如何使用 ffmpeg 指定恒定帧速率
我有一个视频流 url,它以 1 fps 到 25 fps 的速率提供视频帧(帧速率是可变的)。我的目标是将其存储为 mp4 文件,帧速率恒定为 30fps。我还期望录制视频的持续时间与执行 ffmpeg 命令的持续时间相同。
目前我使用以下命令
ffmpeg -f mjpeg -i video_stream_url \
-vf "pad= ceil(iw/2)*2:ceil(ih/2)*2",\
drawtext=text='%{localtime}':fontfile=/Windows/Fonts/Arial.ttf:fontcolor=white:fontsize=25:x=(W-tw)/2:y=h-(2*lh):box=1:boxcolor=0x00000000@1 \
-c:v copy -vcodec libx264 filename.mp4
当前观察 录制的视频时长几乎是我执行命令时长的一半。为了调试问题,我在帧上添加了时间戳。当我播放录制的文件时,视频中与源流中的低 fps 相对应的视频部分以快进模式播放,而视频的其余部分(与源中的 25 fps 相对应)正常播放。
如何在整个过程中保持 30 fps 的统一帧速率,并确保录制的视频文件持续时间与我执行命令的实际持续时间相同
I have a video stream url that gives video frame at the rate of 1fps to 25 fps (frame rate is variable). My aim is to store this as an mp4 file with a constant frame rate of 30fps. I'm also expecting that the duration of the recorded video to be same as the duration for which I execute the ffmpeg command.
At present I use the following command
ffmpeg -f mjpeg -i video_stream_url \
-vf "pad= ceil(iw/2)*2:ceil(ih/2)*2",\
drawtext=text='%{localtime}':fontfile=/Windows/Fonts/Arial.ttf:fontcolor=white:fontsize=25:x=(W-tw)/2:y=h-(2*lh):box=1:boxcolor=0x00000000@1 \
-c:v copy -vcodec libx264 filename.mp4
Present observation
The recorded video duration is almost half of the duration for which I had executed the command. To debug the problem, I have added the timestamp on the frames. When I play the recorded file, the video part of video which corresponds to low fps at source stream plays in a fast forward mode and the rest of the video (corresponding to 25 fps at source) plays normally.
How can I maintain a uniform frame rate of 30 fps throughout and ensure that recorded video file duration is same as the actual duration for which I had executed the command
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论