Printable Version of Topic
Click here to view this topic in its original format
Unofficial VirtualDub Support Forums > Codec Discussion > Huffyuv Question


Posted by: George Mar 29 2004, 03:01 PM
I'm using Huffyuv for several passes on a DV file to perform various operations, i.e. 3/2 pulldown, various filters, convert fps...

Is there a limit to the number of passes through Huffyuv before one will start to see resolution loss? Thta is, is "lossless" using this codec just as the name implies no matter the number?

George

Posted by: NuPogodi Mar 29 2004, 03:15 PM
AFAIK, it is not only a name. "Lossless" has to mean that input & output are absolutely identical. Similar codecs exist also for audio...

[edit] here is the link to http://www.rarewares.org/lossless.html

Posted by: stephanV Mar 29 2004, 03:19 PM
uhm

you could get some loss by constantly swapping between YUV and RGB colorspace though (as i think VirtualDub uses RGB for filtering...)
i dont know if it would be visible though, but id suggest to do some reading into it... there might be ways around it or to keep it to a minimum

i remember it being discussed here earlier, so you could start with a search on this forum smile.gif

Posted by: Cyberman Mar 29 2004, 04:44 PM
VDub asks for RGB, if I remember right, if the codec supplies it - fine. So there WILL be a loss when using Huffy. It wonīt be visible, I think, though I remember someone making tests.

Thereīs an option "Always suggest RGB format for output" - Iīm checking it now, I *think* itīll let Huffy and VDub talk in RGB.

Anyone can confirm/negate that?

Posted by: stephanV Mar 29 2004, 05:23 PM
if im interpreting the codec right it can also compress in RGB, if you dont select the 'convert to YUY2' method under RGB compression method... (the conversion is said to be a little bit lossy in the codec configure screen...) im having doubts how huffyuv works now... unsure.gif

edit: well, i think im right about the RGB-compression, it only isnt as effective as YUV-compression

an uncompressed RGB file of 22.2 MB compressed to about 8.6 MB in the best RGB mode and to 5.2 MB in the best YUV mode
guess compressing in YUV is easier/works better than in RGB

Posted by: fccHandler Mar 29 2004, 06:11 PM
Remember also that the original YUY2 frames are already 33% smaller than RGB frames. YUY2 consumes 16 bits per pixel, while RGB consumes 24 bits per pixel, so from the start there is less data for Huffyuv to compress.

In fact, the "convert to YUY2" method does exactly that; it first converts the RGB input to YUY2, then compresses the YUY2 data. This gives you much smaller Huffyuv files, however the original RGB data can't be recovered exactly, so it's the only mode which isn't actually lossless.

As I understand it, the "always suggest RGB" box is a workaround for programs which incorrectly assume that the codec's default format is its only format. It works something like this:

- You compress YUY2 data into a file with Huffyuv
- You then try to load that file into a program which only supports RGB
- During negotiations, the program asks Huffyuv to suggest a good decompression format, and Huffyuv logically says YUY2
- The program wrongly assumes that it can't load the file now

Posted by: stephanV Mar 29 2004, 07:09 PM
QUOTE (fccHandler @ Mar 29 2004, 08:11 PM)
Remember also that the original YUY2 frames are already 33% smaller than RGB frames. YUY2 consumes 16 bits per pixel, while RGB consumes 24 bits per pixel, so from the start there is less data for Huffyuv to compress.

that would be a better explanation of the smaller file size yes (i didnt know YUY2 was 16-bit, should have done more reading, i guess) biggrin.gif

anyway, since compression in RGB is possible, you can just happily avoid all problems this conversion might give at the cost of a slightly larger file size (taking uncompressed RGB as reference point)

Posted by: George Mar 29 2004, 07:21 PM
...soooo in mind-numbing newby terms do I lose all that much with say three or 4 passes?

What codec (forget about HD space) would be the ideal to use for multiple passes in VD if I'm coming off a DV25 file to start and returning there on the final pass?

George

Posted by: stephanV Mar 29 2004, 07:33 PM
using huffyuv wouldnt give you any loss in quality whatsoever
it copies the frames pixel by pixel, but stores that in a lossless compressed way (kinda like a bmp in winzip i guess)

so if you compress the same file over and over again (say x times) no quality loss will occur; file x will be an exact copy of your original video (if you use the RGB compression method)

now, of course you wanna use filters, so your video will change in appearance of course, but at least you dont have to worry that huffyuv messes up your result, like f.e. a mpeg4 codec would. everything you see is a result of the filters you are using and NOT of using f.e. a too low bitrate

so the way to go would be using huffyuv (in RGB) for all intermediate steps

hope its clear now biggrin.gif

regards - stephan

Posted by: George Mar 29 2004, 08:28 PM
Thanks, Stephan and to the others who replied.

This is very much appreciated!

George rolleyes.gif

Posted by: NuPogodi Mar 30 2004, 08:24 AM
i'm, as always, too late... but let me "insert my 5 cents"... as the quality losses are due to RGB-YUV conversion, the intensity component Y has to be independent (ok, nearly independent) of how many times you've done this conversion. The main damage should be expected for U & V (or RGB) components. However, one knows that the human eye is quite sensitive to Y and much less sensitive to U & V.

I did some tests how harmful is RGB-to-YUV conversion before... just wrote AVS-script which N-times converted a clip from RGB to YUY2 (or RGB-YV12-...-RGB-YUY2, i don't remember exactly). Vdub was in "Fast recompress" mode, i used Huffuyv codec... then, compared initial and encoded clips to estimate PSNR (separately, for Y and UV components). well, after 100 RGB-YUV conversions the Y-component decreased only on 2...3dB and remained on the level 50dB, UV went down to ~25dB. And what? such encoded clip looked, imho, MUCH better than that i encoded with "lossy" codec without RGB-YUV cycling (if i'not mistaken it was ffvfw in the 100%-quality mode -> PSNR(Y)~40db, PSNR(UV)~35db). So, my conclusion was that RGB-to-YUV conversions are much less dangerous for human eye than "loosy" reencoding that decreases PSNR(Y).

@George: it was certainly my own experience, but it says that you can use huffuyv so many times as you want (i hope 100 attempts would be enough?) the most critical point is the final compression by ffvfw, DivX, WMV9, etc. BTW, why you do not use AviSynth to test how your filters change the original clip? it is much faster, it does not require re-encoding, you do not need to free several GBs on your HDD, etc. imho, again...

Posted by: stephanV Mar 30 2004, 09:00 AM
QUOTE (NuPogodi @ Mar 30 2004, 10:24 AM)
i'm, as always, too late... but let me "insert my 5 cents"

better late then never... biggrin.gif

anyway, so what you say RGB to YUV is lossy but hardly noticable (i mean 100 times, gosh!) biggrin.gif

BTW - yesterday i was having a discussion on DivX forum (what am i doing there you ask? tongue.gif) with a guy, who claimed that huffy WAS lossy... then again, he also didnt knew what RGB was... wacko.gif

Posted by: NuPogodi Mar 30 2004, 10:39 AM
QUOTE
BTW - yesterday i was having a discussion on DivX forum (what am i doing there you ask?) with a guy, who claimed that huffy WAS lossy... then again, he also didnt knew what RGB was... 
i have no grounds to not trust the authors of huffuyv, who announced this codec IS lossless. i mean the codec itself, but not the procedure RGB-YUV which preceded encoding. since simple recalculating from one colorspace to another may give floats which should be replaced by integers, one should not wonder that one loses something. Are these losses comparable with those in which "lossy" codecs result? The mathematician's answer (PSNR): intensity - "no", color - "yes", but the human's answer is "no".
PS i apologize... i'd not like to hurt mathematicians, they are humans too...

Posted by: stephanV Mar 30 2004, 10:54 AM
QUOTE (NuPogodi @ Mar 30 2004, 12:39 PM)
i have no grounds to not trust the authors of huffuyv

me neither

well again, that guy i was discussing with also claimed that ANY type video-compression was lossy...
well nevermind... let him think that... biggrin.gif

Posted by: NuPogodi Mar 30 2004, 11:13 AM
Well, Stephan, can you answer me what for you usually use huffuyv? i mean not tests, but a practice. till now, i used it only once (for practical purposes, ceratinly) when i had to do the 2-pass encoding with VERY hard filtering (deinterlace + several noise reduction filters + crop + resize). so, i decided to encode 1st pass by huffuyv and not to repeat filtering twice. but, i must confess, i obtained not so much profit in time to compensate disconveniences (viz., a necessity to free my HDD).

Posted by: stephanV Mar 30 2004, 11:45 AM
i used to use it for intermediate steps with filters (actually im not really into this video editing yet, im still discovering new things every day so 'used to' should be taken with a grain of salt smile.gif )

as youve already pointed out, AVIsynth (just discovered that too) might be a better way to see the effects of filters... BUT (for me) AVIsynth will take some time getting used to; i still make a lot of syntax errors in the scrypts. i also sometimes forget to put in simple things like AviSource and the like laugh.gif.

if you read the http://cultact-server.novi.dk/kpo/huffyuv/huffyuv.html, they also say the main purpose of the codec is lossless CAPTURING (not editing, although it will work just as fine for that)

QUOTE
Huffyuv is intended to replace uncompressed YUV as a video capture format.


like i already said, im still a beginner so most things i do i still consider as testing. hanging around on these forums helps me to learn new stuff almost every day. i have edited some homevideos made with a digital camera (some cutting and resizing, put some text in, easy stuff).

as it comes to filters im still learning about that now. just for a 'simple' thing like smoothening there are so many different kinds of filters. im just running tests (sometimes with huffyuv/virtualdub, sometimes with avisynth) to see what they do and what the difference is between them. there is info about it on the inet of course, but i always like to see for myself. i agree that avisynth will probably go a lot faster than taking intermediate steps with huffyuv. but as for now, the test clips arent that long, so encoding times are quite low. (afterwards, i encode that in DivX, to see what the final result would be like, but the more reading i do, the more im thinking about using other codecs... unsure.gif )

im not even sure if i will ever use any filters, but id at least like to see what they do so i might improve my results... even if i never use them, at least i had fun trying it; some filters can do some weird stuff biggrin.gif

Posted by: NuPogodi Mar 30 2004, 01:21 PM
thanks, thanks a lot... it was quite comprehensive (better than Napoleon's biography biggrin.gif ) actually, i just thought about potential applications of huffy (aside from its direct application) and asked myself where i can use this codec. Except for acceleration of 2-pass encoding, no other ideas came to my stupid head. i've tested and i was a bit disappointed. That's why i asked you... hopefully, this question did not trouble you too much.

Posted by: stephanV Mar 30 2004, 01:33 PM
no troubles at all, just explaining my current understanding of the whole video-editing 'business' smile.gif
but i cant think of any other thing than whats it suggested for: capturing

Posted by: Cyberman Mar 30 2004, 04:11 PM
QUOTE (NuPogodi @ Mar 30 2004, 02:21 PM)
i just thought about potential applications of huffy (aside from its direct application) and asked myself where i can use this codec

One word: cutting.

Not just cutting parts away, but even more re-ordering parts of a video clip. It provides you with keyframes-only, AND lossless compression.

Powered by Invision Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)