是否可以使用 ffmpeg 从原始 h264 比特流制作 VFR MP4?
我有一个原始的 h264 比特流,我想使用 ffmpeg 将其放入 MP4 中,但 ffmpeg 总是以恒定的帧速率生成它,而我需要它是可变的帧速率。
假设我有一个具有可变帧速率的 MP4(从 MediaInfo 输出):
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 17 min 38 s
Bit rate : 233 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 27.879 FPS
Minimum frame rate : 2.545 FPS
Maximum frame rate : 43.478 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.004
Stream size : 29.4 MiB (99%)
Codec configuration box : avcC
我从中提取 H264:
ffmpeg -i input.mp4 -vcodec copy -an -bsf:v h264_mp4toannexb input.h264
``
Just to make it Mp4 once again:
ffmpeg -i input.h264 -c copy output.mp4 ``
output.mp4 现在是一个恒定的帧速率:
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 19 min 40 s
Bit rate : 209 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.004
Stream size : 29.4 MiB (100%)
Codec configuration box : avcC
我的问题是:是否可以以某种方式强制 ffmpeg 使其可变,就像源文件一样?
我正在尝试使用 ffmpeg 的 vsync
选项,但没有运气。
我想我知道问题出在哪里 - 计时信息应该在 h264 比特流之外处理(即通过 RTP 时间戳),并且可以说我确实有这些时间戳(我的应用程序使用 RTP,这就是我获取 h264 比特流的方式) -在创建此 mp4 时,如何在这样的流程中使用这些时间戳将它们传递给 ffmpeg?
I have a raw h264 bitstream that I'd like to put into MP4 using ffmpeg but ffmpeg always produces it with a constant frame rate and I need it to be the variable frame rate.
So lets say I have an MP4 with variable frame rate (output from MediaInfo):
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 17 min 38 s
Bit rate : 233 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Frame rate : 27.879 FPS
Minimum frame rate : 2.545 FPS
Maximum frame rate : 43.478 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.004
Stream size : 29.4 MiB (99%)
Codec configuration box : avcC
and I extract H264 out of it:
ffmpeg -i input.mp4 -vcodec copy -an -bsf:v h264_mp4toannexb input.h264
``
Just to make it Mp4 once again:
ffmpeg -i input.h264 -c copy output.mp4
``
output.mp4 is now a constant frame rate:
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings : 1 Ref Frames
Format settings, CABAC : No
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 19 min 40 s
Bit rate : 209 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.004
Stream size : 29.4 MiB (100%)
Codec configuration box : avcC
My question is: Is it possible to force ffmpeg somehow to make it variable, the same way the source file was?
I was experimenting with ffmpeg's vsync
options but with no luck.
I think I know where the problem is in general - timing information should be handled outside of h264 bitstream (i.e. via RTP Timestamps) and lets say I do have these timestamp (my app uses RTP and this is how I get the h264 bitstream) - how I can use these timestamps in such a flow to pass them to ffmpeg when creating this mp4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论