Log in

View Full Version : Getting AviSynth to work with CCE -- to be added FAQ thread


wmansir
14th May 2003, 00:33
A couple of weeks ago DDogg and myself discussed (http://forum.doom9.org/showthread.php?s=&threadid=51739) adding a post to the FAQ on this issue since the questions come up here often. I started writing this up at the time, but forgot about it. The file caught my attention today so I added a little bit more and decided to throw it up here for additions and editing before adding it to the FAQ. It's far from complete, I just added some info from the top of my head. Since I didn't use CCE 2.62 or 2.64 or the AVS 2.0x series I know help is needed there, but feel free to add info for other sections as well.

So here it is, any comments are welcome. I decided to thow this up just before heading out, so I didn't proof read it entirely. I just wanted it up so I can start the ball rolling.

EDIT 1:
Added Wilbert's info on MakeAVIS
Corrected ConvertToYUY2 and removed speed comment, thanks to DDogg
Added specific note about Mpeg2Dec.dll not compatible with AVS 2.5, DDogg agian
Corrected statment that AddAudio fix works with all versions (need autoloading for macro)
Added some links.



--------------


Getting AviSynth to work with CCE

There are several issues which can arise when trying to use AviSynth (AVS) with various versions of CCE. Since there are several versions of both CCE and AVS that are currently in use this post will try to cover common problems.

The first step is to be sure that your installation of AVS is functioning properly before blaming CCE.Try opening your .avs script in Windows Media Player or Virtual dub. If they can't open the file, CCE probably won't be able to either. Here is AviSynth.org's Troubleshooting guide. (http://www.avisynth.org/index.php?page=Troubleshooting)

Also, CCE isn't the most stable program on the block. Since this post will focus on issues of CCE and AviSynth interoperability it is also assumed that CCE is working correctly. If you are having general issues of CCE crashing with all file types including .avs scripts you should address those issues first (and good luck).

(add something which version of avs to use, recommend latest stable build, currently 2.08)

Versions of CCE

CCE 2.5
Problem: Crashes when adding .avs file.
Solution:
This is a known bug with CCE 2.5. The problem is that Avisynth scripts used with this version need to have an audio track.
The old method to do this was to simply call ResampleAudio(4100), which would add a blank audio track to the output. This actually exploited a bug which has been fixed. So here is an updated method, which should work with all versions of Avisynth 2.01 and higher.

Create a text file in your Avisynth 'Plugin' directory named ' AddAudio.avsi ', then past the following function into the file.
function AddAudio(clip v1) {
v2 = Blankclip()
v1 = AudioDub(v1,v2)
return v1
}
Then add the line ' AddAudio() " to your script. To be sure it worked, open the .avs file in Vdub and on the menu go to ' File->File Information... ' and make sure the Audio stream information is not blank. CCE 2.5 should now accept the script.

CCE 2.62
Problem: CCE won't open my .avs script.
Solution:This version does not accept .avs scripts. As a workaround you can use a second program to convert your .avs script into a pseudo-avi, which CCE can use.

makeAVIS (by Milan) (http://cultact-server.novi.dk/kpo/avisynth/avs_cvs.html), included in his "ffvfw" codec, can do this. It is currently still under development,discussion (http://forum.doom9.org/showthread.php?s=&threadid=49964).

There is also a commercial program called Link2 (http://www.videotools.net/index.php?rub=guides&htm=intro2link2.htm) which is known to work well.
CCE 2.64


CCE 2.66
Problem: CCE is leaking memory FAST!
Solution: This has been observed by several people. It seems to be related to using .avs scripts that don't contain audio. So it is recommended to add audio to your .avs scripts as described in the CCE 2.5 section. However, this solution will not eliminate the memory leak, only reduce it to a more manageable level.

Notes on using AviSynth 2.5

There are now two major branches of the Avisynth development tree.

The 2.0x branch is an improvement to the traditional 1.x series, with bug fixes and some additional functionality. Scripts and plugins are usually compatible between Versions 1.x and 2.0x. Most guides and programs that use AVS are referring to this series.

The major change in the 2.5 branch is the ability to use YV12 colorspace. This means the video is processed in the original format that is on the DVD. When encoding with programs that can accept YV12 input you will see a significant increase in speed. However, the 2.5 series has several limitations. Plugins are not compatible with 2.0x (or vice versa, including Mpeg2Dec.dll) and scripts may need to be adjusted to be compatible with AVS 2.5. Read this FAQ (http://forum.doom9.org/showthread.php?s=&threadid=37276) if you are planing to use AVS 2.5.

If you choose to use AVS 2.5, regardless of what version of CCE you use (up to 2.67.00.10), you will need to convert the colorspace to YUY2 before opening the script in CCE. This is easy, just add the line

ConvertToYUY2()

the the end of your script.

Wilbert
14th May 2003, 12:50
Very nice!

CCE 2.62
This version does not accept .avs scripts. As a workaround you can use a program called Link2 (add link) that will convert your script into a pseudo avi file that can be used with this version of CCE.
I suggest to use "makeAVIS". From the YV12 faq:

A (free) replacement of the avi-wrapper Link2 appeared: makeAVIS (by Milan) (http://cultact-server.novi.dk/kpo/avisynth/avs_cvs.html): included in his "ffvfw" codec, discussion (http://forum.doom9.org/showthread.php?s=&threadid=49964).

wmansir
14th May 2003, 22:47
Thanks for the info and the links, they will be added in. I'll have to do some reading on the subject so it may take a few days until I have the time.

DDogg
15th May 2003, 01:14
wmansir, thanks for this work. Comments:

Avisynth 2.5x and CCE (all that accept an AVS script)

1> You must use Mpeg2Dec3.dll, not the more common Mpeg2Dec.dll. They are not interchangeable.This is easy, just add the line ConvertToYUV2()the the end of your script. Unfortunately, this will negate some of the speed increase that comes with using AVS 2.5 Should be COnvertToYUY2 not V. I think that may be a small overstatement. All operations prior to the COnvertToYUY2 statement are carried out in YV12 if the filters used support YV12 (Most do now). Since CCE needs YUV as an input format to be most efficient, I think one could argue that it does not cause a slowdown when using CCE. That could be wrong, but is what I think at the moment. No matter, the speed using Avisynth 2.5x and Mpeg2Dec3 is considerably faster than earlier versions.

Will add more as they come to mind.

wmansir
15th May 2003, 22:36
Edit 1:

Added Wilbert's info on MakeAVIS, but still haven't researched it completely. Since I don't use CCE 2.62 or 2.64 and really don't want to have to test it completely could someone answer a couple of questions.

1. Does it work well with CCE 2.62/4 and AVS 2.0x and 2.5?
2. Is there any reason to include Link2 or does MakeAVI work just as well with CCE.

I read through the discussion thread, but was unsure these things.

@DDogg
Thanks for catching that YUY2 mistake, I always mess it up. I also removed the note about the speed. I was refering to the loss of speed gains most people get from the switch to AVS 2.5, but since CCE can't accept YV12 input I can see your point that you aren't really losing anything. So it is probably best left unsaid.

Regarding the Mpeg2dec3.dll issue, I think that is covered in the statement that Plugins are not compatible, but I added a specific note on mpeg2dec.dll. The move to AVS 2.5 is fairly complicated so I think it is best to just point to the YV12 FAQ and then say go back to step 1: Verify that AVS is working.

DDogg
16th May 2003, 03:41
I'll take the makeavi test and check it out with all versions of CCE and Avisynth 2.5. Will report back results within 24hr.

Wilbert
16th May 2003, 09:44
Dunno whether the audio is already working?

RB
16th May 2003, 12:57
Guys, thanks for all this work. As I am now the elected CCE forum moderator :), I'll completely rewrite the CCE FAQ. Do I have your permission to use (in possibly slightly edited shape) what was written here?

Thanks!

DDogg
16th May 2003, 14:19
There is a version of mpeg2dec.dll compiled for 2.5 by neuron2, which is used in dvd2svcd bundle for example.
Dvd2svcd uses mpeg2dec3 for avisynth 2.5x, at least that is what he told me to use. I was not aware of another version of mpeg2dec that would work with it instead. Also, mpeg2dec3 is what gives the majority of the speed increase to the avisynth 2.5x combo so I would see no reason to use anything else.

@RB, congrats! I think you will be a great mod for the CCE forum.

wmansir
16th May 2003, 16:17
@RB:
Congratulations RB. I also have faith in you.

Of course you can use what is written here. If the original FAQ poster were still active I would have asked about editing it in, but that didn't seem possible. So this is great news. Feel free to edit the heck out of it or just take what you want. The purpose of this post was to answer common questions, so as long as those answers are in the new FAQ I'll be happy.

@Bach:
My intention for that section was to let the user know that AVS 2.5 has special needs, including different plugins from those used with AVS 2.0x. While I don't want to present wrong information, I also don't want to get bogged down in details.

If you read the section "Plugins are not compatible with 2.0x (or vice versa, including Mpeg2Dec.dll) and .." it actually doesn't say Mpeg2dec.dll is not compatible with AVS 2.5, it says that plugins for 2.5 and 2.0 are not interchangeable, including builds of mpeg2dec.dll. Although I may reword that to make that clearer.

In any case, thank you for your input. I appreciate it.

@All: I would still like to complete this so if anyone has info they think should be added please post it.

DDogg
16th May 2003, 18:23
Well you are sorta right on one and completely dead wrong on the other /Edit as concerns Dvd2svcd.have a look at the folder "path\DVD2SVCD\Avisynth2.5 Plugins\Mpeg2dec" and you will see that indeed the plugins are in the bundle. If dvd2svcd don't use it by default is just his choice. I worked with him for hours and hours via IM on the Avisynth 2.5x supported version. We always used Mpeg2dec3 and there was never a mention of some special version of mpeg2dec.dll. I don't want to go to the trouble to check, but I think he must have added this special version later for some compatibility reason and that slipped by me. Thanks for bringing that to my attention.This is not deadly true and you could have find it doing a fast search http://forum.doom9.org/showthread.p...+2.5#post275068 Dead wrong here and I think I can prove that to you conclusively.

Bach, do me a favor, start an encode in D2S with this special Mpeg2dec.dll version selected in the frameserver tab. Note the speed. On my machine it is 1.32. Now, kill D2S, stop CCE, and goto the avs script and add "3" to the loadplugin line so that mpeg2dec3.dll is now used.

Reload the ECL and press encode. You will see a particularly large speed difference. On my machine the speed increases to 1.65. Please try that and come back and confirm so I can know this is not something machine specific. All this of course using latest csv Avisynth 2.5x

LATER --
/edit: This is very interesting. I think I see the point you are making re "no filters" and it REALLY ties into the discussion Wmansir and I were having re the speed difference of the converttoyuy2 statement after all other work is done in YV12 colorspace. If you use Mpeg2Dec3 which serves YV12 and the normal resizing, addborders stuff like this script:

LoadPlugin("C:\PROGRA~1\DVD2SVCD\AVISYN~1.5PL\Mpeg2dec\MPEG2DEC3.dll")
mpeg2source("D:\TwoWeeks\DVD2AV~2.D2V")
-= AviSynth script by FitCD v1.1.2 =-
LanczosResize(480,368,8,0,704,480)
AddBorders(0,56,0,56)
ConvertToYUY2()
Import("D:\TwoWeeks\ResampleAudio.avs")
ResampleAudio(44100)

There is a large difference in speed between Mpeg2dec3 and the special mpeg2dec.dll even if the redundant ConvertToYUY2 statement is removed when using the special mpeg2dec.dll which serves YUV.

However, If the filters are removed like this and mpeg2dec3.dll is used there is very little difference between it and the special mpeg2dec.dll. This really shows the power gained when working within YV12 colorspace when filters are used, even when those are as simple as resizing. Remember these two examples showed a speed differnece on my specific machine of 1.3x and 1.6x. That's a bunch!

LoadPlugin("C:\PROGRA~1\DVD2SVCD\AVISYN~1.5PL\Mpeg2dec\MPEG2DEC3.dll")
mpeg2source("D:\TwoWeeks\DVD2AV~2.D2V")
ConvertToYUY2()
Import("D:\TwoWeeks\ResampleAudio.avs")
ResampleAudio(44100)

So, I would slightly change and restract a part of my statement. You are dead wrong when it comes to DVD2SVCD as filters are inherent with SVCD conversion and most other conversions. You are not dead wrong when it comes to a conversion if that conversion used absolutely no resize or other filters. :D

/Edit2
Looks like my edit crossed with your reply but I see we are now in sync with our understandings. Good stuff, thanks for the conversation.

DDogg
16th May 2003, 20:03
so I am not wrong at all. I said "it is used in the bundle". I didn't say "it is used in the conversion", did I? :) hehehe, a meer minor point of semantics :)

DDogg
16th May 2003, 23:36
As promised above:

I played around with MakeAVIS from Milan, Link2 (commercial), and vfapi for frameserving to versions of cce using avisynth 2.5x. I am in a hurry to get my kid to a ballgame but here is what I found so far:

MakeAvis - Will not work at present with CCE 2.50, will work with CCE 2.66.01.07 and 2.67.09 and I assume most other versions after the 2.5x series. Is the fastest and seems stable for what Milan calls a test version. Of interest is the force YUY2 colorspace selection. It is actually slightly faster when serving to CCE than putting the COnvertToYUY2 in the avs script and not using the force YUY2 in Makeavis which speaks reams about how well Milan can program.

Link2 is nearly as fast and is a little more flexible and robust than makeavis. It WILL serve to CCE 2.50 and all others I tested. Its internal force YUV will not work with CCE and needs the ConvertToYUY2 statement in the avs script.

VFAPI, slowest but still the king as it is by far the most versatile (and, IMO, the most under appreciated tool we have). It will serve anything to anything including TPRs from TMPG, and VDRs from VirtualDub frameserving. Downside is VFAPI only outputs to RGB24. This is one of the reasons it is slower, IMO, especially with CCE.

That's all I have time for at the moment, but will add more later if something pops to mind. Any ? just ask.