Hi Everyone!
I must start with the fact that javacv helped me a lot to create a very responsive vide recorder activity, it works great, BUT I have a problem with the produced vide FPS, is to slow 15fps for resolution 480x360.
- I downloaded the newest javacv and dependencies
- I initialized the camera preview to 30fps
- I initialized the recorder to 30fps
recorder = new FFmpegFrameRecorder(ffmpeg_link,480,360, 1);
recorder.setFormat("mp4");
recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);// AV_CODEC_ID_FLV1
recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
recorder.setSampleRate(44100);
recorder.setFrameRate(30);
recorder.setVideoBitrate(800000);
- I record the preview data[] just like in the RecordActivity example :
public void onPreviewFrame(byte[] data, Camera camera) {
...
yuvIplimage.getByteBuffer().put(data);
long t = 1000 * (System.currentTimeMillis() - pauseDelay - startTime);
if (t > recorder.getTimestamp()) {
recorder.setTimestamp(t);
}
recorder.record(yuvIplimage);
....
}
-> Result is a qualityt good video, but with the frame rate only ~12-15fps, which is bed for me. I need at least 24fps
Tests :
- the onPreviewFrame() gives me 30fps if I remove this line of code "recorder.record(yuvIplimage);"
- if "recorder.record(yuvIplimage);" is working, than it slows down the processing time to half, so only 15fps are recorded.
- I measured and the "recorder.record(yuvIplimage);" is slowing down.
If the device isn't fast enough to save all frames, we got this low fps video, byt I use a Samsung Galaxy S4, so I don't think that it cannot handle those processing.
If I lower the desired recording resolution to 320x240, it will produce a 25fps video.
The conclusion is that the FFmpegFrameRecorder is slow.
Questions :
- what is worng with my code ? my setting are not right ? (in above code snippet)
- how can I keep 480x360 and to have ~ 25fps ?
Please help me.
Thank you