【问题标题】:Adding subtitles to AirPlay video using AVFoundation on iOS?在 iOS 上使用 AVFoundation 为 AirPlay 视频添加字幕?
【发布时间】:2012-10-16 12:41:57
【问题描述】:

有没有办法在 iOS 上使用 av AVPlayer 和 anAVPlayerItem 让字幕显示在 AirPlay 上?我目前通过向视图层次结构添加标签来实现字幕,这在应用程序中运行良好,但这显然不适用于 AirPlay。

那么,有什么方法可以使用AVFoundation 在 AirPlay 上显示字幕?

【问题讨论】:

    标签: ios avfoundation avplayer


    【解决方案1】:

    您提到您已经通过创建 CC 视图并将其添加到视频顶部来实现自己的 CC。使用 AirPlay 镜像会更容易。您可以通过检测外部屏幕然后在其上放置内容来做到这一点。

    // detecting an external screen
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myExternalScreenDetected:) name:UIScreenDidConnectNotification object:nil];
    
    //
    // Grab external screen then add the content
    - (void)myExternalScreenDetected:(UIScreen *)externalScreen {
        UIWindow *window = [[UIWindow alloc] initWithFrame:externalScreen.bounds];
    
        // ...add content to the window...
    
        window.screen = externalScreen;
        window.hidden = NO;
    }
    

    另一种选择是使用原生隐藏式字幕。这可以通过将语言文件(WebVTT 格式)添加到 m3u8 播放列表中来完成。我没试过这个。似乎更复杂。您可以在这里观看 Apple 的视频:https://developer.apple.com/videos/wwdc/2012/?id=512

    镜像功能似乎比原生方式更容易实现 CC。然而,原生视频播放具有更好的性能,因为 AppleTV 会加载播放列表文件 (m3u8) 并直接播放内容。镜像 AirPlay 必须重新压缩输出并发送到 AppleTV。

    【讨论】:

    • 镜像性能很差,视频会退化为幻灯片。
    • 还不错。 Hulu Plus 使用镜像。不是最好的,但还可以。
    【解决方案2】:

    您可能已经知道这一点,但是当您在 Apple TV 上播放时隐藏字幕未显示的原因可能是您的 AppleTV 已关闭隐藏字幕。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多