YouTube Ingest by Hand (Part 6)

YouTube Ingest by Hand (Part 6)

Google just replied to (and closed) my ticket regarding MPEG-DASH. Apparently they cannot provide any examples of their ingest actually working. "Go ask StackOverflow." Very cringe.

Anyway ... on to HLS now.


Question 1: Can I use AVAssetWriter to write the MPEG-TS stream? The answer seems to be "no".

So, how difficult is it to "hand roll" an M2TS file?

https://developer.apple.com/forums/thread/714694


YES!

The "secret sauce" ended up being the audio track, which was definitely required. Manually merging the MDATs and TRUNs from the two media segments was a pain in the ass. Once I actually got all of the various data offset adjusted correctly, it started working.

There's a million loose ends to tie up still, but the proof-of-concept is in the bag.

This leaves me wondering if I can ditch AVAssetWriter entirely for this use case with just a little more hassle. Is the MDAT atom just the concatenation of the encoded samples?

Another day.

A huge help in this process was ffprobe. mp4dump is nice for seeing the atom structure, but ffprobe alerted me to errors in the media data (resulting from bad data offsets in the trun.

ffprobe -i movie.mp4 -analyzeduration 2147483647 -probesize 2147483647 -flags +global_header -show_streams -show_format -print_format json

The end (sort of).

Subscribe to A garage sale for your mind

Don’t miss out on the latest posts. Sign up now to get access to the library of members-only posts.
[email protected]
Subscribe