Coder Social home page Coder Social logo

videorecorder's Introduction

VideoRecorder

android视频录制,模仿微视,支持按下录制、抬起暂停。进度条断点显示。

视频录制存在的问题:

1.如何获取摄像头的数据

2.如何把获取到的数据保存到视频文件中

3.如何录制音频,并和视频合并

4.录制视频时如何实现暂停功能

5.android摄像头支持的分辨率可能不符合需求,需要转换分辨率

6.android手机录制出来的视频是旋转了90度的,如何实现旋转(转换到前置摄像头又如何处理)

7.视频旋转、利用图片合成视频、使用本地视频剪辑、后期视频特效添加等等

本项目解决了1、2、3、4、5、6。

image image image image image

License

Copyright 2014 qdrzwd, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.å

videorecorder's People

Contributors

qdrzwd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

videorecorder's Issues

VideoRecorderFFmpeg not support for all devices

HI, First of all thanks for your great stuff. Downloaded your code and builded successfully. Tested on three devices Moto G, Samsung Duos, LG-P990. Its working on Moto G. Not working another two devices(Samsung Duos, LG-P990). Would you please explain me what is the issue. Please reply me as soon as possible

自定义progress中有一点问题布局异常但可以运行,我找到个人解决办法,不知道有没有好的办法请后面追加:

DisplayMetrics dm = new DisplayMetrics();
((Activity) paramContext).getWindowManager().getDefaultDisplay().getMetrics(dm);
perPixel = dm.widthPixels / countRecorderTime;
上面这段会导致在布局初始化的时候:报布局异常
这个在加载布局前获取:widthPixels 我是在工具类中widthPixels 初始化,在再自定义progress中用,就不会再提示了!!!!
如果有其他好的解决办法,请追加

启动报java.awt相关依赖,随后OOM崩溃,无法打开app

E/dalvikvm: Could not find class 'java.awt.Rectangle', referenced from method com.googlecode.javacv.cpp.opencv_core$IplImage.copyTo
W/dalvikvm: VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
03-17 11:21:36.108 29313-29387/com.qd.videorecorder E/dalvikvm-heap: Out of memory on a 82944016-byte allocation.
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: "Thread-2592" prio=5 tid=14 RUNNABLE
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: | group="main" sCount=0 dsCount=0 obj=0x42d76068 self=0x680a6888
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: | sysTid=29387 nice=0 sched=0/0 cgrp=apps handle=1742954528
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: | schedstat=( 0 0 0 ) utm=4 stm=1 core=1
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: at java.nio.MemoryBlock.allocate(MemoryBlock.java:126)
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: at java.nio.ReadWriteDirectByteBuffer.(ReadWriteDirectByteBuffer.java:46)
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:68)
03-17 11:21:36.108 29313-29387/com.qd.videorecorder I/dalvikvm: at com.qd.recorder.RecorderThread.run(RecorderThread.java:48)
03-17 11:21:36.108 29313-29387/com.qd.videorecorder E/dalvikvm: threadid=14: exiting,name=Thread-2592
03-17 11:21:36.108 29313-29387/com.qd.videorecorder W/dalvikvm: threadid=14: thread exiting with uncaught exception (group=0x41dea498)
03-17 11:21:36.108 29313-29387/com.qd.videorecorder E/AndroidRuntime: FATAL EXCEPTION: Thread-2592
java.lang.OutOfMemoryError
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at java.nio.MemoryBlock.allocate(MemoryBlock.java:126)
at java.nio.ReadWriteDirectByteBuffer.(ReadWriteDirectByteBuffer.java:46)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:68)
at com.qd.recorder.RecorderThread.run(RecorderThread.java:48)

关于设置较大的PreviewSize崩溃的问题

很好的工程,发现一个问题,我把PreviewSize调到1920*1080的时候内存溢出,具体是在RecordThread中的run方法中,new出的ByteBuffer超出了内存限制。
if(mByteBuffer == null){
//相当于 mByteBuffer = ByteBuffer.allocateDirect(559872000); OOM
mByteBuffer = ByteBuffer.allocateDirect(mSize * mTotalFrame);
mBytes = new byte[mSize];
}

ByteBuffer.allocateDirect导致java.lang.OutOfMemoryError

com.qd.videorecorder E/AndroidRuntime: FATAL EXCEPTION: Thread-227
                                                                      Process: com.qd.videorecorder, PID: 14200
                                                                      java.lang.OutOfMemoryError
                                                                          at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                          at java.nio.MemoryBlock.allocate(MemoryBlock.java:125)
                                                                          at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:72)
                                                                          at com.qd.recorder.RecorderThread.run(RecorderThread.java:48)

新手疑惑

为什么不直接使用Android SDK中的MediaRecorder?这种实现方式有什么优势?

OutOfMemoryError

Process: com.qd.videorecorder, PID: 26029
java.lang.OutOfMemoryError
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at java.nio.MemoryBlock.allocate(MemoryBlock.java:125)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:72)
at com.qd.recorder.RecorderThread.run(RecorderThread.java:49)

I got 'Could not encode video packet' many time during record video

com.googlecode.javacv.FrameRecorder$Exception: avcodec_encode_video2() error -1: Could not encode video packet.
09-09 16:15:57.949 18104-24174/com.qd.videorecorder W/System.err﹕ at com.qd.recorder.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:697)
09-09 16:15:57.949 18104-24174/com.qd.videorecorder W/System.err﹕ at com.qd.recorder.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:622)
09-09 16:15:57.949 18104-24174/com.qd.videorecorder W/System.err﹕ at com.qd.recorder.RecorderThread.run(RecorderThread.java:65)
09-09 16:15:58.214 18104-24174/com.qd.videorecorder I/recorder﹕ avcodec_encode_video2() error -1: Could not encode video packet.

how can i fix it? i want to make full-screen& high resolution video. but i think this make encode slow

hi 关于优化的一些建议

你的demo很棒 ,不过使用过程中发现了些问题,提一些可以优化的建议
现在的gc上存在一些问题,因为gc过多造成 视频fps很低 。
可以尝试用setPreviewCallbackWithBuffer()来降低帧频
还有 ] rotateYUV420Degree270 这些旋转方法当中的byte 可以不用每次初始化
可以定义两个全局的cacheByte进行运算,这样会减少掉gc

Close the application on start

Hi,
Just to know that I am running this application on my samsung SIII GT I9300 and mostly app is closed can you tell me the reason of it?

Could not find class 'java.awt.image.ComponentColorModel', referenced from method com.googlecode.javacv.cpp.opencv_core$IplImage.getBufferedImage

Error in initialization surfaceview on this line
yuvIplImage = IplImage.create(previewHeight, previewWidth,IPL_DEPTH_8U, 2);

改变尺寸画面拼接

private int previewWidth = 640, screenWidth = 640;
private int previewHeight = 480, screenHeight = 480;
// 获取摄像头的所有支持的分辨率
        /*List<Camera.Size> resolutionList = Util.getResolutionList(mCamera);
        if (resolutionList != null && resolutionList.size() > 0) {
            Collections.sort(resolutionList, new Util.ResolutionComparator());
            Camera.Size previewSize = null;
            if (defaultScreenResolution == -1) {
                boolean hasSize = false;
                // 如果摄像头支持640*480,那么强制设为640*480
                for (int i = 0; i < resolutionList.size(); i++) {
                    Size size = resolutionList.get(i);
                    if (size != null && size.width == 640 && size.height == 480) {
                        previewSize = size;
                        hasSize = true;
                        break;
                    }
                }
                // 如果不支持设为中间的那个
                if (!hasSize) {
                    int mediumResolution = resolutionList.size() / 2;
                    if (mediumResolution >= resolutionList.size())
                        mediumResolution = resolutionList.size() - 1;
                    previewSize = resolutionList.get(mediumResolution);
                }
            } else {
                if (defaultScreenResolution >= resolutionList.size())
                    defaultScreenResolution = resolutionList.size() - 1;
                previewSize = resolutionList.get(defaultScreenResolution);
            }
            // 获取计算过的摄像头分辨率
            if (previewSize != null) {
                previewWidth = previewSize.width;
                previewHeight = previewSize.height;
                cameraParameters.setPreviewSize(previewWidth, previewHeight);
                if (videoRecorder != null) {
                    videoRecorder.setImageWidth(previewWidth);
                    videoRecorder.setImageHeight(previewHeight);
                }

            }
        */

还有什么要改的吗?

这样输出的视频左边480*480正常 右边(640-480)是左边的重叠

去掉`rotateYUV420Degree90()`画面完全乱了!这个不只是转向吗?

与vitamio冲突

将这个同时和vitamio 同时引入项目,某些so文件会在data\data\package\lib 无so文件,怎么解决啊

关于删除一个视频片段

你好,我也是因为公司有项目有类似“美拍”方面的需求,所以对你这个demo非常感兴趣,希望可以进行一些其他功能的探讨,我们可以认为在录制过程中录制了多个小视频片段,有没有想法如何实现删除其中的一段视频,或者结束录制后可以任意调整每段视频的顺序。 谢谢!

add watermark

how can we add watermark on video during recording or after we have saved the video

com.qd.videorecorder I/recorder: 录制错误

com.qd.videorecorder I/recorder: 录制错误avcodec_encode_video2() error -1: Could not encode video packet.红米2a,5.1.1 ui 8

11-23 18:06:13.361 25013-25264/com.qd.videorecorder W/System.err: com.googlecode.javacv.FrameRecorder$Exception: avcodec_encode_video2() error -1: Could not encode video packet.
11-23 18:06:13.361 25013-25264/com.qd.videorecorder W/System.err: at com.qd.recorder.NewFFmpegFrameRecorder.record(NewFFmpegFrameRecorder.java:767)
11-23 18:06:13.361 25013-25264/com.qd.videorecorder W/System.err: at com.qd.recorder.NewFFmpegFrameRecorder.record(NewFFmpegFrameRecorder.java:689)
11-23 18:06:13.361 25013-25264/com.qd.videorecorder W/System.err: at com.qd.recorder.RecorderThread.run(RecorderThread.java:67)

11-23 18:06:34.381 25013-25013/com.qd.videorecorder E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
11-23 18:06:34.381 25013-25013/com.qd.videorecorder I/ViewRootImpl: CPU Rendering VSync enable = true
11-23 18:06:34.391 25013-25013/com.qd.videorecorder D/ActivityThreadInjector: clearCachedDrawables.
11-23 18:06:34.581 25013-25013/com.qd.videorecorder E/MediaPlayer: Should have subtitle controller already set
11-23 18:06:34.671 25013-25013/com.qd.videorecorder E/MediaPlayer: Should have subtitle controller already set

录制完之后只要3s左右,再次录制,就录制完,直接无图像了。只要3s左右的声音

视频编码格式

你好,如果要把视频的编码格式换成H264的话需要改哪些内容?

has text relocations

Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.qd.videorecorder-1/lib/arm/libavcodec.so: has text relocations

Delete a video chunk

Hi,
I want to delete some portion of the video.Let I took a 5 sec video and I want to selete last 2 sec video. How can I move 2 sec back .

Different recording speeds

Hi,

Is it possible to record video at different fps? For example I would like to record video at 120fps.

Thank you!

我移植的时候遇到一个问题,不能加载库

Process: com.niusan.ctchaonao, PID: 21354
java.lang.UnsatisfiedLinkError: Couldn't load checkneon from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.niusan.ctchaonao-51.apk"],nativeLibraryDirectories=[/data/app-lib/com.niusan.ctchaonao-51, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.niusan.ctchaonao.recorder.FFmpegRecorderActivity.(FFmpegRecorderActivity.java:257)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2370)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5426)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)

旋转视频,变花

我想横向拍摄,因为视角比较广,看了您的代码,在NewFFmpegFrameRecorder的record方法中,注释了这段代码://image = rotate(image,90);,然后我把注释去掉,再录制视频,结果变花了。

红米切换前置闪退

只用红米试用了一下,切换前置摄像头的时候闪退了。 拍完视频,无法使用?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.