[FFmpeg-user] Fragmented MP4 with non-fixed frame rate

Gal Bar Mashiah galbarm at gmail.com
Wed Oct 7 16:29:38 CEST 2015


I'm creating a fragmented MP4 for the use of playing in Media Source
Extensions.
The command line is: ffmpeg.exe -probesize 10000000 -r 10 -i - -vcodec copy
-an -f mp4 -reset_timestamps 0 -blocksize 30000 -movflags
empty_moov+default_base_moof+frag_keyframe -loglevel debug -

The source of the video is an IP camera streaming H.264
The configured and expected frame rate is 10FPS but there is no guarantee
for 10FPS, for example a frame may get dropped occasionally, or the camera
may just not play nice with what it declares.
I have simulate a 10% p-frames drops to emphasize the following issue:

With the above command, the output video plays faster than real-time and
this is a problem because the whole pipe is a live stream.
With the 10% frame drop simulation, the effective playback rate it 1.1x.
I don't want to obligate to a fixed frame rate because there is no
guarantee for a fixed-rate.
If I remove the -r 10 flag entirely, the MP4 seems to the playing at 2x-3x
speed.

Is there a way building the MP4 timestamps in a more dynamic way? for
example, giving it the RTP timestamp or somehow telling ffmpeg to build the
MP4 with the timestamp of the "feed" time?


Full log:

2015-10-07T14:11:29.821Z : FFmpeg text stream 1 : ffmpeg version
N-72981-gdc87758 Copyright (c) 2000-2015 the FFmpeg developers
2015-10-07T14:11:29.821Z : FFmpeg text stream 1 :   built with gcc 4.9.2
(GCC)
2015-10-07T14:11:29.822Z : FFmpeg text stream 1 :   configuration:
--enable-gpl --enable-version3 --disable-w32threads --enable-avisynth
--enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls
--enable-iconv --enable-libass --enable-libbluray --enable-libbs2b
--enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme
--enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
--enable-lzma --enable-decklink --enable-zlib
2015-10-07T14:11:29.823Z : FFmpeg text stream 1 :   libavutil      54.
27.100 / 54. 27.100
2015-10-07T14:11:29.823Z : FFmpeg text stream 1 :   libavcodec     56.
41.100 / 56. 41.100
2015-10-07T14:11:29.823Z : FFmpeg text stream 1 :   libavformat    56.
36.100 / 56. 36.100
2015-10-07T14:11:29.823Z : FFmpeg text stream 1 :   libavdevice    56.
 4.100 / 56.  4.100
2015-10-07T14:11:29.823Z : FFmpeg text stream 1 :   libavfilter     5.
17.100 /  5. 17.100
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 :   libswscale      3.
 1.101 /  3.  1.101
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 :   libswresample   1.
 2.100 /  1.  2.100
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 :   libpostproc    53.
 3.100 / 53.  3.100
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 : Splitting the commandline.
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 : Reading option
'-probesize' ... matched as AVOption 'probesize' with argument '10000000'.
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 : Reading option '-r' ...
matched as option 'r' (set frame rate (Hz value, fraction or abbreviation))
with argument '10'.
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 : Reading option '-i' ...
matched as input file with argument '-'.
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 : Reading option '-vcodec'
... matched as option 'vcodec' (force video codec ('copy' to copy stream))
with argument 'copy'.
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 : Reading option '-an' ...
matched as option 'an' (disable audio) with argument '1'.
2015-10-07T14:11:29.824Z : FFmpeg text stream 1 : Reading option '-f' ...
matched as option 'f' (force format) with argument 'mp4'.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Reading option
'-reset_timestamps' ... matched as AVOption 'reset_timestamps' with
argument '0'.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Reading option
'-blocksize' ... matched as AVOption 'blocksize' with argument '30000'.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Reading option
'-movflags' ... matched as AVOption 'movflags' with argument
'empty_moov+default_base_moof+frag_keyframe'.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Reading option
'-loglevel' ... matched as option 'loglevel' (set logging level) with
argument 'debug'.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Reading option 'tcp://
127.0.0.1:10000' ... matched as output file.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Finished splitting the
commandline.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Parsing a group of
options: global .
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Applying option loglevel
(set logging level) with argument debug.
2015-10-07T14:11:29.825Z : FFmpeg text stream 1 : Successfully parsed a
group of options.
2015-10-07T14:11:29.826Z : FFmpeg text stream 1 : Parsing a group of
options: input file -.
2015-10-07T14:11:29.826Z : FFmpeg text stream 1 : Applying option r (set
frame rate (Hz value, fraction or abbreviation)) with argument 10.
2015-10-07T14:11:29.826Z : FFmpeg text stream 1 : Successfully parsed a
group of options.
2015-10-07T14:11:29.826Z : FFmpeg text stream 1 : Opening an input file: -.
2015-10-07T14:11:30.666Z : FFmpeg text stream 1 : [h264 @ 0000000004767460]
Format h264 probed with size=2048 and score=51
2015-10-07T14:11:30.666Z : FFmpeg text stream 1 : [h264 @ 0000000004767460]
Before avformat_find_stream_info() pos: 0 bytes read:32816 seeks:0
2015-10-07T14:11:31.153Z : FFmpeg text stream 1 : [h264 @ 0000000004778da0]
Frame num gap 4 2
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 : [h264 @ 0000000004767460]
max_analyze_duration 5000000 reached at 5000000 microseconds
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 : [h264 @ 0000000004767460]
After avformat_find_stream_info() pos: 7784180 bytes read:7815924 seeks:0
frames:152
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 : Input #0, h264, from
'pipe:':
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 :   Duration: N/A, bitrate:
N/A
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 :     Stream #0:0, 152,
1/1200000: Video: h264 (Main), 2 reference frames, yuv420p(tv, bt709,
left), 1280x720 [SAR 1:1 DAR 16:9], 1/60, 30 fps, 30 tbr, 1200k tbn, 60 tbc
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 : Successfully opened the
file.
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 : Parsing a group of
options: output file tcp://127.0.0.1:10000.
2015-10-07T14:11:47.750Z : FFmpeg text stream 1 : Applying option vcodec
(force video codec ('copy' to copy stream)) with argument copy.
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 : Applying option an
(disable audio) with argument 1.
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 : Applying option f (force
format) with argument mp4.
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 : Successfully parsed a
group of options.
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 : Opening an output file:
tcp://127.0.0.1:10000.
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 : Successfully opened the
file.
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 : [mp4 @ 0000000004f0b4c0]
Codec for stream 0 does not use global headers but container format
requires global headers
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 : Output #0, mp4, to 'tcp://
127.0.0.1:10000':
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 :   Metadata:
2015-10-07T14:11:47.751Z : FFmpeg text stream 1 :     encoder         :
Lavf56.36.100
2015-10-07T14:11:47.752Z : FFmpeg text stream 1 :     Stream #0:0, 0,
1/10240: Video: h264, 1 reference frame ([33][0][0][0] / 0x0021),
yuv420p(left), 1280x720 (0x0) [SAR 1:1 DAR 16:9], 1/10, q=2-31, 30 fps, 30
tbr, 10240 tbn, 10 tbc
2015-10-07T14:11:47.752Z : FFmpeg text stream 1 : Stream mapping:
2015-10-07T14:11:47.752Z : FFmpeg text stream 1 :   Stream #0:0 -> #0:0
(copy)
-- 
Gal Bar Mashiah.


More information about the ffmpeg-user mailing list