Bento4 icon indicating copy to clipboard operation
Bento4 copied to clipboard

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

Open ultravistor opened this issue 8 years ago • 5 comments

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

ultravistor avatar Jul 20 '17 05:07 ultravistor

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?

barbibulle avatar Jul 21 '17 06:07 barbibulle

@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 avatar Jul 21 '17 08:07 ultravistor

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

ultravistor avatar Jul 21 '17 10:07 ultravistor

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

barbibulle avatar Jul 28 '17 05:07 barbibulle

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!

renatosc avatar Sep 13 '21 19:09 renatosc