DivX Plus HD H.264 Encoder (Beta 2)


What's new in Beta 2
  • Target Quality Mode

    One of the problems faced in video compression is determining at which data rate we need to encode a given piece of content to achieve a particular output quality. Certain sources are likely to require higher bitrates than others, e.g. a fast-action film versus a CGI animation, and experimental encoding can be time consuming, exacerbated by the fact that the rate-control can be misguided with less than 2 passes. A target quality mode can help solve this problem.

    As an alternative to the 1-pass (-br) and n-pass (-br -npass) bitrate-based modes that we described in our last tutorial you can now enable a preliminary implementation of quality-based rate-control whose goal is to provide a consistent perceived output quality across a wide variety of input material without exceeding data rate constraints for playback devices. By using the new -qf <int> argument you can specify a target quality in the range 0-51, with lower numbers implying a higher target quality, e.g.:

    DivX264 -i "Input.avs" -o "Output.264" -qf 18

    This target quality mode is useful when you want to target a certain output quality from a single encoding pass and you are willing to let the encoder determine the necessary data rate instead of targeting a particular output file size. All other variables held constant, higher quality settings (lower -qf <int> values) will produce larger files and you will need to experiment a little to find the setting that best balances your personal preferences. The target quality mode can be leveraged for compression checks by GUI applications and should produce similar quality to a 2-pass encoding at the same effective rate but in much less time.


  • Sample Aspect Ratio

    Sample aspect ratio (also known as "pixel aspect ratio" in the DivX 6 encoder) is a method of informing the renderer that the pixels in each decoded picture buffer actually represent a sample of the original video whose shape was not necessarily square - i.e. that the renderer may need to rescale the decoded picture to be taller or wider before displaying it. The technique allows devices with constrained buffer shapes to handle pictures that are wider or taller than they would otherwise support. Examples include certain HD cameras as well as common formats such as DVD, where SAR is often used in conjunction with letterboxing or pillarboxing to ensure that videos with a variety of frame shape can be stored in high quality in a fixed-shape frame buffer.

    You can now specify the sample aspect ratio (SAR) of the input video using the -sar argument. In its alpha release the encoder always assumed that pixels were square (1:1 SAR) and thus it was necessary to resize certain source material to ensure this was actually true. Because these adjustments are no longer necessary it's possible to achieve better picture resolution and less pre-processing time in the input pipeline. These pictures demonstrate just one common use case for SAR:



    Widescreen picture formatted for PAL 720x576 16:9 DAR DVD, as encoded.
    (Click to enlarge and read more)



    The same picture after the renderer applies 16:11 SAR during playback.
    (Click to enlarge)


    If your input video does not have 1:1 SAR you need to specify the ratio of width to height of each sample that the renderer should display during playback. Note that the display aspect and sample aspect are two related but different properties. Some frequently encountered sample aspects are shown below:

    SD Format SAR
    PAL 4:3 12:11
    PAL 16:9 16:11
    NTSC 4:3 10:11
    NTSC 16:9 40:33


    The DivX Plus HD profile implements stricter rules for interlaced content to ensure robust playback on a wide variety of devices. When encoding interlaced material using the -tff or -bff arguments only the following combinations of resolution and SAR are permitted:
    Interlaced resolution Support SARs
    1920x1080i60 1:1 (16:9 frame)
    1920x1080i50 1:1 (16:9 frame)
    1440x1080i60 1:1 (4:3 frame), 4:3 (16:9 frame)
    1440x1080i50 1:1 (4:3 frame), 4:3 (16:9 frame)
    720x480i60 1:1, 40:33 (16:9 frame), 10:11 (4:3 frame)
    720x576i50 1:1, 16:11 (16:9 frame), 12:11 (4:3 frame)
    704x480i60 1:1, 40:33 (16:9 frame), 10:11 (4:3 frame)
    704x576i50 1:1, 16:11 (16:9 frame), 12:11 (4:3 frame)
    640x480i60 1:1 (4:3 frame)
    480x480i60 1:1, 20:11 (16:9 frame), 15:11 (4:3 frame)
    480x576i50 1:1, 24:11 (16:9 frame), 18:11 (4:3 frame)
    352x480i60 1:1, 80:33 (16:9 frame), 20:11 (4:3 frame)
    352x576i50 1:1, 32:11 (16:9 frame), 24:11 (4:3 frame)


  • Stdin support

    The encoder now accepts raw video input via stdin, which makes it both easier to develop around the encoder and to use a wider variety of tools in the input pipeline for encoding DivX Plus HD content. In our tutorial for the alpha version of the encoder we showed how to use AVISynth to read a source file in an arbitrary format, decode it, and perform some basic manipulations like resizing to a supported resolution and frame rate. These same operations can now be performed using other common video processing toolkits. Let's look at a typical example using FFmpeg.

    FFmpeg's documentation can appear a little daunting at first due to it's extensive functionality, but really it's not much more complex than the command line tools we've already encountered. The command line documentation tells us that the basic syntax looks like this:

    ffmpeg [[infile options][`-i' infile]]... {[outfile options] outfile}...

    We'll use a handful of the available options to input an AVI file, crop and resize it to a supported resolution, and output raw video at a valid frame rate ready to pipe into the DivX Plus HD encoder. Let's assume our input video is 1920x1088 @ 30fps progressive and we want to encode at 720p @ 23.976fps. We can tell FFmpeg to decode our AVI file using -i, crop 8 pixels from the height using -cropbottom, resize to 1280x720 using -s, and convert the frame rate using -r. The first part of the command line might look as follows:

    ffmpeg.exe -i "C:\SomeFolder\MyInput.avi" -cropbottom 8 -s 1280x720 -r 24000/1001

    We also need to use -f and -pix_fmt to tell FFmpeg that we want to output YV12 planar video (the raw format that the DivX Plus HD encoder expects via stdin), and to write those raw frames to stdout, which we will later pipe to the encoder's stdin. To do that we just put a "-" character where we'd normally write the output filename. This makes our complete command-line for FFmpeg look like this:

    ffmpeg.exe -i "C:\SomeFolder\MyInput.avi" -cropbottom 8 -s 1280x720 -r 24000/1001 -f rawvideo -pix_fmt yuv420p -

    Next we ask the DivX Plus HD encoder to read input via the stdin, again using the "-" character where we'd normally write a file name. Because the only data the encoder will see is raw video frames we also have to tell it the resolution and frame rate of the input video on the command line when using the stdin feature. Let's use the new target quality mode (-qf) in conjunction with the stdin feature to create a high quality file in just one pass:

    divx264.exe -i - -y 1280x720 -fps 24000/1001 -qf 18 -o "C:\SomeFolder\MyOutput.264"

    Neither of these commands will work on their own. We must combine them using the pipe character, "|" to pipe FFmpeg's stdout handle to the DivX Plus HD encoder's stdin handle:

    ffmpeg.exe -i "C:\SomeFolder\MyInput.avi" -cropbottom 8 -s 1280x720 -r 24000/1001 -f rawvideo -pix_fmt yuv420p - | divx264.exe -i - -y 1280x720 -fps 24000/1001 -qf 18 -o "C:\SomeFolder\MyOutput.264"

    When we execute this command FFmpeg will decode and transform the input video, and the DivX Plus HD encoder will output an H.264 video stream, all without creating any intermediary files. All that remains is to mux the video stream into an MKV container:

    MKVMerge.exe -o "C:\SomeFolder\MyMKVVideo.mkv" --default-duration 0:1001/24000s "C:\SomeFolder\MyOutput.264"



    Encoding using stdin then creating an MKV file.
    (Click to enlarge)


    Keep in mind that the encoder requires valid input resolution and frame rates as input. We covered these in our last tutorial, but for convenience here's the table once again:

    Rate
    (Numerator)
    Scale
    (Denominator)
    Approximate FPS
    = Rate / Scale
    Max Dimensions Min Dimensions
    60 1 60 1280x720 320x240
    60000 1001 59.940 1280x720 320x240
    50 1 50 1280x720 320x240
    30 1 30 1920x1080 320x240
    30000 1001 29.970 1920x1080 320x240
    25 1 25 1920x1080 320x240
    24 1 24 1920x1080 320x240
    24000 1001 23.976 1920x1080 320x240

    Width and height must each be multiples of 8.
    Width and height are tested independently for minimums and maximums.
    Any alternative rate/scale representations must evaluate to exact equivalents.


  • Input trimming

    A minor new feature is the ability to trim frames from the beginning of the input video using -start. In conjunction with the existing -frames argument it is possible to specify a range of frames to be encoded, which can be useful for conducting short tests as well as removing unwanted sequences from captured material. An example of using both features to encode only frames 1000 through 2999 is as follows:

    divx264.exe -i "MyInput.avs" -o "C:\SomeFolder\MyOutput.264" -qf 18 -start 1000 -frames 2000

    The -start argument currently works only with input from file because seeking is not possible when reading from stdin. When using stdin you should use options in the decoding application in place of -start and -frames, for example FFmpeg's -ss and -t arguments.

  • Ctrl+C, Ctrl+Break supported

    It's now possible to stop the encoder by pressing Ctrl+C or Ctrl+Break while it is running.

Known issues for DivX Plus HD H.264 Encoder Beta 2

The following are known issues in this version:

  • The encoder may run slowly with input that is in RGB colorspace. If you are using an AVISynth script for input add ConvertToYV12() to your script to convert video to YV12 colorspace.

  • The encoder doesn't support input from compressed AVI files. Create an AVISynth script using the AVISource filter to process such files.

  • The encoder will only accept 1:1 SAR for 704x576i and 704x480i input.

Downloading DivX Plus HD H.264 Encoder Beta 2

To download this beta you need to create a free DivX Labs account then join the Project Rémoulade Apps group. Downloads for Project Rémoulade are available at the top of the group homepage for signed-in members.


How you can help us

We want to hear your feedback! Please submit your comments and questions to the DivX Plus forum (requires sign-in).


If your feedback relates to performance issues or software stability, please consider attaching some of the following to your post:

  • Screenshots from CPU-Z that show your CPU, memory and mainboard configuration.

  • Screenshots of any crash dialogs, including the details view if available.

  • An export from MSInfo32, which you can launch by simply typing MSInfo32 into the Run box on your Start menu, so that we can see information about the operating system, running software and application errors.