Adding trick play to a DASH or HLS stream¶
Table of Contents
Trick play, or trick mode as it is sometimes called, is a feature that gives viewers visual feedback while they are rewinding or fast-forwarding a stream. Adding this feature to your streams can be done in different ways:
- For DASH, a sync-samples only track can be added to enable trick play support
- For HLS, an I-frame Playlist is required for trick play. Such a playlist can
reference either the original video track or a sync-samples only track
- Using USP, sync-samples only tracks are supported for fMP4 HLS, but not for HLS with Transport Streams (HLS TS)
- Using a sync-samples only track can make trick play’s visual feedback more smooth, as it may offer a higher density of frames compared to an I-frame Playlist that merely references the original video track
Working with sync-samples only files is currently only supported for static packaging. In other words: adding such files to a Origin VOD workflow has no use at the moment.
You can package a CMAF compliant MP4 that contains only sync-samples with proper
mp4split with the
mp4split --trickplay -o sync-samples.cmfv \ video.cmfv
If you use a input file that contains more than one track, be sure to select the specific video track that you want to take the sync-samples from (because CMAF files can only contain a single track):
mp4split --trickplay -o sync-samples_1.cmfv \ video_1.ismv --track_type=video mp4split --trickplay -o sync-samples_2.cmfv \ video_2.mp4 --track_id=2
The output specified when using
--trickplay option should be CMAF,
.cmfv file extension.
After you have created a sync-samples only file, you can simply add that file to the other media files that should become part of your stream and, based on these files, create a MPD:
mp4split --package_mpd -o manifest.mpd video.cmfv sync-samples.cmfv audio.cmfa
The I-frame Playlists necessary for adding trick play to HLS need to be generated manually for each video track when streaming fMP4 HLS. Depending on whether or not you are working with a dedicated sync-samples only file, this process is slightly different.
Currently, trick play for fMP4 HLS is only supported for static packaging.
Without a sync-samples only file¶
Use the –create_iframe_playlist option to create an I-frame Playlist that references the original video track:
mp4split -o iframe.m3u8 --create_iframe_playlist \ --fragment_duration=6000 video.cmfv mp4split -o video.m3u8 --fragment_duration=6000 \ video.cmfv mp4split -o audio.m3u8 --fragment_duration=6000 \ audio.cmfa mp4split -o master_playlist.m3u8 \ iframe.m3u8 \ video.m3u8 \ audio.m3u8
With a sync-samples only file¶
When a file contains only sync-samples,
mp4split automatically detects this
and will create an I-frame Playlist for it, instead of a regular Media Playlist.
Using the –create_iframe_playlist option is not necessary.
mp4split -o iframe.m3u8 --fragment_duration=6000 \ sync-samples.cmfv mp4split -o video.m3u8 --fragment_duration=6000 \ video.cmfv mp4split -o audio.m3u8 --fragment_duration=6000 \ audio.cmfa mp4split -o master_playlist.m3u8 \ iframe.m3u8 \ video.m3u8 \ audio.m3u8
When using a sync-samples only file to add trick play to HLS, a common error reported by Apple’s MediaStreamValidator is the following must fix issue:
Error: Framerate change without discontinuity tag detected
This problem occurs when the source of sync-samples only file has variable GOP size (which is reflected in the sync-samples only file). To solve it, make sure that your source has a constant GOP size.
The I-frame Playlists necessary for adding trick play to HLS are automatically generated for each video track in a HLS TS stream. This is true for static as well as dynamic packaging. In the case of the latter, you must specify a client manifest version of 4 or higher in order for Origin to add the necessary I-frame Playlists, using –hls.client_manifest_version.