Log in

View Full Version : Avoid using VirtualDub to prevent format conversions?


Lyris
30th May 2012, 17:36
Hey all,

Sometimes when I'm working on DVDs, I'll need to do things in stages. For example, taking a 4:4:4 TIFF image sequence, and using AVISynth scripts to produce a PAL or NTSC res downconvert of this.

Then I'll save this file in VirtualDub (as a Lagarith AVI file, usually in YV12 because that's all many of the AVIsynth filters operate in anyway). Downstream, I'll load this AVI file in another AVISynth script to do more processing.

The reason for the multiple steps is that combining everything into one big script is just too slow.

But, VirtualDub only processes in RGB, correct? So each time I do this, I'm adding a pixel format conversion. Just today I saw one case where the chroma resolution had been mangled by this process. Red text on a nearly black background had colour bleed everywhere.

So, my question is, how should I be doing this to preserve quality wherever possible?

sneaker_ger
30th May 2012, 17:43
But, VirtualDub only processes in RGB, correct?

This was correct in the past for its filtering system, but not anymore. "Fast recompress" mode was never affected.

kolak
30th May 2012, 17:45
No- Vdub has different processing color spaces, not only RGB. You set it in Color Depth. You can stay in YV12 if you set it.
I use YUY2 and many Vdub filters works in it natively- no need to go through RGB.

StainlessS
30th May 2012, 18:41
Fast recompress just enters negotiation with the compression codec, and if they can
agree on a common format they do not need to convert. However, in eg HuffYUV,
you have to set it to ConvertToYUV, otherwise it would actually send HUFFYUV RGB,
even if in Fast Recompress.
As far as I know all VD filters require conversion to RGB, and so cannot be used in eg
Fast Recompress or Direct Stream Copy. In my 1.9.11 when Fast Recompress is selected,
it disables Filters (tried it with a builtin filter).

Can you give the name any VD filter that accepts anything other than RGB ?
I'de kinda like to read it say that in docs as I find it extremely difficult to believe.

EDIT:
You can stay in YV12 if you set it set it where?

sneaker_ger
30th May 2012, 18:51
Can you give the name any VD filter that accepts anything other than RGB ?

I don't have the docs at hand, but the internal "resize" and "convert format" do for example. Check "Show image formats" on the bottom left in the filters window to verify.

Lyris
30th May 2012, 18:58
Ah ha! Thanks for this, guys. This wasn't always here:

http://i74.photobucket.com/albums/i258/lyris-lite/Capture.jpg

So basically once I've downconverted to YV12 in the AVISynth script, I can set these options to YV12 in VirtualDub, choose Fast Recompress, and I'm good for avoiding further degradation?

Edit: yep - seems like it - the colour bleed is gone. Now let's try to get it into Cinema Craft SP3 (YUY2) intact!

StainlessS
30th May 2012, 19:17
WOW!!!, Thanks man, that took me by surprise.
Never read the VDub docs for years, probably not since a big chunk of the old docs were abandoned.
Am now asking myself how easy it might be to incorporate the VDUBMod Avisynth Script editor in
current version of VD. Downloading SDK etc imminent.

Again, thanks very much.

StainlessS
30th May 2012, 19:47
Ah ha! Thanks for this, guys. This wasn't always here:

Just checked, VD MPEG2 had a reduced version of colorspaces
in your image, me and you have been missing out for a long long time. VDMod,
(the one I almost exclusively use except where
rendering multipart AVS files [chopped in half]) does not
have anything more than 16/24/32 bit rgb.

Gavino
30th May 2012, 20:49
VDMod,
(the one I almost exclusively use except where
rendering multipart AVS files [chopped in half]) does not
have anything more than 16/24/32 bit rgb.
VDMod was obsolete years ago.
As the saying goes, wake up and smell the coffee... :)

TheSkiller
30th May 2012, 21:09
Edit: yep - seems like it - the colour bleed is gone. Now let's try to get it into Cinema Craft SP3 (YUY2) intact!I do that a lot with CCE SP3. I always feed it YUY2 (anything else is not a good idea) even though, as usual, my script result is YV12.
The important part is, if you examine CCE's "way of downconverting YUY2 to YV12 for MPEG2" you will notice that it is equivalent to AviSynth's ConvertToYV12(interlaced=true/false). Whether the interlaced or non-interlaced processing takes place depens on one setting: in the "Picture" settings at the bottom there you can choose between interlaced, progressive and auto (do not use auto).

Knowing that CCE works this way we can simply convert from YV12 to YUY2 by doubling the vertical chroma. CCE then downsamples this and in the end it's a NOP without additional chroma bleed.


I think it can be done using chromaresample=point and some shifting of the plane as AviSynth's pointresampling introduces a shift. I should investigate this but until now I always used a function called YV12toYUY2 (http://forum.doom9.org/showthread.php?p=764655#post764655) for this which does a point resize that doesn't shift the plane. Do not confuse it with Gavino's YV12toYUY2.
For interlaced point YV12->YUY2 you need to wrap the YV12toYUY2 function in between something like separatefields() and weave() but I don't have access to my scripts on this computer.

Edit: This is what happens:

ColorBars(pixel_type="YV12")
Raw=last

YV12toYUY2()
ConvertToYV12(interlaced=false)

Subtract(last, raw) #it's a NOP, YV12 chroma stays untouched



Edit 2: If you use VD in "Fast Recompress" mode it does not matter what color spaces you set in the settings, it's only for filter processing within VD. That means this mode always keeps the incoming color space untouched.

Wilbert
30th May 2012, 21:29
Am now asking myself how easy it might be to incorporate the VDUBMod Avisynth Script editor in
current version of VD.
You know about the F2 button right? To reload your edited+resaved script.

kolak
30th May 2012, 22:04
Ah ha! Thanks for this, guys. This wasn't always here:

http://i74.photobucket.com/albums/i258/lyris-lite/Capture.jpg

So basically once I've downconverted to YV12 in the AVISynth script, I can set these options to YV12 in VirtualDub, choose Fast Recompress, and I'm good for avoiding further degradation?

Edit: yep - seems like it - the colour bleed is gone. Now let's try to get it into Cinema Craft SP3 (YUY2) intact!

You can always set YV12 as input, use AutoYUY2 filter (to upsample to 4:2:2) and than YUY2 as output color depth and export file with some 4:2:2 codec, like UTVideo or Canopus Lossless- this work very well.
SP3 likes YUY2 as input.

StainlessS
31st May 2012, 03:08
VDMod was obsolete years ago.As the saying goes, wake up and smell the coffee... :)

You know about the F2 button right? To reload your edited+resaved script.

Well the reason I live in the past is that I like Virtual Dub,
and am yet to find any other version of it that eg inserts the
current frame into the script, clip ranges, trimsets and the other
script editing functionality of the build in script editor.
Having an external editor just dont do it for me, I'm just not
that easily pleased. :)
Maybe AVSPmod does that sort of thing, shall really have to try it one day (for more than five minutes).

EDIT: having had a brief look a Vd 1.9/10 source, looks like I'll havta stick with VDubMod,
looks like too big a job to take on (still gonna explore it a little more though).