Clearly, AVFoundation (and Quicktime X) can demux and play properly encoded .ts
containers, because .ts
containers underly HTTPS live streaming.
You can actually create AVURLAssets directly from the underlying ts files, and play these directly, very similarly to the way you would play a mov or mp4 file.
There is some overhead for each ts file, so your best bet is to simply cat the files into one large ts file (based on your m3u8's contents), and play that large file.
There are a couple of gotcha's: AVCompositions constructed using ts file based AVAssets are memory hungry, so avoid AVCompositions apart from small files. You cannot use ts file based AVAssets in a reference movie.
This problem was annoying for us too for a long time. We have finally decided to write a tool to convert a list of ts to an mp4 file. It consists in using TSDemux to demux and concatenate videos/audios and then generate a mp4 file with GPAC.
It does really answer your question, but it may be a way to do what you want to do. This tool is on Github, feel free to try: https://github.com/Keemotion/TS2MP4