Search code examples
videovideo-streamingmp4vlctranscoding

MP4 MOOV atom for progressive playing


I'm looking a way to create a MOOV atom that would allow an user to reproduce an MP4 file while it is still transcoding (for example the transcoding of an endless stream like a the one from a security camera)

I think that the only way I could do that is to have each chunk and sample have exactly the same size so I can declare in advance its format in the st* tables. The problem is that I'm not able to transcode a mp4 with this characteristics using vlc (I don't know if that is even possible) and therefore I can't test if such approach would work.

Is there a way to transcode a file so its frames and chunks have the same size? And if that is possible do you think I could create a MOOV atom that would allow to start the reproduction while the file is still transcoding?


Solution

  • What you are looking for is to generate a fragmented MP4. I only know how to do that with ffmpeg, but its probably doable with VLC. You don't need to have same size chunks, but you will have same size segments with moof following mdat boxes.

    As an example, using x264 You can use this command line with ffmpeg: ffmpeg -i input -c:v libx264 -preset medium -f mp4 -movflags empty_moov+omit_tfhd_offset+frag_keyframe -frag_duration 1000000 output.mp4