可以强制AVFoundation播放本地.ts文件吗? [英] Can AVFoundation be coerced into playing a local .ts file?

查看:226
本文介绍了可以强制AVFoundation播放本地.ts文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,AVFoundation(和Quicktime X)可以分解和播放正确编码的 .ts 容器,因为 .ts 容器支持HTTPS直播。

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

没有设置本地Web服务来提供 .m3u8 和相关的 .ts 文件,我真的希望能够:说服 AVURLAsset 和/或 URLAssetWithURL 接受本地文件 .m3u8 URI,好像它是一个HTTP URI,或者更好,能够使用 AVQueuePlayer 加载并播放一系列 .ts 个文件,而不会跳过直播流媒体。

Short of setting up a local web service to serve the .m3u8 and associated .ts files, I'd really like to be able to either: convince AVURLAsset and/or URLAssetWithURL to accept a local file .m3u8 URI as if it were an HTTP URI, or better yet, be able to use AVQueuePlayer to load and play a sequence of .ts files without jumping through the live streaming hoops.

我想要这样做的原因是我需要以一种零碎的方式在本地生成电影资产 - 整个资产不会立即可用但会生成为时光流逝。显然,这适用于 AVQueuePlayer 但由于各种原因,我的资产片段打包在 .ts 容器中。所有这些听起来都非常适合本地直播。

The reason I'm wanting to do this is that I need to locally generate movie assets on-the-fly in a somewhat piecemeal fashion - the entire asset won't be available at once but will be generated as time goes by. Obviously this lends itself to an AVQueuePlayer but for various reasons my asset fragments are packaged in .ts containers. All this sounds like it's perfect for "local" live streaming.

我怀疑 URLAssetWithURL 做了一些资格认证传递给它的字符串,然后设置一些属性来表示它正在查看一个实时流媒体源,然后告诉 AVPlayer / AVQueuePlayer 预计 .ts 表单中的曲目。它可能会看到HTTP并确定这是实时流式传输。

I suspect that URLAssetWithURL does some qualification of the string passed to it and then sets some properties to signal that it's looking at a live streaming source which in turn tell AVPlayer/AVQueuePlayer to expect tracks in .ts form. It probably sees the HTTP and decides that this is live streaming.

所以我的问题是:如何将愚弄AVFoundation变成处理本地 .m3u8 文件与远程文件完全相同?

So my question is: how would one go about "fooling" AVFoundation into handling a local .m3u8 file exactly as it does a remote one?

奖金问题是:有没有人(如果是这样的话)能够从 .ts 文件中生成 AVAsset ,以便资产返回资产轨道的状态(准备播放)?

And the bonus question is: Has anyone (and if so how) been able to make an AVAsset from a .ts file so that the asset will return the status of the asset's tracks (prepare for playback)?

TIA!

推荐答案

这个问题在很长一段时间内对我们来说都很烦人。我们最终决定编写一个工具来将ts列表转换为mp4文件。它包括使用TSDemux解复用和连接视频/音频,然后使用GPAC生成mp4文件。

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.

它确实回答了你的问题,但它可能是你做你想做的事情的一种方式。
此工具在Github上,请随时尝试: https://github.com/Keemotion/TS2MP4

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

这篇关于可以强制AVFoundation播放本地.ts文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆