acotilla91 / ACHLSCaptioningServer

Utility for dynamically adding VTT subtitles to HLS on iOS/tvOS apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ACHLSCaptioningServer

License Platform Language

ACHLSCaptioningServer is an easy-to-use utility for dynamically adding VTT subtitles to HLS (m3u8) streams that do not have subtitles embedded already. This class generates a new HLS file and upload that file to a local server using GCDWebServer. The generated file URL can be passed to an AVPlayerViewController object.

Last tested on Xcode 7.3, iOS 9.3.2, tvOS 9.2.1

Installation and Setup

Manual

  1. Add ACHLSCaptioningServer folder to your project.
  2. In the project editor, select your target, click Build Phases and then under Link Binary With Libraries add libz.tbd and libxml2.tbd libraries to your target. (This is needed for GCDWebServer)

Usage

NSURL *origStreamURL = your-original-stream-url
NSURL *vttFileURL = your-vtt-file-url

NSURL *streamURL = [[ACHLSCaptioningServer sharedInstance] getCaptionedHLSStreamFromStream:origStreamURL vttURL:vttFileURL];

AVURLAsset *videoAsset = [[AVURLAsset alloc] initWithURL:streamURL options:nil];

AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:videoAsset];

AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];

AVPlayerViewController *avPlayerController = [[AVPlayerViewController alloc] initWithNibName:nil bundle:nil];
[avPlayerController setPlayer:player];
[avPlayerController.view setFrame:self.view.frame];
[self addChildViewController:avPlayerController];
[self.view addSubview:avPlayerController.view];
[avPlayerController didMoveToParentViewController:self];

Licensing

This project is licensed under the terms of the MIT license.

About

Utility for dynamically adding VTT subtitles to HLS on iOS/tvOS apps.

License:Other


Languages

Language:Objective-C 100.0%