Can AVFoundation be coerced into playing a local .ts file?

前端 未结 2 1974
后悔当初
后悔当初 2021-02-02 01:58

Clearly, AVFoundation (and Quicktime X) can demux and play properly encoded .ts containers, because .ts containers underly HTTPS live streaming.

<
相关标签:
2条回答
  • 2021-02-02 02:20

    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.

    0 讨论(0)
  • 2021-02-02 02:27

    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

    0 讨论(0)
提交回复
热议问题