This post is also available in: Russian
In our era of ubiquitous globalization and internationalization, most of Web projects are launched in multiple languages. This especially applies to online video projects. Videos with alternate audio tracks and subtitles often attract viewers by the very fact of their existence. Most of popular content is created outside Russia, so there is abundance of content with original audio tracks and subtitles. Such content allows you to enjoy video in the original quality and detail, and learn foreign languages. In this post, we will tell you how to implement this functionality in Flash video player using OSMF 1.6.
Quite recently, Adobe announced OSMF 01.06, a new OSMF release enhanced with alternate audio track support. Frankly speaking, audio track substitution on the client side, even at the ActionScript level, raises many questions and probably even some disappointment. However, this is a very effective and easy way to support multiple audio tracks in video content. Previously, for each audio track we had to store a separate video file. This led to a substantial increase in data storage costs. The situation became times more complex if you needed to support dynamic bitrate.
To support alternate audio tracks in your video project, you have to follow a few simple steps:
1) Prepare your video content (with a single audio track) and, separately, your alternate audio tracks
2) Prepare content metadata (f4m v2 manifest)
3) Revise your video player to support audio track switching.
Video content must be prepared for HTTP Dynamic Streaming (commonly, this is done by the f4fpackager utility). During this, a common multi-bitrate manifest file is generated. After that, edit the manifest to enter data on alternate audio tracks. For this purpose, add the following attributes to the <media> tags of your audio tracks:
- alternate = “true”
- type = “audio”
- lang = “English” (example)
- bitrate = “” (always empty, as dynamic bitrate is not supported for audio)
After this, you just have to change the manifest version:
Then, you have to publish all files generated during content preparation, to a Web server: f4v — your main video with the main audio track, f4v — alternate audio tracks, f4m — the manifest file. To prepare content in our projects, we prefer Rhozet software transcoders as they have convenient automation tools. This, however, does not prevent anyone from using lower-budget implementations. To support HTTP Dynamic Streaming, we used an Apache plugin developed by Adobe. Still, you can use the specs to make an f4v plugin for any other Web server.
Implementation of alternate audio tracks in the video player is pretty trivial and is well-documented. The video player takes details of alternate tracks from the manifest file that is loaded before the video content. The sound is switched by index, but still you can fetch the “lang” attribute for each track. So, when the user selects an audio track index, the basic sound of the container is turned off, and the needed audio fragments are loaded in parallel with video fragments. OSMF replaces the main audio track with the resulting separate audio track (that’s why dynamic bitrate is not supported). When you switch to default audio, additional fragments are no longer loaded, and the container audio is turned on.
When you implement content playback with alternate audio tracks, it is very important to encrypt all the content (main video and alternate audio) with a single key, as the player cannot request separate licenses for audio streams.