DivX Plus MKV extension: Smooth FF/RW
Have you ever been frustrated when trying to fast-forward or rewind a video because your player becomes unresponsive and the video skips large chunks of time unpredictably making it hard to quickly find the scene you're looking for? Rewinding can be particularly infuriating using CDs or DVDs, and with downloaded video even faster media can still be problematic due to the long and irregular gaps between keyframes.
DivX Plus offers an extension to the MKV container called Smooth FF/RW that helps to solve this experience problem by including a special navigation track in your MKV file during authoring. This extension is supported by all DivX Plus devices and gives you the option to trade a small filesize overhead for a much better navigation experience. This article shows how you can try this new feature with the easy-to-use DivX Plus Converter as well as providing information and sample tools that you can use to author this feature manually or to add support in your own encoding tool chain.
See it in action
We took a regular DivX Plus HD .mkv video, added the Smooth FF/RW extension, then filmed it playing it in a DivX Plus HD device:
You can also download this file and play it in the DivX Plus Player.
Clicking the fast-forward and rewind buttons in DivX Plus Player multiple times increases the playback rate, shown in the lower-left hand corner of the video area. For files that include a Smooth FF/RW track the following behavior is typical:
|16x-32x||Smooth FF/RW track at several fps for easy viewing|
|2x-8x||Smooth FF/RW at full speed for precise navigation|
|8x||Smooth FF/RW track at full speed for precise navigation|
|16x-32x||Smooth FF/RW track at several fps for easy viewing|
When a file contains a Smooth FF/RW track DivX Plus Player can also update the picture instantly as you click and drag the scrub control at the bottom of the window.
Keep in mind that although DivX Plus Player can somewhat simulate the navigation experience on your desktop the biggest improvement can be seen when you're sitting back on the couch using a real device with a remote control in your hand. Without the Smooth FF/RW extension it is impossible to deliver this level of control with internet-based content. That's because in order to achieve such high compression modern encoders use delta frames that mostly depend on being decoded in sequence. To display a specific picture during FF/RW a player has to find the nearest past key frame, which acts as a restart point, then decode from there forward until the desired picture is reached. This is generally infeasible during fast-forward and especially so during rewind because keyframes are often irregularly spaced and can be up to several hundred frames apart.
How it works
The Smooth FF/RW extension adds a subsampled copy of the main video track to the .mkv file where the pictures are all key frames. Both the picture resolution and frame rate are substantially reduced, and the Smooth FF/RW track typically adds 10-15% to the overall file-size.
Special backwards references are also added so that players can rapidly traverse the Smooth FF/RW track in both directions.
Creating a Smooth FF/RW track manually
You can manually author a Smooth FF/RW track that will work on any DivX Plus HD device so long as you:
- Respect the video constraints of DivX Plus HD profile, and..
- Follow the additional requirements for the Smooth FF/RW track.
- Add the Smooth FF/RW track to your video using a mux supporting the correct Smooth FF/RW track extension syntax.
The next sections of this article are more technical and walk through the Smooth FF/RW track requirements, encoding such a track, and adding the encoded track to an existing .mkv file.
Smooth FF/RW track requirements
In order to guarantee playback on DivX Plus devices, observe these additional restrictions when encoding Smooth FF/RW tracks:
|Frame types||IDR only|
One of the following decimations of the main video track rate:
The rate denominator for the Smooth FF/RW track must match that of the main video track. E.g. if the main video is at 23.976 (24/1.001) fps the Smooth FF/RW track can be at 3.996 (4/1.001) fps.
|Picture timing SEI||No conveyance of telecine or interlaced modes, e.g. pic_struct = 0|
|Field types||Progressive only|
|Picture resolution||1/2 or 1/4 of main video track resolution|
|Picture width||160-960 pixels, modulus 8|
|Picture height||120-544 pixels, modulus 8|
|Sample aspect||Must match aspect of the main video track|
|NAL bitrate||Maximum 2Mbps|
|CPB size||25 Mbit|
Encoding a Smooth FF/RW track manually
Let's work through an example of encoding a Smooth FF/RW track using x264, a popular open-source H.264 encoder. Imagine we have a 1080p (1920x1080) main video track at 23.976fps encoded at around 8Mbps average, and we want to create a Smooth FF/RW track at around 1/4 resolution.
Calculate the resolution of the Smooth FF/RW track.Width = 1920 / 4 = 480 pixels
Height = 1080 / 4 = 270 pixels
Note that the height is not evenly divisible by 8. We can correct that by rounding up:270 / 8 = 33.75
Height = 34 * 8 = 272 pixels (rounding up)
Final dimensions for the Smooth FF/RW track are 480x272.
Choose a frame rate to decimate to. The main track is at 23.976fps, which is actually 24/1.001, so consulting the table above we will choose 4/1.001fps because 4 goes into 24 evenly.
Now we know our Smooth FF/RW video will be 480x272@4fps.
Choose a data rate for the Smooth FF/RW track
Typically a good choice will be around 10-15% of the average data data rate of the main video track. In this example the main video track was encoded at 8Mbps, which gives a range of:8000 * 0.10 = 800 kbps
8000 * 0.15 = 1200 kbps
For this example we'll choose 1000kbps (12.5%)
Create the Smooth FF/RW video track.
One way to create such a clip from the main video track is to use AVISynth. A suitable script might look like this:# Load the main track (you might use another source filter)
# Force the correct frame rate numerator/denominator
# Drop frames and force the new rate
# Downsample. A sharp/slow resizer is not necessary
Pass the AVISynth script to x264 for encoding:x264 --level 40 --keyint 1 --vbv-maxrate=2000 --vbv-bufsize=25000 --bitrate 1000 -o SmoothFFRWTrack.264 SmoothFFRWTrack.avs
Arguments in blue are derived from the master DivX Plus HD requirements, and arguments in green are derived from the Smooth FF/RW track requirements.
After encoding is complete we have a valid .264 elementary stream ready for muxing.
Adding the Smooth FF/RW track to an MKV file
To add a Smooth FF/RW track to an .mkv file you need to use a mux utility that understands the syntax of the extension. DivX provides a reference implementation in the DivXMKVMux sample tool. Begin by downloading and installing the DivXMKVMux package.
For easy access to DivXMKVMux launch a command console via the shortcut provided in the DivX Plus programs group on your Start menu. The console will start in the installation directory and the installation directory is automatically added to the PATH environment variable for the console session so that you can type "DivXMKVMux" from any other directory.
You can access the full list of arguments for DivXMKVMux using:
The help output is lengthy because DivXMKVMux is fairly flexible, but the required syntax is actually quite straightforward. To use DivXMKVMux to add a Smooth FF/RW track to an existing .mkv file as a post-processing simply step specify an input file with the -r argument:
You can view the output file including the Smooth FF/RW track in DivX Plus Player.
Let us know what you think
Please send us your comments and questions on this feature via the DivX Plus (.mkv) forum (requires sign-in).
This section of the article describes the technical implementation of the Smooth FF/RW track and assumes the reader is familiar with MKV EBML structure. Less technical readers may wish to skip this section.
The following diagrams illustrate how Smooth FF/RW tracks are represented in DivX Plus HD .mkv files. Note that during development this feature has been referred to as TrickTrack. For the purposes of consistency that nomenclature is retained in this technical description. At a high level:
- The Smooth FF/RW track is contained in a separate EBML structure following the EBML structure for the main video.
- Each video TrackEntry has a TrickTrackFlag indicating whether or not the track is a Smooth FF/RW track.
- In each video TrackEntry there is a cross-reference to the related SegmentUID and TrackUID in the corresponding EBML structure. Note that the EBML class IDs for these cross-references differ depending on TrickTrackFlag.
- Only when all expected elements are present and all cross-references between master and Smooth FF/RW track segment and track UIDs are succesfully resolved is a valid relationship established
Additionally, backwards references are written into BlockGroups for the Smooth FF/RW track that allow fast traversal of the Smooth FF/RW track in both directions. The illustration below shows how these references are written for the first Cluster. For files with multiple Clusters references will also exist from the first BlockGroup for the Smooth FF/RW track in each new cluster to the last BlockGroup for the Smooth FF/RW track in the previous cluster.
The EBML elements for the Smooth FF/RW extension are:
[+] Click to expand Key
|Element Name||The friendly name for the EBML ID.|
|Lvl||The level in the container hierarchy that this element appears, with Segment at level 0.|
|EBML ID||The unique EMBL ID for the element.|
|Ma||Whether or not the element is mandatory in an .mkv file if its parent element is present. This is different than whether or not the element must be present for this extension to work.|
|Mu||Whether or not the element may appear multiple times within a single instance of its parent.|
|Rng||Any restrictions of the range of values for the element payload.|
|Def||The default value for the element. Elements with default values are interpreted as present and assume their default value if their parent element is read but they are not present in the file.|
|Type||The element type. Types in this table are:
|D+||Whether or not the element is new in this DivX Plus extension.|
|Description||A description of the element.|
|Element Name||Lvl||EBML ID||Ma||Mu||Rng||Def||Type||D+||Description|
|TrickTrackUID||3||[C0]||-||-||>0||-||u||*||The TrackUID of the Smooth FF/RW video in the paired EBML structure corresponding to this video track.|
|TrickTrackSegUID||3||[C1]||-||-||-||-||b||*||The SegmentUID of the Segment containing the track identified by TrickTrackUID.|
|TrickTrackFlag||3||[C6]||-||-||0-1||0||u||*||Set to 1 if this video track is a Smooth FF/RW track. If set to 1, MasterTrackUID and MasterTrackSegUID should must be present and BlockGroups for this track must contain ReferenceFrame structures. Otherwise, TrickTrackUID and TrickTrackSegUID must be present if this track has a corresponding Smooth FF/RW track.|
|MasterTrackUID||3||[C7]||-||-||>0||-||u||*||The TrackUID of the video track in the paired EBML structure that corresponds to this Smooth FF/RW track.|
|MasterTrackSegUID||3||[C4]||-||-||-||-||b||*||The SegmentUID of the Segment containing the track identified by MasterTrackUID.|
|ReferenceFrame||3||[C8]||-||-||-||-||c||*||Contains information about the last reference frame.|
|ReferenceOffset||4||[C9]||*||-||-||-||u||*||The relative offset, in bytes, from the previous BlockGroup element for this Smooth FF/RW video track to the containing BlockGroup element.|
|ReferenceTimeCode||4||[CA]||*||-||-||-||u||*||The timecode of the BlockGroup pointed to by ReferenceOffset.|
- All of the above elements are mandatory for a valid implementation of the Smooth FF/RW extension.
- Lacing is not supported for the Smooth FF/RW video track.
- Players that do not yet support the Smooth FF/RW extensions can avoid playing the Smooth FF/RW track as a title by detecting a TrickTrackFlag element whose value is 1.