First of which is that it is open source, and second is it can perform any and every streaming operation you may want to execute. The above manifest have 7 variants. Take for instance we need to download a local copy of the x variant in an. To do so, first ensure you have a local installation of ffmpeg:. Verify FFmpeg installation by running the "ffmpeg" command directly from your terminal.
If installation is successful, you should see something similar to this:. Let me explain what those flags do: "-i" specifies the input file which can be a stream url or any media file. Running the above command will generate chunks of TS segments of about 3 seconds duration each within the current working directory. To combine the generated. That will generate a playlist. Mobile App Development. Programming Languages. Get insights on scaling, management, and product development for founders and engineering managers.
Read programming tutorials, share your knowledge, and become better developers together. Hot Topics. Chukwukadibia Durugo Follow. Published Mar 30, The mediafilesegmenter command-line tool takes an encoded media file as an input, wraps it in an MPEG-2 transport stream, and produces a series of equal-length files from it, suitable for use in HTTP Live Streaming.
The media file segmenter can also produce index files playlists and decryption keys. The file segmenter behaves very much like the stream segmenter, but it works on existing files instead of streams coming from an encoder.
For details, type man mediafilesegmenter from the terminal window. The mediastreamvalidator command-line tool examines the index files, stream alternates, and media segment files on a server and tests to determine whether they will work with HTTP Live Streaming clients.
For details, type man mediastreamvalidator from the terminal window. The variantplaylistcreator command-line tool creates a master index file, or playlist, listing the index files for alternate streams at different bit rates, using the output of the mediafilesegmenter. The mediafilesegmenter must be invoked with the -generate-variant-playlist argument to produce the required output for the variant playlist creator.
For details, type man variantplaylistcreator from the terminal window. The id3taggenerator command-line tool generates ID3 metadata tags. These tags can either be written to a file or inserted into outgoing stream segments. For details, see Adding Timed Metadata. For VOD sessions, media files are available representing the entire duration of the presentation.
The index file is static and contains a complete list of all files created since the beginning of the presentation. This kind of session allows the client full access to the entire program. HTTP Live Streaming offers advantages over progressive download for VOD, such as support for media encryption and dynamic switching between streams of different data rates in response to changing connection speeds.
QuickTime also supports multiple-data-rate movies using progressive download, but QuickTime movies do not support dynamically switching between data rates in mid-movie. Live sessions events can be presented as a complete record of an event, or as a sliding window with a limited time range the user can seek within. For live sessions, as new media files are created and made available, the index file is updated. The new index file lists the new media files.
Older media files can be removed from the index and discarded, presenting a moving window into a continuous stream—this type of session is suitable for continuous broadcasts. Alternatively, the index can simply add new media files to the existing list—this type of session can be easily converted to VOD after the event completes.
It is possible to create a live broadcast of an event that is instantly available for video on demand. This allows clients to join the broadcast late and still see the entire event. It also allows an event to be archived for rebroadcast with no additional time or effort. Media files containing stream segments may be individually encrypted.
When encryption is employed, references to the corresponding key files appear in the index file so that the client can retrieve the keys for decryption.
When a key file is listed in the index file, the key file contains a cipher key that must be used to decrypt subsequent media files listed in the index file. The format of the key file is a packed array of these 16 octets in binary format. The media stream segmenter available from Apple provides encryption and supports three modes for configuring encryption.
The first mode allows you to specify a path to an existing key file on disk. In this mode the segmenter inserts the URL of the existing key file in the index file. It encrypts all media files using this key. The second mode instructs the segmenter to generate a random key file, save it in a specified location, and reference it in the index file. All media files are encrypted using this randomly generated key.
The third mode instructs the segmenter to generate a new random key file every n media segments, save it in a specified location, and reference it in the index file.
This mode is referred to as key rotation. Each group of n files is encrypted using a different key. You may also choose to protect the delivery of the key files using your own session-based authentication scheme.
Key files require an initialization vector IV to decode encrypted media. The IVs can be changed periodically, just as the keys can. HTTPS is commonly used to deliver key files. It may also be used to deliver the media segment files and index files, but this is not recommended when scalability is important, since HTTPS requests often bypass web server caches, causing all content requests to be routed through your server and defeating the purpose of edge network distribution systems.
For this very reason, however, it is important to make sure that any content delivery network you use understands that the. M3U8 index files are not to be cached for longer than one media segment duration for live broadcasts, where the index file is changing dynamically.
A master index file may reference alternate streams of content. References can be used to support delivery of multiple streams of the same content with varying quality levels for different bandwidths or devices.
HTTP Live Streaming supports switching between streams dynamically if the available bandwidth changes. The client software uses heuristics to determine appropriate times to switch between the alternates. Currently, these heuristics are based on recent trends in measured network throughput. The master index file points to alternate streams of media by including a specially tagged list of other index files, as illustrated in Figure Both the master index file and the alternate index files are in.
M3U8 playlist format. The master index file is downloaded only once, but for live broadcasts the alternate index files are reloaded periodically. The first alternate listed in the master index file is the first stream used—after that, the client chooses among the alternates by available bandwidth. Note that the client may choose to change to an alternate stream at any time, such as when a mobile device enters or leaves a WiFi hotspot. All alternates should use identical audio to allow smooth transitions among streams.
You can create a set of stream alternates by using the variantplaylistcreator tool and specifying the -generate-variant-playlist option for either the mediafilesegmenter tool or the mediastreamsegmenter tool see Download the Tools for details. The first entry in the variant playlist is played when a user joins the stream and is used as part of a test to determine which stream is most appropriate. The order of the other entries is irrelevant. Where possible, encode enough variants to provide the best quality stream across a wide range of connection speeds.
For example, encode variants at kbps, kbps, kbps, kbps, kbps. When possible, use relative path names in variant playlists and in the individual. M3U8 playlist files. The video aspect ratio on alternate streams must be exactly the same, but alternates can have different pixel dimensions, as long as they have the same aspect ratio. For example, two stream alternates with the same aspect ratio could have dimensions of x and x To ensure the user has a good experience when the stream is first played, regardless of the initial network connection, you should have more than one master index file consisting of the same alternate index files but with a different first stream.
HTTP Live Streaming allows the client to choose among stream alternates dynamically as the network bandwidth changes, providing the best stream as the device moves between cellular and WiFi connections, for example, or between 3G and EDGE connections. This is a significant advantage over progressive download. It is strongly recommended that you use HTTP Live Streaming to deliver video to all cellular-capable devices, even for video on demand, so that your viewers have the best experience possible under changing conditions.
In addition, you should provide cellular-capable clients an alternate stream at 64 Kbps or less for slower data connections.
If you cannot provide video of acceptable quality at 64 Kbps or lower, you should provide an audio-only stream, or audio with a still image. A good choice for pixel dimensions when targeting cellular network connections is x for content and x for content see Preparing Media for Delivery to iOS-Based Devices. If your app delivers video over cellular networks, and the video exceeds either 10 minutes duration or 5 MB of data in a five minute period, you are required to use HTTP Live Streaming.
0コメント