Log in

View Full Version : How NOT to compress video with avisynth + Vdub?


Reloader
11th March 2011, 15:23
When I use avisynth script and VirtualDub to save it as avi it saves it compressed. Quality is much lower. I checked direct stream copy and it's still the same. How do I apply needed script to a video but still get it out uncompressed from Vdub?

kypec
11th March 2011, 15:28
When you apply any filter(s) to source video you're effectively modifying it so it can't be directly stream copied upon export. You can however select some lossless codec as your Compressor and save through that.

Reloader
11th March 2011, 15:34
Quality is still not same as original video. I tried Lagairth and TSCC codecs.

kypec
11th March 2011, 15:46
What about posting your script and source sample (~50MB) to have something for real tests on our side?

Reloader
11th March 2011, 15:49
The code I use

audio = wavsource("AUDIO.wav")
clip = avisource("VIDEO.avi")

even = selecteven(clip).selectodd
odd = selectodd(clip).selectodd
clip = interleave(even, odd)

clip = audiodub(clip, audio)
return fadeout(clip, 0).trim(0, 0)

As for video, file size is too big. I can give info that comes from mediainfo.

Dogway
11th March 2011, 16:00
tick fast recompress to bypass yuv to rgb conversion

Reloader
11th March 2011, 16:11
Didn't work.

Didée
11th March 2011, 16:15
even = selecteven(clip).selectodd
odd = selectodd(clip).selectodd
clip = interleave(even, odd)

== is the same as ==

clip = clip.SelectEvery(4,2,3)


This is a somewhat strange pattern to select. A more familiar pattern is (4,0,3) ... but without knowing the source, it's all guesswork.

Reloader
11th March 2011, 16:17
That's not my problem here. Avisynth did its job, but video is too much compressed.

poisondeathray
11th March 2011, 16:18
In what manner is the "quality" not the same ? wrong color ? compression artifacts ?

If you're not going to post samples, at least post a representative screenshot

Didée
11th March 2011, 16:26
Yeah. When you use a lossless compressor, then there is no loss. (Except for possible colorspace conversions - it's up to the user to care for them not to happen.)

If your result looks "heavily compressed", then you're doing something wrong.

Reloader
11th March 2011, 16:36
Here's what I did: Turned on VirtualDub, went to File> Open video file and selected avs script. Then I went to video> compression and selected lagairth lossless codec. On configure everything is unchecked, and Mode is RGB (Default). Then I go to Save as AVI and save the video.

Didée
11th March 2011, 16:45
And the original colorspace of your "video.avi" is ... what? Check with e.g. MediaInfo, or simply use Avisource("video.avi").Info()

poisondeathray
11th March 2011, 16:48
how are you determining "quality"?

in a media player? do you have 2 media players open at the same time? (only 1 can use overlay at a time)

"too much compressed" implies compression artifacts, not a difference in color or luminance

Reloader
11th March 2011, 16:53
I picked older game to determine just how well is the quality by looking at pixels. No need for 2 players at same time, difference in quality is obvious.

It is compressed from 76 mb to 6 mb.

Didée
11th March 2011, 17:07
As the bare minimum, show before/after screenshots to show up the problem.

Also, a short source sample to reproduce (or not reproduce) the problem.

This is the standard procedure when you're looking for help.

Until then, I'm out. Others should, too.

Reloader
11th March 2011, 17:15
OK, here are screens:
Uncompressed http://img69.imageshack.us/img69/7439/94703912.png
Compressed http://img191.imageshack.us/img191/4939/55186942.png

Didée
11th March 2011, 17:31
Looks funky indeed. Alas I hardly every use Lagarith (I'm on ff-Huffy for speed, or FFV1 for compression), hence I'm not sure what's the cause. Have you checked "prevent upsampling when decoding" in Lagarith's options? If not, try that.

Also, what's the compressor of the original capture file? When opening the script in Vdub, does the preview look OK, or is there already degradation in the preview?

Didée
11th March 2011, 18:13
Looking close at the screenshots, it almost looks like two forth-and-back conversions between YUV and RGB have taken place.

Figure what the original codecs's colorspace is (seems like RGB, most probably), and make sure that no colorspace conversion is taking place in the whole decoding/processing/encoding chain. It might start already with the initial decoder.

pandy
11th March 2011, 19:09
IMO Lagarith is not reliable enough to use it - use HuffYUV or FFV1 instead. Use exactly same color space in codec as in Avisynth.

Reloader
12th March 2011, 00:35
I tried "prevent upsampling when decoding", still exports it compressed. Preview looks OK in Vdub. Original capture file is 100% uncompressed video. Hence the big file size.

I don't have HuffYUV in Vdub codec list, but it probably wouldn't work anyway.

StainlessS
12th March 2011, 09:56
Here is a link to page on multi-threaded HuffYUV which I use in combo
with huffyuv 2.1.1, (It seems to work better with HD).
To use this in VDub, (assuming YUV input), select Fast Recompress
and in the VDUB compression settings for "huffyuv v2.1.1 multi-threading patch",
select for "RGB Compression method", "<- Convert to YUY2"
and in "YUY2 compresson method", "Predict Left Fastest".

EDIT Forgot this link:-

http://home.h01.itscom.net/para/intro/huffyuv-mt/

Reloader
12th March 2011, 09:58
I can't see HuffYUV in Vdub in the first place.

StainlessS
12th March 2011, 10:20
Probably because it is not installed.
By the way, the link above, on download takes you to a japanese
page with a load of different numbered versions. I just downloaded
the first in list 459, and the last in list, 712, and by MD5 checksum,
it is the last in list 712, that I have. (need to see the install notes
on the above linked page, need th dll renaming from
"huffyuv_mt_en.dll" to "huffyuv_mt.dll".

IGNORE ABOVE, have just uploaded Huffyuv to MediaFire, click on the
Exblend link in my sig to download the Huffyuv package, already edited
and you can eg install v2.1.1 ordinary and the MT version by right clicking
on their respective .INF file and selecting install.

Reloader
12th March 2011, 10:25
I installed it long ago from http://neuron2.net/www.math.berkeley.edu/benrg/huffyuv.html

BTW, you didn't give me any links.

StainlessS
12th March 2011, 10:30
Well then a re-install would be a good idea.
Links?, as I said, click on the "ExBlend() v1.02b" link at the bottom of this post
and then look for the HUFFYUV zip in the list.

Reloader
12th March 2011, 10:40
Well then a re-install would be a good idea.

Re-installed it. Still no luck. I don't think HuffYUV would work different than other codecs.

Links?, as I said, click on the "ExBlend() v1.02b" link at the bottom of this post
and then look for the HUFFYUV zip in the list.

Yeah I figured that out. I meant in your first post you gave me no links. :)
Here is a link to page on multi-threaded HuffYUV

StainlessS
12th March 2011, 10:45
Whoops, sorry for that, have added link in the original post.

Did the MT version install work?
You should after install of both find an entry in control panel
add-remove programs for both HuffYUV versions. Are they there?

Try uninstall/reinstall.

Reloader
12th March 2011, 10:54
Installed it now :) But it didn't do the job :(

StainlessS
12th March 2011, 10:58
"But it didn't do the job",

And that means what?, did not install, does not show in VDub?
does not show uninstall in add remove programs?

Reloader
12th March 2011, 11:00
It compressed the video, like other codecs.

StainlessS
12th March 2011, 11:12
OK, I'm out of suggestions, but a short clip might help others to
assist, Edited in VDUB using direct stream copy and lose any audio.
(ie direct load into VD and not via Avisynth, on audio menu, "No Audio").

Reloader
12th March 2011, 11:25
It compresses the video only if I use Avisynth.

Didée
12th March 2011, 12:51
Did the following:

1) Saved your source PNG

2) Imported PNG in Avisynth with ImageSource(). Video colorspace is RGB.

( 2a) Did a little scriptery to make side-scrolling, just so that there's something happening)

3) Opened Avisynth Script in Vdub. Video colorspace is RGB.

4) Checked "Fast recompress" in Vdub

5) Selected Lagarith as compressor. In Lagarith, checked both "RGB (default)" and "Prevent upscaling when decoding"

6) Saved the video as AVI.

7) Cecked the saved Avi against source file. They are pixel identical.

result video: http://www.mediafire.com/?b8brwn78klfbv7x


BTW1: The results between Lagarith, FFV1 and Huffyuv were pixel identical. (Each codec set to RGB compression.)

BTW2:
Huffyuv: .. 38742 kB
Lagarith: .. 37452 kB
FFV1: ...... 27719 kB


BTW3: If you're going to compress this to some kind of mpeg4 (Xvid, x264, whatever), you will face a problem. Mpeg compression will happen in YV12 colorspace. You'll need to do a 2x upscale with point sampling to overcome the chroma subsampling of YV12. :):)

Gavino
12th March 2011, 14:10
4) Checked "Direct stream copy" in Vdub

5) Selected Lagarith as compressor. In Lagarith, checked both "RGB (default)" and "Prevent upscaling when decoding"
Doesn't "Direct stream copy" cause VDub to ignore the compression settings?
Perhaps you mean unchecked "Direct stream copy"?

Reloader
12th March 2011, 14:16
How about you send me your Vdub, your video, and avs file. If it comes out compressed then I don't have a clue what's going on.

Didée
12th March 2011, 14:24
Darn, me was scatterbrained while typing. I checked "Fast recompress", of course. Not "direct stream".


How about you send me your Vdub, your video, and avs file. If it comes out compressed then I don't have a clue what's going on.
To be on the safe side, shouldn't I send you my PC rig as a whole?

Reloader
12th March 2011, 14:41
Joker :)

tengo6dedos
13th March 2011, 00:11
Try this, Lagarith selection in VirtualDub, click configure, choose Mode "YV12", and only leave selected multithreathing in Lagarith, also disable if you dont have multi core. Also use Video->Fast Recompress...

Reloader
13th March 2011, 18:11
Didn't work.

StainlessS
13th March 2011, 19:08
This seems to be going around in circles. We are yet to hear what the colorspace
of the original clip is, but know through Didee that it is RGB in the png.
Reloader keeps saying he wants it 'uncompressed', could he really be
asking how to save it, 'uncompressed', if so then Direct Stream Copy with
no codec selected will do this but seems so obvious that it has not as yet
been suggested. Is it purely the smaller file size that concerns Reloader,
as it is smaller then 'it must be worse'?
If the above is not the case, then at this point perhaps the guess work
is too onerous. Reloader need to supply some short clip if only a few frames,
using Direct Stream Copy, No audio, and no codec selected, as imported
directly into VDub.

Didée
13th March 2011, 19:34
Edit: Had missed StainlessS' post before writing mine.

Didn't work.

The advice of tengo6dedos was bad. Your "problem" is RGB->YUV conversion. Hence you should *not* select "YV12" in Lagarith, but RGB.

This was suggested to you already. EVERYTHING you need to do was suggested to you already.

BTW, how are you reviewing your encoded result? If you're playing it in a DirectShow player, it could be that your setup does not allow for RGB rendering, and the decoder (or eventually, hooked-up ffdshow) converts to a YUV colorspace before sending data to the renderer.
In case of doubt, just drag the encoded AVI into Vdub for evaluation.

Reloader
13th March 2011, 22:14
OK I figured this out (myself). I used lagairth codec (although any lossless codec would do the job), opened video in Vegas Pro, rendered it from Vegas Pro and it's not compressed. I dunno why it looked compressed in video player.

So I guess KMPlayer was problem lol.

About the size:

original video - 238 mb
Interleaved with Vdub - 26.2 mb
Rendered from Vegas Pro - 53.8 mb

Have a nice day.

smok3
14th March 2011, 09:00
why would you even ask if you then consistently ignore every good advice given? lol

pbristow
14th March 2011, 09:13
Reloader: Some generally useful tips, which may help you in future.

1. In your original request and in your responses, rather than being terse, try being *informative*. "Didn't work" as a response really doesn't tell people anything useful, especially if another poster gets in between your reply and the post you're replying to. You need to specify *what* didn't work, and *in what way*, and *how you know*. Just mentioning that you were viewing your results in KMplayer might have prompted someone to ask "how does it look when loaded in VDub?", which would have very quickly established that in fact there was nothing wrong with the way the file was being saved, and that it wasn't being "compressed" at all.

2. Remember that "a picture paints a thousand words"... and that a 40 second video clip paints a thousand pictures, which is therefore potentially as informative as a million words! ;)

KMplayer should be able to play back your video fine, so it's worth having a look at the settings you've got in there. KMplayer has a LOT of settings to check, but a useful place to start when using it to check processed video is:
[RIGHT-CLICK] to bring up the menu;
Video (Advanced) -> SuperSpeed mode.
This turns off all post-processing in KMplayer, and lets you see what the video file *really* looks like.

Good luck! :)

Reloader
14th March 2011, 11:30
I said that preview looks OK in Vdub.
Preview looks OK in Vdub.

When I said "Didn't work" it obviously meant it came out compressed. I thought no explanation was needed.