1 year ago
#274733
Adam Szmyd
Is it possible to make VFR MP4 from a raw h264 bitstream using 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 : Baseline@L4.2
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 : Baseline@L4.2
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?
ffmpeg
mp4
h.264
rtp
bitstream
0 Answers
Your Answer