admin管理员组文章数量:1122846
I'm working with a MJPEG stream source
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn
I want to capture this stream and save it to an MP4 file using FFmpeg, but I am running into a weird issue.
The only way it works fine is when I just copy the stream without reencoding and using wallclock as timestamps (cmd 1):
ffmpeg -use_wallclock_as_timestamps 1 -i "http://IP/video/1280x720" -c:v copy output_good.mp4
However, when I try encoding the stream with libx264, the playback speed of the resulting video becomes slower than 100%, causing the video to gradually fall out of sync with real-time. This happens even when I use any encoding, also when I explicitly set the frame rate or vsync. For example, these commands fail:
- CMD 2:
ffmpeg -i "http://IP/video/1280x720" -c:v libx264 -r 30 -preset fast output_bad1.mp4
- CMD 3:
ffmpeg -use_wallclock_as_timestamps 1 -i "http://IP/video/1280x720" -c:v libx264 output.mp4
As you can see in the comparison of the resulting videos, the playback gradually slows down with CMD 2 and CMD 3, while it's alright with CMD 1.
What I've noticed is that on the FFmpeg stdout, when using encoding, the speed=
and FPS=
go up and up, e.g. to 31 FPS even though my source is technically at 25 FPS.
What I've tried:
- different encoding codecs (e.g. libvpx)
- -re
- preset ultrafast on encoding
- vsync (fps_mode), both ctr and vfr
- fps=30 filter
Has anyone encountered a similar issue or know how to force FFmpeg to preserve the correct playback speed while encoding or enforcing a frame rate? Thanks!
本文标签: videoIssue with MJPEG stream playback speed when encoding with FFmpegStack Overflow
版权声明:本文标题:video - Issue with MJPEG stream playback speed when encoding with FFmpeg - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736280828a1926125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论