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
FFmpegFrameRecorder creates video with duration less than last frame timestamp #337
Comments
Maybe there is a bug, but the mp4 format isn't known to be easy to work with anyway. I'd suggest trying the Matroska (mkv) format, if that's an option. |
Is this still happening with JavaCV 1.2? |
Sorry for the delay. Now we use MediaCodec instead of ffmpeg in our project.
But I get the following error:
|
Thanks for checking! That's a known issue with Gradle: #395 (comment) Let me know if that's enough to get it working, thanks! |
Any updates on this? JavaCV 1.3 has just been released. Maybe this got fixed in new versions of FFmpeg... |
I'm guessing you simply forgot to call |
I use FFmpegFrameRecorder (javaCV 1.1) to create video fragments with max duration of 30 seconds from screenshots, which I get from MediaProjection on Android. In each video fragment first frame has timestamp 0.
I have the following recorder settings:
MediaProjection gives me next screenshot only when there are changes on the screen, so frames are recorded irregularly. When it is time to close current video fragment, usually the last recorded frame has timestamp smaller than 30 seconds. I found only one way to get video fragment of exactly 30 seconds – I record last real frame several times. As I understand, if first frame has timestamp 0, video duration must be equal to last frame timestamp + last frame duration. For example, if last real frame has timestamp 27.5 sec, I record this frame with timestamps 28.5 sec, 29.5 sec, 29.966 sec. This approach works perfectly with mpeg4 codec, but with H264 codec result video duration is much smaller than last frame timestamp. For example, for one of video fragments video duration (determined by exiftool and mp4parser) is 28.7 sec and last frame has timestamp 29.966 sec and pkt_duration_time = 0.033333 sec (determined by ffprobe).
So I can’t create video of specified duration using FFmpegFrameRecorder with H264 codec. Is it a bug in FFmpegFrameRecorder (when using H264 codec) or am I missing something? May be, there is a way to set duration for last frame instead of recording the last real frame with different timestamps?
The text was updated successfully, but these errors were encountered: