[FFmpeg-user] convertion from h264 to mp4 for MSE

Grzegorz Wolny g.wolny at samsung.com
Fri Dec 22 10:29:08 EET 2017


Hello,

I'm having problem with conversion from h264 to mp4.
I would like to pack h264 stream into mp4 container. The stream in mp4 
format is going to be played in chrome browser with html5 video and MSE.

I'm trying to do this with following command:

ffmpeg -f h264 -i 720p.h264 -c:v copy -an -movflags 
frag_keyframe+empty_moov+default_base_moof -f  mp4  720p.mp4

but the output stream is not correctly played by chrome. It looks like 
there is problem with 'timescale' and 'default sample flags'. Boxes mvhd 
and mdhd contains different timescale. Box tfhd contains default sample 
flags = 1010000.

Here is log from stdout of the ffmpeg:

$ ffmpeg -f h264 -i 720p.h264 -c:v copy -an -movflags 
frag_keyframe+empty_moov+default_base_moof -f  mp4  720p.mp4
ffmpeg version N-89551-gbc10260 Copyright (c) 2000-2017 the FFmpeg 
developers
   built with gcc 4.9.4 (Ubuntu 4.9.4-2ubuntu1~14.04.1)
   configuration:
   libavutil      56.  6.100 / 56.  6.100
   libavcodec     58.  8.100 / 58.  8.100
   libavformat    58.  3.100 / 58.  3.100
   libavdevice    58.  0.100 / 58.  0.100
   libavfilter     7.  7.100 /  7.  7.100
   libswscale      5.  0.101 /  5.  0.101
   libswresample   3.  0.101 /  3.  0.101
Input #0, h264, from '720p.h264':
   Duration: N/A, bitrate: N/A
     Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 
[SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1200k tbn, 60 tbc
File '720p.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to '720p.mp4':
   Metadata:
     encoder         : Lavf58.3.100
     Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), 
yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 30 
tbr, 1200k tbn, 1200k tbc
Stream mapping:
   Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x20ae880] Timestamps are unset in a packet for stream 0. This is 
deprecated and will stop working in the future. Fix your code to set the 
timestamps properly
[mp4 @ 0x20ae880] pts has no value
     Last message repeated 1251 times
frame= 1252 fps=0.0 q=-1.0 Lsize=    6304kB time=00:00:41.63 
bitrate=1240.3kbits/s speed=1.25e+03x
video:6293kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 0.184422%


I would like to notice that the same h264 stream has been successfully 
converted to mp4 by mp4box command:
MP4Box -add 720p.h264 -dash -1 -frag 5000 test-out.mp4.

Could you give me any clue how to do the same with ffmpeg?

Best regards,
Grzegorz Wolny



More information about the ffmpeg-user mailing list