Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th November 2003, 07:16   #1  |  Link
zambelli
Doom9ing since 2001
 
zambelli's Avatar
 
Join Date: Oct 2001
Location: Seattle, WA, USA
Posts: 2,002
Encoding Avisynth (.avs) sources with WME9

(I apologize for the re-post... I figured this might interest readers of this forum too.)

If you ever tried using Avisynth scripts as sources in the Windows Media 9 Encoder, you probably discovered that it simply didn't work. In all likelyhood you received an error message "No such interface supported".

This bothered me for the longest time. I always assumed the error message was indicating that somehow .avs files weren't supported as sources in WME9. And yet, I knew from Nic's practical implementation of the WM encoder object model that it was possible to feed .avs files to WME9.

So I finally decided to explore the problem more closely. I analyzed the VBScript-based encoder sample that shipped with WME9 - wmcmd.vbs - and found nothing in the source code that would theoretically prevent WME9 from reading .avs files. I then ran wmcmd.vbs under the Visual Studio script debugger and waited for the script to error out. When it did, I was somewhat surprised to find out that the error had nothing to do with the source reading method.

Apparently, the script-based WME9 was trying to read the duration property of the source object - and it was finding that the duration property did not exist. It errored out every time it attempted to print out the progress of the encoding process. Doh! I assume the GUI-based encoder was doing a similar thing - trying to access properties of the video source object that Avisynth simply wasn't supplying - at least not in the way that WME9 expected it.

Well, with that figured out, the fix became easy. Considering source duration was only being used for the trivial progress printout, I simply took out the few lines of code out of wmcmd.vbs that dealt with source duration. The upside: WME9 (script-based only) now accepted Avisynth scripts as input. The downside? Progress percentage disappeared from the printed output. Not a big loss, I think you will agree.

So, what do you need to do to make WME9 work with Avisynth? It's quite simple, really. First make a copy of the wmcmd.vbs file that shipped with WME9. Call it something like WME9AVS.vbs, perhaps. Now open the file in Notepad or any text/code editor and find the text "Compute file duration". Beginning with that line, delete every line of code up until (but not including) "intSleepDuration = 2000". The deleted section should count about 20 lines of code. Now replace the deleted code with the line:

intDuration = 0

Save the file and you're done. You should now be able to use wmcmd.vbs with any valid .avs file as source. As I said, the only downside is that you won't be able to get the progress report about your encoding pass, including info about the start of Pass2. Oh well. Don't forget that the .vbs version of WME9 is just about as powerful as the full version of the encoder. If you run into a setting that's not supported in the script-based encoder, just go and create a profile in the full encoder and then use the script-based encoder with the "-wme" switch. This is essentially how you get 6-channel mono WAV input and other nifty tricks done.

Feel free to suggest better fixes for the duration bug, if you can think of any. My solution is merely a workaround, I'll admit that, but for right now it gets the job done.
zambelli is offline   Reply With Quote
Old 25th November 2003, 10:11   #2  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480


(moved it to the right forum, though).
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 25th November 2003, 12:52   #3  |  Link
mf
·
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
How about the ffvfw-lite AVISynth-in-AVI wrapper?
mf is offline   Reply With Quote
Old 25th November 2003, 14:43   #4  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
It would be very strange if it didn't work - i haven't experienced anywhere, where it didn't work when audio was written to the AVI. However one step less (ie. not having to create the fake AVI is always a good thing.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 25th November 2003, 15:23   #5  |  Link
jonny
Registered User
 
jonny's Avatar
 
Join Date: Feb 2002
Location: Italy
Posts: 876
If you don't mind to use AVI as container, you can download the wmv9 codec (http://www.microsoft.com/windows/win...cdownload.aspx - see: "Codecs Installation Package for Windows Media Video 9 VCM")
After installing it, you can use wmv9 in VDub (like XviD or DivX).
jonny is offline   Reply With Quote
Old 26th November 2003, 00:59   #6  |  Link
zambelli
Doom9ing since 2001
 
zambelli's Avatar
 
Join Date: Oct 2001
Location: Seattle, WA, USA
Posts: 2,002
Jonny: This is true, and it's certainly convenient to be able to use WMV9 in VDub, but in my opinion (and I try to keep it as unbiased as possible) ASF does have one big advantage over AVI: it supports non-square pixel encoding. If you're encoding anamorphic content it's a huge factor to be able to preserve the full resolution of the video source while still maintaining the proper aspect ratio and fully utilizing the bitrate.

Take as an example a case where you have an anamorphic DVD source that you're trying to convert to WMV9. If you use AVI as the container, you're stuck with square pixels. Your 720x480 source now needs to be resized to a square pixel resolution such as 864x480 or 640x360 to maintain the proper aspect ratio. In the former case you waste bitrate; in the latter you lose lines of resolution. Sure, you could keep the full resolution and encode the AVI as 720x480 and then use a 3rd party player such as BSPlayer or MPC which supports real-time resizing, but then you're increasing the level of complexity. Correct playback becomes a skill. Would your tech challenged friend know to use the right player or to set it to the right resizing mode?

With ASF, on the other hand, you can simply encode the 720x480 source "as is", without any resizing, and set the PAR to 23:19 (I calculated this on the fly just now so I could be a little off) to force the player to resize the rendered image to 870x480. WMP9 will do this and any other player which uses VMR-9 (such as MPC) should be able to do this automatically.
zambelli is offline   Reply With Quote
Old 26th November 2003, 09:54   #7  |  Link
jonny
Registered User
 
jonny's Avatar
 
Join Date: Feb 2002
Location: Italy
Posts: 876
Quote:
With ASF, on the other hand, you can simply encode the 720x480 source "as is", without any resizing, and set the PAR to 23:19 (I calculated this on the fly just now so I could be a little off)
First time i hear about this, thanks for the info.
Anyway, yep, i try to keep all the rows too (when is possible)
Usually i store the correct aspect ratio in the filename: test_2_347.avi (and i set something like this with BSPlayer: 2347:1000).
(i calculate the correct ar after cropping)
I know that while this looks really simple to my eyes, could look incomprensible to someone other ( expecially some friends )

Last edited by jonny; 26th November 2003 at 09:56.
jonny is offline   Reply With Quote
Old 26th November 2003, 13:08   #8  |  Link
mf
·
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Oh man, this is the first time you'll hear me recommend Matroska, but set against ASF I just can't help but do. Matroska has pixel aspect ratio setting too, and you can encode in it through VirtualDubMod, which works via the VfW API.
(how I'll regret having posted this later )
mf is offline   Reply With Quote
Old 26th November 2003, 14:31   #9  |  Link
jonny
Registered User
 
jonny's Avatar
 
Join Date: Feb 2002
Location: Italy
Posts: 876
zambelli, now you have the complete solution
jonny is offline   Reply With Quote
Old 14th December 2003, 18:27   #10  |  Link
kassandro
Registered User
 
Join Date: May 2003
Location: Germany
Posts: 502
Actually there are two wm9 encoders. The command line encoder, which cannot encode videos frame served by avisynth and the encoder with a GUI, which can handle AVS scripts. It is quite buggy though and Microsoft has built in a very special user terror feature. If the system is overloaded and cannot give cpu cycles to the encoder for a while the encoder STOPS and you have to start from the beginning. Nevertheless I managed to encode quite a few videos frame served by avisynth.
kassandro is offline   Reply With Quote
Old 5th February 2004, 07:37   #11  |  Link
Christo
Registered User
 
Join Date: Apr 2002
Posts: 13
Thank you for WMV+AVS info
Christo is offline   Reply With Quote
Old 27th February 2008, 19:26   #12  |  Link
Umamio
Cost Effective
 
Join Date: Nov 2007
Posts: 64
Batching encodes

... 4 years later

I had been using the Windows Media Encoder GUI "Source From: Both Device and File" trick to perform my WMV encodes from avs but this method suits me much better and worked great. Thanks for this information!

One issue I was wondering if anyone could help me with: When I tried to batch my encodes (rather than have just have a single encode per .bat file) the cmd console became unresponsive after outputting the details of the first encode and did not move onto the next. Actually, it happens after each encode, regardless, but it is only a problem when they are batched. Is anyone aware of this being a common problem or does anyone have a potential solution?

The only special filters loaded in the .avs are VobSub and DGdecode.

If not, is anyone aware of a way that I could force kill a command console after an encode is complete and load another bat file.

Like batching up a sequence of .bat files with a kill process in between each. So.. a bat file of launching other bats that launch processes that commit suicide when they are complete. Something like that. Or maybe the vbs could be modified further?
I am a moron.

ANYWAY, if anyone can help, that would be excellent.



Edit: I visited Zambelli's site in the hope that there might be something there and there was an updated VBS which does everything I could ever ask for. My prayers are answered. Thank you!

Last edited by Umamio; 27th February 2008 at 19:46. Reason: Found solution
Umamio is offline   Reply With Quote
Old 28th February 2008, 07:00   #13  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
You don't see to be the only one:
http://forum.doom9.org/showthread.php?t=133587
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 28th February 2008, 13:08   #14  |  Link
Umamio
Cost Effective
 
Join Date: Nov 2007
Posts: 64
Thanks for the information, Shodan.

My problems have all been solved by Zambelli's most recent (October 11, 2007)modified vbs.

I don't know if the problems I've outlined here apply to that thread as this is the first time I've ever had a functioning command line batch encoder for Windows Media and it's been a while since the January hotfixes that those people suspect of causing the trouble were installed on this machine.

I do have experience of other WMencoder quirks though, hopefully it will be useful info to someone!

Edit: I get the feeling it's a Vista only problem, running XP here.

Last edited by Umamio; 28th February 2008 at 14:29. Reason: Clarification
Umamio is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:44.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.