android javacv ffmpeg(ffmpeg)录像fps低

NOTE: I have updated this since originally asking the question to reflect some of what I have learned about loading live camera images into the ffmpeg libraries.
I am using ffmpeg from javacv compiled for Android to encode/decode video for my application. (Note that originally, I was trying to use ffmpeg-java, but it has some incompatible libraries)
Original problem: The problem that I've run into is that I am currently getting each frame as a Bitmap (just a plain android.graphics.Bitmap) and I can't figure out how to stuff that into the encoder.
Solution in javacv's ffmpeg: Use avpicture_fill(), the format from Android is supposedly YUV420P, though I can't verify this until my encoder issues (below) are fixed.
avcodec.avpicture_fill((***Picture)mFrame, picPointer, avutil.PIX_FMT_YUV420P, VIDEO_WIDTH, VIDEO_HEIGHT)
Problem Now: The line that is supposed to actually encode the data crashes the thread. I get a big native code stack trace that I'm unable to understand.
Does anybody have a suggestion?
Here is the code that I am using to instantiate all the ffmpeg libraries:
avcodec.avcodec_register_all();
avcodec.avcodec_init();
avformat.av_register_all();
mCodec = avcodec.avcodec_find_encoder(avcodec.CODEC_ID_H263);
if (mCodec == null)
Logging.Log("Unable to find encoder.");
Logging.Log("Found encoder.");
mCodecCtx = avcodec.avcodec_alloc_context();
mCodecCtx.bit_rate(300000);
mCodecCtx.codec(mCodec);
mCodecCtx.width(VIDEO_WIDTH);
mCodecCtx.height(VIDEO_HEIGHT);
mCodecCtx.pix_fmt(avutil.PIX_FMT_YUV420P);
mCodecCtx.codec_id(avcodec.CODEC_ID_H263);
mCodecCtx.codec_type(avutil.***MEDIA_TYPE_VIDEO);
***Rational ratio = new ***Rational();
ratio.num(1);
ratio.den(30);
mCodecCtx.time_base(ratio);
mCodecCtx.coder_type(1);
mCodecCtx.flags(mCodecCtx.flags() | avcodec.CODEC_FLAG_LOOP_FILTER);
mCodecCtx.me_cmp(avcodec.FF_LOSS_CHROMA);
mCodecCtx.me_method(avcodec.ME_HEX);
mCodecCtx.me_subpel_quality(6);
mCodecCtx.me_range(16);
mCodecCtx.gop_size(30);
mCodecCtx.keyint_min(10);
mCodecCtx.scenechange_threshold(40);
mCodecCtx.i_quant_factor((float) 0.71);
mCodecCtx.b_frame_strategy(1);
mCodecCtx.qcompress((float) 0.6);
mCodecCtx.qmin(10);
mCodecCtx.qmax(51);
mCodecCtx.max_qdiff(4);
mCodecCtx.max_b_frames(1);
mCodecCtx.refs(2);
mCodecCtx.directpred(3);
mCodecCtx.trellis(1);
mCodecCtx.flags2(mCodecCtx.flags2() | avcodec.CODEC_FLAG2_BPYRAMID | avcodec.CODEC_FLAG2_WPRED | avcodec.CODEC_FLAG2_8X8DCT | avcodec.CODEC_FLAG2_FASTPSKIP);
if (avcodec.avcodec_open(mCodecCtx, mCodec) == 0)
Logging.Log("Unable to open encoder.");
Logging.Log("Encoder opened.");
mFrameSize = avcodec.avpicture_get_size(avutil.PIX_FMT_YUV420P, VIDEO_WIDTH, VIDEO_HEIGHT);
Logging.Log("Frame size - '" + mFrameSize + "'.");
//mPic = new ***Picture(mPicSize);
mFrame = avcodec.avcodec_alloc_frame();
if (mFrame == null)
Logging.Log("Unable to alloc frame.");
This is what I want to be able to execute next:
BytePointer picPointer = new BytePointer(data);
int bBuffSize = mFrameS
BytePointer bBuffer = new BytePointer(bBuffSize);
int picSize = 0;
if ((picSize = avcodec.avpicture_fill((***Picture)mFrame, picPointer, avutil.PIX_FMT_YUV420P, VIDEO_WIDTH, VIDEO_HEIGHT)) &= 0)
Logging.Log("Couldn't convert preview to ***Picture (" + picSize + ")");
Logging.Log("Converted preview to ***Picture (" + picSize + ")");
VCAP_Package vPackage = new VCAP_Package();
if (mCodecCtx.isNull())
Logging.Log("Codec Context is null!");
//encode the image
int size = avcodec.avcodec_encode_video(mCodecCtx, bBuffer, bBuffSize, mFrame);
int totalSize = 0;
while (size &= 0)
totalSize +=
Logging.Log("Encoded '" + size + "' bytes.");
//Get any delayed frames
size = avcodec.avcodec_encode_video(mCodecCtx, bBuffer, bBuffSize, null);
Logging.Log("Finished encoding. (" + totalSize + ")");
But, as of now, I don't know how to put the Bitmap into the right piece or if I have that setup correctly.
A few notes about the code:
- VIDEO_WIDTH = 352
- VIDEO_HEIGHT = 288
- VIDEO_FPS = 30;
解决方案 After a lot of searching, I figured out that you have to load the pointers in a fairly strict and awkward manner.
This is how I got everything working:
Codec setup:
avcodec.avcodec_register_all();
avcodec.avcodec_init();
avformat.av_register_all();
/* find the H263 video encoder */
mCodec = avcodec.avcodec_find_encoder(avcodec.CODEC_ID_H263);
if (mCodec == null) {
Log.d("TEST_VIDEO", "avcodec_find_encoder() run fail.");
mCodecCtx = avcodec.avcodec_alloc_context();
picture = avcodec.avcodec_alloc_frame();
/* put sample parameters */
mCodecCtx.bit_rate(400000);
/* resolution must be a multiple of two */
mCodecCtx.width(VIDEO_WIDTH);
mCodecCtx.height(VIDEO_HEIGHT);
/* frames per second */
***Rational avFPS = new ***Rational();
avFPS.num(1);
avFPS.den(VIDEO_FPS);
mCodecCtx.time_base(avFPS);
mCodecCtx.pix_fmt(avutil.PIX_FMT_YUV420P);
mCodecCtx.codec_id(avcodec.CODEC_ID_H263);
mCodecCtx.codec_type(avutil.***MEDIA_TYPE_VIDEO);
/* open it */
if (avcodec.avcodec_open(mCodecCtx, mCodec) & 0) {
Log.d("TEST_VIDEO", "avcodec_open() run fail.");
/* alloc image and output buffer */
output_buffer_size = 100000;
output_buffer = avutil.av_malloc(output_buffer_size);
size = mCodecCtx.width() * mCodecCtx.height();
picture_buffer = avutil.av_malloc((size * 3) / 2); /* size for YUV 420 */
picture.data(0, new BytePointer(picture_buffer));
picture.data(1, picture.data(0).position(size));
picture.data(2, picture.data(1).position(size / 4));
picture.linesize(0, mCodecCtx.width());
picture.linesize(1, mCodecCtx.width() / 2);
picture.linesize(2, mCodecCtx.width() / 2);
Handling the preview data:
//(1)Convert byte[] first
byte[] data420 = new byte[data.length];
convert_yuv422_to_yuv420(data, data420, VIDEO_WIDTH, VIDEO_HEIGHT);
//(2) Fill picture buffer
int data1_offset = VIDEO_HEIGHT * VIDEO_WIDTH;
int data2_offset = data1_offset * 5 / 4;
int pic_linesize_0 = picture.linesize(0);
int pic_linesize_1 = picture.linesize(1);
int pic_linesize_2 = picture.linesize(2);
for(y = 0; y & VIDEO_HEIGHT; y++)
for(x = 0; x & VIDEO_WIDTH; x++)
picture.data(0).put((y * pic_linesize_0 + x), data420[y * VIDEO_WIDTH + x]);
//Cb and Cr
for(y = 0; y & VIDEO_HEIGHT / 2; y++) {
for(x = 0; x & VIDEO_WIDTH / 2; x++) {
picture.data(1).put((y * pic_linesize_1 + x), data420[data1_offset + y * VIDEO_WIDTH / 2 + x]);
picture.data(2).put((y * pic_linesize_2 + x), data420[data2_offset + y * VIDEO_WIDTH / 2 + x]);
//(2)Encode
//Encode the image into output_buffer
out_size = avcodec.avcodec_encode_video(mCodecCtx, new BytePointer(output_buffer), output_buffer_size, picture);
Log.d("TEST_VIDEO", "Encoded '" + out_size + "' bytes");
//Delayed frames
for(; out_size & 0; i++) {
out_size = avcodec.avcodec_encode_video(mCodecCtx, new BytePointer(output_buffer), output_buffer_size, null);
Log.d("TEST_VIDEO", "Encoded '" + out_size + "' bytes");
//fwrite(output_buffer, 1, out_size, file);
I am still working to packetize the data, but the ongoing test project can be found here @
本文地址: &
注:由于最初提出这个问题反映了一些什么,我已经了解了装载现场摄像机图像到FFmpeg的图书馆我已经更新了这个
我使用的ffmpeg 从 javacv 编译为Android为en code /德code视频为我的应用程序。 (请注意,原来,我试图用的ffmpeg-java的,但它有一些不兼容的库)
原题:,我碰到的问题是,我目前得到的每一帧作为位图(只是一个普通的 android.graphics.Bitmap ),我无法弄清楚如何的东西,到了EN codeR。
解决方案的的ffmpeg ::使用avpicture_fill(),格式从Android是所谓YUV420P,虽然我无法验证这一点,直到我恩codeR问题(下)是固定的。
*** codec.avpicture_fill((***Picture)mFrame,picPointer,avutil.PIX_FMT_YUV420P,VIDEO_WIDTH,VIDEO_HEIGHT)
现在的问题:是应该的线路实际上连接$ C C数据$崩溃的线程。我明白,我无法理解一个大本地code堆栈跟踪。没有任何人有一个建议?
下面是我使用实例的所有的ffmpeg的code 库:
*** codec.av codec_register_all();
*** codec.av codec_init();
avformat.av_register_all();
M codeC = *** codec.av codec_find_en codeR(*** codeC codeC_ID_H263);
如果(M codeC == NULL)
Logging.Log(“无法找到连接codeR。”);
Logging.Log(“发现恩codeR。”);
M codecCtx = *** codec.av codec_alloc_context();
M codecCtx.bit_rate(300000);
M codecCtx codeC(M codeC)。
M codecCtx.width(VIDEO_WIDTH);
M codecCtx.height(VIDEO_HEIGHT);
M codecCtx.pix_fmt(avutil.PIX_FMT_YUV420P);
M codecCtx codec_id(*** codeC codeC_ID_H263)。
M codecCtx codec_type(avutil.***MEDIA_TYPE_VIDEO)。
***Rational比=新***Rational();
ratio.num(1);
ratio.den(30);
M codecCtx.time_base(比);
。M codecCtx coder_type(1);
M codecCtx.flags(M codecCtx.flags()| *** codeC codeC_FLAG_LOOP_FILTER。);
M codecCtx.me_cmp(*** codec.FF_LOSS_CHROMA);
M codecCtx.me_method(*** codec.ME_HEX);
M codecCtx.me_subpel_quality(6);
M codecCtx.me_range(16);
M codecCtx.gop_size(30);
M codecCtx.keyint_min(10);
M codecCtx.scenechange_threshold(40);
M codecCtx.i_quant_factor((浮点)0.71);
M codecCtx.b_frame_strategy(1);
M codecCtx.qcom preSS((浮点)0.6);
M codecCtx.qmin(10);
M codecCtx.qmax(51);
M codecCtx.max_qdiff(4);
M codecCtx.max_b_frames(1);
M codecCtx.refs(2);
M codecCtx.direct preD(3);
M codecCtx.trellis(1);
M codecCtx.flags2(M codecCtx.flags2()|。*** codeC codeC_FLAG2_BPYRAMID |。*** codeC codeC_FLAG2_W $ P $物pD | *** codeC。 。codeC_FLAG2_8X8DCT | *** codeC codeC_FLAG2_FASTPSKIP);
如果(*** codec.av codec_open(M codecCtx,M codeC)== 0)
Logging.Log(“无法打开EN codeR。”);
Logging.Log(“恩codeR打开。”);
mFrameSize = *** codec.avpicture_get_size(avutil.PIX_FMT_YUV420P,VIDEO_WIDTH,VIDEO_HEIGHT);
Logging.Log(“帧大小 - ”“+ mFrameSize +”'“);
// MPIC =新***Picture(mPicSize);
mFrame = *** codec.av codec_alloc_frame();
如果(mFrame == NULL)
Logging.Log(“无法ALLOC框架。”);
这就是我希望能够继续执行下一个:
BytePointer picPointer =新BytePointer(数据);
INT bBuffSize = mFrameS
BytePointer bBuffer =新BytePointer(bBuffSize);
INT picSize = 0;
如果((picSize = *** codec.avpicture_fill((***Picture)mFrame,picPointer,avutil.PIX_FMT_YUV420P,VIDEO_WIDTH,VIDEO_HEIGHT))< = 0)
Logging.Log(“无法转换preVIEW来***Picture(”+ picSize +“)”);
Logging.Log(“转换preVIEW来***Picture(”+ picSize +“)”);
VCAP_Package vPackage =新VCAP_Package();
如果(M codecCtx.isNull())
Logging.Log(“codeC上下文为空!”);
// EN code图像
INT大小= *** codec.av codec_en code_video(M codecCtx,bBuffer,bBuffSize,mFrame);
INT totalSize = 0;
而(尺寸与GT; = 0)
totalSize + =大小;
Logging.Log(“恩codeD'”+规模+“”字节。“);
//获取任何延迟帧
大小= *** codec.av codec_en code_video(M codecCtx,bBuffer,bBuffSize,NULL);
Logging.Log(“成品编码(”+ totalSize +“)”);
不过,截至目前,我不知道如何把位图到右边那条或者如果我正确地有***。
有关code的几个注意事项:
VIDEO_WIDTH
VIDEO_HEIGHT
解决方案 很多搜索之后,我想通了,你必须加载指针在一个相当严格,尴尬的方式。这是我得到的一切工作:
codeC设置:
*** codec.av codec_register_all();
*** codec.av codec_init();
avformat.av_register_all();
/ *找到H263视频连接codeR * /
M codeC = *** codec.av codec_find_en codeR(*** codeC codeC_ID_H263);
如果(M codeC == NULL){
Log.d(“TEST_VIDEO”,“*** codec_find_en codeR()必定失败。”);
M codecCtx = *** codec.av codec_alloc_context();
照片= *** codec.av codec_alloc_frame();
/ *把样品参数* /
M codecCtx.bit_rate(400000);
/ *分辨率必须是2的倍数* /
M codecCtx.width(VIDEO_WIDTH);
M codecCtx.height(VIDEO_HEIGHT);
/* 每秒帧数 */
***Rational avFPS =新***Rational();
avFPS.num(1);
avFPS.den(VIDEO_FPS);
M codecCtx.time_base(avFPS);
M codecCtx.pix_fmt(avutil.PIX_FMT_YUV420P);
M codecCtx codec_id(*** codeC codeC_ID_H263)。
M codecCtx codec_type(avutil.***MEDIA_TYPE_VIDEO)。
/* 打开它 */
如果(*** codec.av codec_open(M codecCtx,M codeC)小于0){
Log.d(“TEST_VIDEO”,“*** codec_open()必定失败。”);
/ * ALLOC形象和输出缓冲区* /
output_buffer_size = 100000;
output_buffer = avutil.av_malloc(output_buffer_size);
大小= M codecCtx.width()* M codecCtx.height();
picture_buffer = avutil.av_malloc((尺寸* 3)/ 2); / *尺寸YUV 420 * /
picture.data(0,新BytePointer(picture_buffer));
picture.data(1,picture.data(0).position(大小));
picture.data(2,picture.data(1).position(尺寸/ 4));
picture.linesize(0,M codecCtx.width());
picture.linesize(1,M codecCtx.width()/ 2);
picture.linesize(2,M codecCtx.width()/ 2);
处理preVIEW数据:
//(1)转换的byte []第一
byte []的data420 =新的字节[data.length]
convert_yuv422_to_yuv420(数据,data420,VIDEO_WIDTH,VIDEO_HEIGHT);
//(2)填写图像缓存
INT data1_offset = VIDEO_HEIGHT * VIDEO_WIDTH;
INT data2_offset = data1_offset * 5/4;
INT pic_linesize_0 = picture.linesize(0);
INT pic_linesize_1 = picture.linesize(1);
INT pic_linesize_2 = picture.linesize(2);
对于(Y = 0; Y< VIDEO_HEIGHT; Y ++)
为(X = 0; X
- 其中; VIDEO_WIDTH; X ++)
picture.data(0)。把((Y * pic_linesize_0 + X),data420 [Y * VIDEO_WIDTH + X]);
对于(Y = 0; Y< VIDEO_HEIGHT / 2; Y ++){
为(X = 0; X
- 其中; VIDEO_WIDTH / 2; X ++){
picture.data(1)。把((Y * pic_linesize_1 + X),data420 [data1_offset + Y * VIDEO_WIDTH / 2 + X]);
picture.data(2)。把((Y * pic_linesize_2 + X),data420 [data2_offset + Y * VIDEO_WIDTH / 2 + X]);
//(2)恩code
// EN code中的图像转换成output_buffer
out_size = *** codec.av codec_en code_video(M codecCtx,新BytePointer(output_buffer),output_buffer_size,图片);
Log.d(“TEST_VIDEO”,“恩codeD'”+ out_size +“”字节“);
对于(; out_size大于0;我++){
out_size = *** codec.av codec_en code_video(M codecCtx,新BytePointer(output_buffer),output_buffer_size,NULL);
Log.d(“TEST_VIDEO”,“恩codeD'”+ out_size +“”字节“);
// FWRITE(output_buffer,1,out_size,文件);
我还在努力打包数据,但正在进行的测试项目都可以在这里找到@的
本文地址: &
扫一扫关注官方微信>> 使用FFmpeg实现视频录制和视频播放
使用FFmpeg实现视频录制和视频播放
所属分类:
下载地址:
VideoRecorder-master.zip文件大小:12.26 MB
分享有礼! 》
请点击右侧的分享按钮,把本代码分享到各社交媒体。
通过您的分享链接访问Codeforge,每来2个新的IP,您将获得0.1 积分的奖励。
通过您的分享链接,每成功注册一个用户,该用户在Codeforge上所获得的每1个积分,您都将获得0.2 积分的分成奖励。
android视频录制,模仿微视,支持按下录制、抬起暂停。进度条断点显示。该源码解决以下问题: 1.如何获取摄像头的数据2.如何把获取到的数据保存到视频文件中3.如何录制音频,并和视频合并4.录制视频时如何实现暂停功能5.android摄像头支持的分辨率可能不符合需求,需要转换分辨率6.android手机录制出来的视频是旋转了90度的,如何实现旋转(转换到前置摄像头又如何处理)
Sponsored links
源码文件列表
温馨提示: 点击源码文件名可预览文件内容哦 ^_^
.gitignore332.00 B 22:22
org.eclipse.core.resources.prefs244.00 B 22:22
1.82 kB 22:22
LICENSE34.30 kB 22:22
996.00 B 22:22
ic_launcher-web.png50.19 kB 22:22
Screenshot_-22-07-35.png100.57 kB 22:22
Screenshot_-22-07-49.png98.71 kB 22:22
Screenshot_-22-07-58.png99.03 kB 22:22
Screenshot_-22-08-08.png99.24 kB 22:22
Screenshot_-22-08-18.png61.23 kB 22:22
Thumbs.db218.00 kB 22:22
android-support-v4.jar376.65 kB 22:22
libavcodec.so8.22 MB 22:22
libavfilter.so794.71 kB 22:22
libavformat.so1.37 MB 22:22
libavutil.so273.37 kB 22:22
libcheckneon.so13.12 kB 22:22
libffmpeginvoke.so13.12 kB 22:22
libjniavcodec.so597.40 kB 22:22
libjniavfilter.so341.40 kB 22:22
libjniavformat.so465.40 kB 22:22
libjniavutil.so485.40 kB 22:22
libjniopencv_core.so653.24 kB 22:22
libjniopencv_imgproc.so341.24 kB 22:22
libjniswresample.so109.40 kB 22:22
libjniswscale.so133.40 kB 22:22
libopencv_core.so2.33 MB 22:22
libopencv_imgproc.so2.06 MB 22:22
libswresample.so77.24 kB 22:22
libswscale.so269.24 kB 22:22
libtbb.so225.21 kB 22:22
javacpp.jar156.91 kB 22:22
javacv.jar1.10 MB 22:22
781.00 B 22:22
project.properties563.00 B 22:22
btn_darkgrey_bg.9.png158.00 B 22:22
btn_darkgrey_bg_pressed.9.png158.00 B 22:22
btn_dialog_normal.png1.01 kB 22:22
btn_lightgreen_bg.9.png164.00 B 22:22
btn_lightgreen_bg_pressed.9.png160.00 B 22:22
button.png791.00 B 22:22
dialog_title_bar.png273.00 B 22:22
f10_large.jpg88.34 kB 22:22
f1_large.jpg88.17 kB 22:22
f2_large.jpg114.06 kB 22:22
f4_large.jpg121.87 kB 22:22
f5_large.jpg115.76 kB 22:22
f6_large.jpg93.19 kB 22:22
f7_large.jpg144.10 kB 22:22
f8_large.jpg105.33 kB 22:22
f9_large.jpg108.12 kB 22:22
guide_btn.png6.40 kB 22:22
guide_btn_pressed.png6.44 kB 22:22
guide_focus.png91.30 kB 22:22
guide_icn_close.png1.38 kB 22:22
guide_icn_close_pressed.png1.38 kB 22:22
guide_text.png15.64 kB 22:22
ic_launcher.png7.48 kB 22:22
icn_change_view.png1.59 kB 22:22
icn_change_view_pressed.png1.59 kB 22:22
icn_flashlight_off.png1.21 kB 22:22
icn_flashlight_on.png1.21 kB 22:22
icn_move.png1.21 kB 22:22
icn_move_pressed.png1.22 kB 22:22
icn_pic_choose.png2.07 kB 22:22
icn_pic_delete.png1.46 kB 22:22
icn_picture.png1.24 kB 22:22
icn_picture_pressed.png1.24 kB 22:22
icn_play_big.png5.65 kB 22:22
icn_play_small.png2.71 kB 22:22
icn_save.png1.09 kB 22:22
icn_save_pressed.png1.09 kB 22:22
icn_video.png1.13 kB 22:22
icn_video_pressed.png1.13 kB 22:22
icn_zoomin.png1.20 kB 22:22
icn_zoomin_pressed.png1.20 kB 22:22
m11_large.jpg127.39 kB 22:22
m12_large.jpg63.58 kB 22:22
m13_large.jpg128.52 kB 22:22
m14_large.jpg80.05 kB 22:22
m16_large.jpg109.19 kB 22:22
m3_large.jpg110.86 kB 22:22
progress_bar_green.9.png136.00 B 22:22
progress_bar_grey.9.png112.00 B 22:22
record_icon.png712.00 B 22:22
semi_transparent.png261.00 B 22:22
sign_video.png1.00 kB 22:22
slide_bar.png1.51 kB 22:22
slide_bar_pressed.png1.54 kB 22:22
video_text01.png3.96 kB 22:22
video_text02.png3.04 kB 22:22
video_text03.png4.21 kB 22:22
video_text04.png3.44 kB 22:22
ic_launcher.png3.69 kB 22:22
ic_launcher.png12.22 kB 22:22
ic_launcher.png24.20 kB 22:22
390.00 B 22:22
509.00 B 22:22
515.00 B 22:22
394.00 B 22:22
499.00 B 22:22
491.00 B 22:22
319.00 B 22:22
564.00 B 22:22
365.00 B 22:22
413.00 B 22:22
2.03 kB 22:22
4.88 kB 22:22
1.76 kB 22:22
2.93 kB 22:22
324.00 B 22:22
381.00 B 22:22
78.00 B 22:22
1.64 kB 22:22
1.51 kB 22:22
39.15 kB 22:22
3.63 kB 22:22
35.41 kB 22:22
41.10 kB 22:22
5.07 kB 22:22
2.29 kB 22:22
1.93 kB 22:22
12.69 kB 22:22
4.96 kB 22:22
(提交有效评论获得积分)
评论内容不能少于15个字,不要超出160个字。
wangzhe_90228楼上说的对啊 能不能便宜点啊
wangzhe_90228很好
就是录视频时有杂音怎么回事啊?
浅吟且行的未来想看下,应该是不错的,要是能开源出来,估计感谢的人会更多,哈哈!!
yxb没有jni源码,想学习和修改都不行,骗钱
leeeeeeq这个是github上的代码好意思要这么贵 ,真是醉了
评价成功,多谢!
下载VideoRecorder-master.zip
CodeForge积分(原CF币)全新升级,功能更强大,使用更便捷,不仅可以用来下载海量源代码马上还可兑换精美小礼品了
您的积分不足,优惠套餐快速获取 30 积分
10积分 / ¥100
30积分 / ¥200原价 ¥300 元
100积分 / ¥500原价 ¥1000 元
订单支付完成后,积分将自动加入到您的账号。以下是优惠期的人民币价格,优惠期过后将恢复美元价格。
支付宝支付宝付款
微信钱包微信付款
更多付款方式:、
您本次下载所消耗的积分将转交上传作者。
同一源码,30天内重复下载,只扣除一次积分。
鲁ICP备号-3 runtime:Elapsed:128.969ms - init:0.2;find:2.8;t:1.8;tags:0.3;related:73.5;comment:6.2; 27.69
登录 CodeForge
还没有CodeForge账号?
Switch to the English version?
^_^"呃 ...
Sorry!这位大神很神秘,未开通博客呢,请浏览一下其他的吧ffmpeg - Android JavaCV FFmpegFrameRecorder.stop() throws exception - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
J it only takes a minute:
I am using FFmpegFrameRecorder to capture preview frames from camera. I am using this setting:
mVideoRecorder = new FFmpegFrameRecorder(mVideoPath, 300, 300, 1);
mVideoRecorder.setFormat("mp4");
mVideoRecorder.setSampleRate(44100);
mVideoRecorder.setFrameRate(30);
mVideoRecorder.setVideoCodec(avcodec.***_CODEC_ID_H264);
mVideoRecorder.setAudioCodec(avcodec.***_CODEC_ID_AAC);
mVideoRecorder.setVideoQuality(0);
mVideoRecorder.setAudioQuality(0);
mVideoRecorder.setVideoBitrate(768000);
mVideoRecorder.setAudioBitrate(128000);
mVideoRecorder.setGopSize(1);
After I have finished capturing all frames by calling .record(IplImage) method I call mVideoRecorder.stop().
But from time to time stop() method throws
org.bytedeco.javacv.FrameRecorder$Exception: av_interleaved_write_frame() error -22 while writing interleaved video frame.
at org.bytedeco.javacv.FFmpegFrameRecorder.record(FFmpegFrameRecorder.java:727)
at org.bytedeco.javacv.FFmpegFrameRecorder.stop(FFmpegFrameRecorder.java:613)
I have not seen any regularity in this behaviour nor have been able to found what error -22 is. And after that no ffmpeg call on file in mVideoPath works (I guess that file is not even valid due that error).
I would really appreciate any help with this issue, thanks :)
3,85722142
Know someone who can answer? Share a link to this
via , , , or .
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Browse other questions tagged
rev .24880
Stack Overflow works best with JavaScript enabled

参考资料

 

随机推荐