AVUrlAsset和WebVTT [英] AVUrlAsset and WebVTTs
问题描述
在iOS/TVOS上,是否可以从URL加载远程.vtt文件并将其用作字幕轨道,同时还从URL加载远程HLS视频(与在m3u8播放列表中指定的VTT相反))?
On iOS/TVOS, is it possible to load a remote .vtt file from a URL and use it as a subtitle track with a remote HLS video also loaded from a URL (as opposed to the VTT being specified within the m3u8 playlist)?
伪代码:
AVAsset* video_asset = AVAsset( "http://video.m3u8" );
AVAsset* subtitle_asset = AVAsset( "http://subtitle.vtt" );
AVPlayer player = player.playVideoWithSubtitle( video_asset, subtitle_asset );
player.play().
文档提到使用AVAsset字幕,但实际上有人举过例子吗?我只能找到有关将字符串添加为字幕而不是加载远程VTT的示例.
The docs mention using AVAsset for subtitles, but does anyone actually have an example? I can only find examples regarding adding strings as subtitles rather than loading a remote VTT.
推荐答案
我在此处发布了一个解决方案: https://stackoverflow.com/a/37945178/171933 基本上,您需要使用 AVMutableComposition
将视频与字幕一起加入,然后播放该构图.
I've posted a solution over here: https://stackoverflow.com/a/37945178/171933 Basically you need to use an AVMutableComposition
to join the video with the subtitles and then play back that composition.
这篇关于AVUrlAsset和WebVTT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!