Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFmpegFrameGrabber works great at 640x480@60 fps but the framerate is decreased to 18 fps at 1920x1080@30 fps #1701

Closed
rgm-22 opened this issue Sep 27, 2021 · 5 comments

Comments

@rgm-22
Copy link

rgm-22 commented Sep 27, 2021

Hi @saudet!

Thank you very much for your awesome support! 😀

I am having this issue with JavaCV 1.5.4.

I can record perfectly with my camera at 640x480 @ 60 fps.
But when I set 1280x720 (HD) @ 60 fps and 1920x1080 (FullHD) @ 30 fps the preview is slowed down and the resulting recording video is 1280x720 (HD) @ 40 fps and 1920x1080 (FullHD) @ 18 fps.

My configuration:
ffmpeg_Frame_Recorder = new FFmpegFrameRecorder(videoPath, 1920, 1080, 2);

/// Video
ffmpeg_Frame_Recorder.setFormat("mp4");
ffmpeg_Frame_Recorder.setFrameRate(30);
ffmpeg_Frame_Recorder.setPixelFormat(0);
ffmpeg_Frame_Recorder.setVideoBitrate(10000000);
ffmpeg_Frame_Recorder.setVideoQuality(0);

/// Audio
ffmpeg_Frame_Recorder.setAudioBitrate(194000);
ffmpeg_Frame_Recorder.setSampleRate(48000);
mAudioRecordRunnable = new AudioRecordRunnable();

I am using OpenCV and

ffmpeg_Frame_Recorder.record(new OpenCVFrameConverter.ToOrgOpenCvCoreMat().convert(mat));

Any help is really appreciated!

@saudet
Copy link
Member

saudet commented Sep 27, 2021

Please try to use hardware acceleration...

@rgm-22
Copy link
Author

rgm-22 commented Sep 28, 2021

Thank you for your answer!

Do you know if it is possible on Android? I have checked out that you mentioned this in another issue:

"You'll probably need hardware acceleration to encode at any kind of speed though. Unfortunately, FFmpeg doesn't support hardware acceleration for encoding on Android: https://trac.ffmpeg.org/wiki/HWAccelIntro (Unless this has changed recently @tmm1?)"

Thank you again!

@saudet
Copy link
Member

saudet commented Sep 28, 2021

Nope, not available on Android. You'll need to use the MediaCodec API for that

@saudet
Copy link
Member

saudet commented Sep 28, 2021

Duplicate of #1693

@saudet saudet closed this as completed Sep 28, 2021
@saudet saudet marked this as a duplicate of #1693 Sep 28, 2021
@saudet
Copy link
Member

saudet commented Mar 3, 2023

FFmpeg 6.0 now includes support for hardware accelerated encoding using MediaCodec.
Please give it a try with the snapshots: http://bytedeco.org/builds/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants