Color Crushing when deinterlacing DVi using AVANTI, FFMPEG and AVISynth

Edit Alert! This posts describes obsolete tools. I suggest not trying to use AVANTI. Instead, try something newer like Mediacoder.

I use an old version of Sony Vegas for my video work (the upgrades became cost-prohibitive). The tool works fine with avi files from the old video cameras, DV(SD), but that is about it. No real support for mpeg and/or mp4 formats.

To make the best possible video, I use the MEGUI+Debugmode+Avisynth approach. This has a superior deinterlacing tool called QTGMC. Normally this is sufficient.

I’m currently doing a project which has to combine 1280x720p and 1920x1080p footage, along with my 720x480i. Because I don’t want the progressive footage to be rendered in an interface chain, the whole project has to become progressive, and I now have to convert the interlaced avi files into progressive format (because I don’t want to use default vegas deinterlacing).

The above process can only output mp4, which as I said, Vegas cannot import. So I had to dig into the AVISynth scripts. I was expecting it to be simple: It wasn’t, as AVISynth doesn’t support the output formats I need. FFMPEG does, so I was led to the AVANTI tool. Also a bit long in the tooth. So old I have to run it in administrative mode with windows 7, and the UI mangles the icons on the buttons.

Although aging, AVANTI is a really nice tool that uses both AVISynth and FFMPEG. You configure the settings you want and it creates the scripts and runs them.

I ran into several problems. First, I could not reuse the “DV(SD)” codec for the resultant deinterlaced files, as I was using sizes and colorspaces that were not supported. In particular, the colorspace was yuv12p but needed to be yuv22p, or something like that. I did not know how to change this. Perhaps a simple extra line in the AVISYynth script file, but I don’t know. So I had to use the lossless HUFFYUV codec, with the resultant multi-hundred-GB files. C’est la guerre, but I’m not lossy.

Next, I discovered that the conversion to HUFFYUV was crushing the colors (see the above link and 16-235 color bits expanding to 0-255). I didn’t think it should have been doing this but it did, so I had to adjust them in the AVANTI settings.

Next, even when I had added a script to the AVISynth panel, AVANTI didn’t think it needed to run it. So I had to choose the “FORCE” option, which means the Avisynch script will be processed upstream of ffmpeg.

All hours and hour of frustration. But it did work. Below is the main screen. Source and destination fields are self-explanatory. I wasn’t using audio as I had demuxed them earlier (you of course can enable audio). In the video option, I have selected the HUFFYUV Codec, with all other settings coming from Source.

The “Deinterlace” option presents a real problem. If we don’t select it, file readers will think the video is interlaced, even if it isn’t (or maybe the tool will save a deinterlaced video as interlaced, I don’t know). But checking the button means the yadif tool in ffmpeg is called, and I want to use the qtgmc tool in avisynth instead. From tests, I know that the button HAS to be checked (else the video is interlaced). Hopefully setting the “Deinterlace AUTO” option will work and yadif is smart enough not to deinterlace a deinterlaced image (or make it worse.)

(Aside: Don’t worry about the missing buttons and corrupted images in the menu system. This is what AVANTI looks like in windows 7.)


Now for the “Color correction page” panel. Note that I have selected the option to “Change Levels from…PC->TV and specified that it be performed in Avisynth.


I changed nothing in the “crop-scale-pad” panel. (Actually, I wanted to use lanczos to up-rez them, but I only have a free TB to work with.)

In the “AviSynth Script Editor”, I use the following script:

ConvertToYV12(interlaced=true, matrix="PC.709")
QTGMC(Preset="medium", FPSDivisor=2)

Screen is shown below:


Very important: I also had to right-click in the script text field and choose “Enable AviSynth FORCE mode”. Unless I did that, AVANTI kept running the script with only ffmpeg. (Note that the selected option is shown greyed out, while the unselected options are black). See screen shot below:


And that is it. Input is “AVI DV(SD) interlaced” and output is “huffyuv deinteraced avi container”, the latter of which Vegas can read. And the colors aren’t crushed.

Leave a Reply

Your email address will not be published. Required fields are marked *