Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ Why Avisynth can't be used with 64-bit VirtualDub

One problem with attempting to port software from 32-bit Windows to 64-bit Windows is that 64-bit processes cannot load 32-bit DLLs, even on the AMD64 (x64) platform. This is a major annoyance because it means that 32-bit video codecs, audio codecs, filters, and file format drivers cannot be loaded into 64-bit VirtualDub. Unfortunately, because Avisynth is a 32-bit DLL, it cannot be loaded either, and thus Avisynth scripts cannot be used.

The solution for a problem like this is to create a 32-bit process that hosts the 32-bit DLLs, and then use interprocess communication (IPC) to transfer data between the 32-bit and 64-bit processes. This is suboptimal because of the delays and inefficiencies in switching processes, but it would work at least and maintain compatibility. There are a number of IPC mechanisms available on Windows, but most of them have major deficiencies, such as not being securable, not having support for waiting or non-blocking I/O, or requiring Windows NT. One with relatively less suckage is COM marshaling, in which the Windows COM system automatically transfers a function call and assocated data across the process boundary.

It turns out that COM marshalling between 32-bit and 64-bit processes is explicitly allowed by Win64. The AVIFile interfaces implemented by Avisynth are COM interfaces, and thus should be usable from a 64-bit processes. Trying to do so, however, just causes AVIFile import errors. So what's going on?

I'm not a COM expert by any means, but digging around a bit in MSDN Library revealed that some Registry setup is necessary for interprocess COM marshalling that the Avisynth installer doesn't do, namely:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}]
"AppId"="{E6D6B700-124D-11D4-86F3-DB80AFD98778}"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\AppID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}]
@="Avisynth""DllSurrogate"=""
This directs DCOM to launch the default dllhost.exe application to host Avisynth. After doing this, the base Avisynth class that implements IAVIFile can be created in a 64-bit process using CoCreateInstance(CLSCTX_LOCAL_SERVER), and then can be queried to IPersistFile to open an Avisynth script.

Unfortunately, that's as far as I got.

The COM marshaller needs to know the makeup of interfaces and types used in an interface to know how to "remote" a call across the process or network boundary. It seems that Microsoft never created a type library for the IAVIFile or IAVIStream interfaces, and so although you can create Avisynth in a process host, the IAVIFile interface you get back is useless as it returns 8001000B (RPC_E_CLIENT_CANTMARSHAL_DATA) for all calls. Nuts.

I tried creating an interface description language (IDL) file for the interfaces and compiling it with the MIDL compiler, but it seems the IAVIStream interface isn't remotable. The reason is that it has methods that return LONG instead of HRESULT, making it impossible for the marshaller to return remoting errors. This is borne out by the disassembly of AVIFileOpen() in the OS, which uses CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER for the creation context, ruling out use of an out-of-process server. As I understand it this basically means that IAVIFile and IAVIStream methods would have to be reflected to a different, remote-compatible COM interface, which would require a custom 64-bit Avisynth module to handle the translation. At that point you might as well create a custom marshalling mechanism too in order to avoid the overhead of copying all of the audio and video data.

So, sadly, it looks like the only way to use Avisynth in 64-bit processes is to actually write Avisynth64.

Comments

Comments posted:


If you get a moment, take a look at this and let me know what you think:
http://www.planetamd64.com/index.php?sho..

I'm stuck trying to deal with exception handling not working in the resize filters, any help would be appreciated. :)

squid - 04 04 05 - 01:07


You could take the AVISynth source and compile a 64-bit binary, in theory. I've not done it myself though, so I don't know if the code is portable yet.

Anonymous - 06 01 09 - 19:24


A good workaround is using the Avisynth Virtual File System: http://www.turtlewar.org/avfs/
You get the ability to mount AVISynth files from windows explorer (right click in context menu) as a virtual folder with virtual AVI- & WAV-assets in it! Any NLE & any Encoder should work with it!
It's a genious tool, no matter if the application is 64-bit or 32-bit!

Try it & be impressed like me! :-)

Greetings

Jim Pansen - 08 07 10 - 06:51


I tried the avfs and Virtualdub 1.10.2 x64 and it works like a charm! I broke out a test file, 'An Officer and a Gentleman' and converted it from vob to avi (later to mkv) with xvid_x64. I was pulling 106fps nearly constantly. I am quite pleased as the quality and speed were very good, and much better than my DivX setup.

Thanks for the heads-up on this Jim!
It is a good 'hopefully temporary' work-around!

SamL - 16 10 12 - 14:56

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.