Create a DivX Plus HD video file on Linux

For years, I have been recording shows and films on TV. For this, I have been using my old “Pinnacle PCTV Stereo” acquisition card, inserted into a 1GHz VIA Nehemiah processor-powered living-room PC. More recently, I have kept using this card from time to time in a 1.8GHz Core2Duo E4300-powered desktop PC.

The living-room PC is no more; its power supply overheated. Now, I am using a regular living-room media player, which is able to read my media through the network using the DLNA protocol. This hardware media player does not have the same tolerance for varying file formats as seen with a standard PC, but luckily it can read the “DivX Plus HD” file format, which is perfect as far as I am concerned: based on a Matroska (.mkv) container, it can include chapters, and subtitles, etc.

Cet article existe aussi en français.

Since my video acquisition card is of the low-spec. kind, and my former living-room PC was also low-powered, my recordings were always made in an almost-raw (and space-greedy) format: an MJPEG video stream, and a raw audio stream, inside an AVI container. Then a two-pass transcode step would convert such files into more compact files. I mostly used 3  final formats:

  • a few films were in SVCD format, usually intended to be burnt to CD,
  • a few films were in DVD format (in particular old VHS tapes that I digitalized), usually intended to be burnt to DVD,
  • and most recordings ended up in the MPEG2 format, which is less strict and more space-efficient, even though I knew these would only be readable with a computer.

Of course, this third format is the one that cannot be read by my shiny new DLNA media player, whence the need to transcode these files. And since the Matroska container allows the embedding of subtitles, I can even convert my family video files, for which “subtitles” are really my notes about who is on the screen, and where ;-)

After several tries, it became apparent that creating a file that would be compatible with a hardware —not software— media player is tricky. On the one hand, the DivX Plus HD standard is not always followed to the letter; on the other hand, some aspects of this standard, that may seem insignificant details, are mandatory for a working result.

I finally found a combination of tools and parameters, with which I achieve a fully compatible result (with fast-forward, fast-rewind, et al.) with 100% success. You can get the script on my Git repository.

This script’s behaviour is interactive, unless changed with parameters: questions are asked about which streams to include in the generated file. The default answers should be fine, and simply accepting these should be enough to get the wanted result. If that is indeed the case with your video files, then you can automate the script by giving to it the -y parameter, the role of which is to accept all default answers.

Note that this script makes some assumptions:

  • First, the video streams given for input are supposed to not already be in the x264 format with all required properties for DivX Plus HD; thus they will always be transcoded.
  • Next, the script is written to limit the frame-rate to 25 images per second (PAL), firstly because less frames means less bytes, hence more bytes available to improve overall quality; secondly because with more than 30 images per second, the standard defines different maximum dimensions for the frames, and I did not want to manage two different sub-standards.
  • Finally, ffmpeg is supposed to support the fdk_aac codec; if this is not the case, then “-c:a libfdk_aac” should be replaced with “-c:a aac” in the script.

This script is also intended to be kind-of educative. Not only can it run as an automatic transcoding tool, but it can also assist in manual transcoding.

This script’s default behaviour is to display each command before it is run. You can choose to only do the displaying part, and not run anything (-n parameter), so that you can see what would have been run but ensure that nothing is modified on the hard disk. You can then adapt the displayed commands and run them yourself.

You can ask for information as well. The -h parameter will tell you what information can be read from the input streams (-i parameter): video, audio, and subtitle streams, and chapters.

As you can see in the script itself, the web sites that were most helpful in reaching my goal were:


  • 2017-11-06 — The code is now in Git.
  • 2015-04-04 — I discovered by chance that the crop filter in x264 will only accept even values; for example, if I must remove 6 pixels, I have to remove 2 pixels on one side and 4 on the other side, instead of removing 3 pixels on each side. Script fixed.


Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

La discussion continue ailleurs

URL de rétrolien :

Fil des commentaires de ce billet