Log in

View Full Version : AVISynth Bug for surround sound


killmoms
29th June 2010, 15:15
Hey all,

So, I've been testing out Microsoft's Expression Encoder 4 which supports input of AVISynth scripts natively (very nice). Only problem I'm running into is bringing in PCM surround sound successfully. According to a support thread I started (http://social.expression.microsoft.com:80/Forums/en-US/encoder/thread/86ef22b7-b74b-4d74-920d-0632bb862c7e) over on their forum, there's a bug in AVISynth that's returning an illegal WAVEFORMATEX structure (see MSDN documentation here (http://msdn.microsoft.com/en-us/library/dd757720(VS.85).aspx)). From what I can grok (very little) it seems that WAVEFORMATEX should only ever return a number of channels equal to or less than 2. If there's more than that, it should be a WAVEFORMATEXTENSIBLE structure instead.

Is there any way this bug could be fixed so I can successfully bring AVISynth scripts with surround sound into EE4?

Note, my method here is using MergeChannels with individual monaural WAV file stems. But, the same problem seems to occur if I'm using QTInput with audio = true and a file that has surround sound.

Gavino
29th June 2010, 16:49
Try adding the following line to your script:
global OPT_UseWaveExtensible=True

This forces Avisynth to use the WAVEFORMATEXTENSIBLE structure for output. However, it might introduce other problems which is why it is not done by default. See this thread for details (which I don't fully understand). I'm sure IanB can say more.

killmoms
29th June 2010, 20:55
Just tried that, but unfortunately it doesn't solve the problem in EE4. It returns "Error: Cannot find audio codec: 0xFFFE". That's only slightly different than before (when it said simply "Error: Cannot find audio codec.").

Tried looking through that thread (most of it's above my head) but I think I can grok that the problem might be in Microsoft's "AVI/WAV File Source DirectShow" component. Is this what's being used to process AVISynth scripts in EE4? If that's the case, how can I use Haali Media Splitter to solve the problem? I don't see anything in its settings indicating it can be used to split AVI files. Perhaps I'm not looking in the right place?

EDIT: Re-installed Haali Media Splitter and checked its box for "Enable AVI support" during install. Also went to Tools > Options > Compatability in EE4 and disabled Microsoft's AVI Splitter and enabled Haali Media Splitter (which, for some reason, showed up twice, so I enabled both) and ffdshow. Didn't seem to solve the issue, whether I opened the .avs script directly (same "Error: Cannot find audio codec.") or if I opened a fake AVI made from it with makeAVIS (which said "Error: Cannot find audio codec: 0x3313").

IanB
29th June 2010, 23:32
My old post 1245971 (http://forum.doom9.org/showpost.php?p=1245971) still summarises the state of play.

Yes Micro$loth would like everybody to use WAVEFORMATEXTENSIBLE for more than 2 channels instead of WAVEFORMATEX. But as you have discovered there is much out there that turns it's nose up at WAVEFORMATEXTENSIBLE. And much software just accepts multi-channel WAVEFORMATEX as one would expect. Hence the current less than optimal Avisynth behaviour, at least you now have options to force the desired behaviour.

Microsoft's "AVI/WAV File Source" DirectShow component seems to be your bug bear. Note this is NOT the same thing as Microsoft's AVI Splitter. This is a source problem not a splitter problem.

Your options are Persevere with getting Haali's DirectShow Avisynth source working, I can't find the reference but it is distinct from .AVI handling. :search:
Try to get the Fake .AVI file system working so that you can use the DirectShow "File Source (Async.)" component which does correctly support WAVEFORMATEXTENSIBLE (it usually just installs and works first time :confused: )

killmoms
30th June 2010, 16:05
Thanks IanB, sorry I'm kind of fumbling around with this. Is there anyone who's found specific steps that I might take to utilize these source components properly in EE4?

Worse comes to worst I can just enable or disable tracks in my source QuickTime files prior to encoding, but using AVIsynth is a little cleaner/more convenient (and allows me to mix and match audio to video, if necessary, so it's more flexible than creating a bunch of large source QuickTime files with duplicate data).

IanB
1st July 2010, 01:05
As Haali say in his post 996826 (http://forum.doom9.org/showpost.php?p=996826) if you open an .avs script with his "Haali Media Splitter" it will do what you want. The relevant component is C:\Program Files\Haali\MatroskaSplitter\avs.dll, but it is not publicly registered and appears to be just an internal helper for the main C:\Program Files\Haali\MatroskaSplitter\splitter.ax.

I tried various merit tweaker and fiddlers to make Haali the default DirectShow .avs handler but it just broke. I suspect there is something missing from the implementation to allow this. The above post is about the only reference I could find.

Avisynth Development is a pretty niche forum and this needs a DirectShow expert so I suggest you crack open a new thread in one of the other forums, maybe New and alternative a/v containers (http://forum.doom9.org/forumdisplay.php?f=74) where Haali and his enthusiasts are active.