axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
1.97k stars 479 forks source link

mp4fragment: generating single moof/mdat for mp4 with video and audio tracks #164

Open ultravistor opened 7 years ago

ultravistor commented 7 years ago

Hello, as far as I know currently mp4fragment automatically generates two moof(/mdat) if its given an mp4 with video and audio tracks. I guess this behavior is similar to ffmpeg with -movflags frag_keyframe+separate_moof option (https://ffmpeg.org/ffmpeg-formats.html).

In my use case I would like to generate single moof with mp4fragment; is there a way to do this, or any plan to support such behavior?

Thanks

barbibulle commented 7 years ago

Do you mean mp4 fragments with moof/mdat fragments that contain both audio and video elementary streams? That is indeed not currently supported, as I wasn't able to find a good use case for this (most fragmented mp4 players actually require that fragments contain only elementary stream samples from one track). Do you have a specific use case that requires multi-track fragments?

ultravistor commented 7 years ago

@barbibulle Thanks for your reply, in my use case there's a server who receives live video chunks periodically and it passes them to mp4fragment to make m4s with correct headers. On player side, there're some custom players that work like DASH player, but not using DASH.js etc; it's using MSE but not fully compliant with DASH guidelines. (Not completely sure about HLS, but I think they support multiplexed media)

Ultimately this is not mandatory though, as a developer writing custom video server & player, I thought it would be great if there's an option to generate a single moof (not separating media), to cut some procedures and minimize number of resources clients will handle in some use cases.

(By the way, mp4fragment was the only tool that have all options we needed, thanks a lot for the great work.)

ultravistor commented 7 years ago

Side notes: as I tested, playback of multiplexed fmp4 media (audio and video are in a single moof/mdat) generated by following option seems to work fine on Chrome, Firefox and Safari

ffmpeg -i vidandaudio.mp4 -movflags frag_keyframe+empty_moov -f mp4 result.mp4

barbibulle commented 7 years ago

Ok, I'll add this to the TODO list of new features to work on.

renatosc commented 3 years ago

Just to add to @ultravistor. I use - movflags frag_keyframe+empty_moov+default_base_moof when creating my fmp4 and I noticed that when the video is H264 I end up with single track per moof/mdat, but when the video is H265/HVEC I get both video and audio tracks together in the same moof/mdat.

I wanted the opposite of @ultravistor, i.e to always have a single track per moof/mdat (regardless of the video codec), so I ended up adding the separate_moof option and it works fine!