PDA

View Full Version : SetCompData - a little info + app for XviD


ChiDragon
3rd February 2006, 01:02
I spent a few hours trying to find out how the heck I could set "SetCompData" in Sylia without having to initiate the XviD codec settings dialogue, and with the help of some posts on these forums and others I figured out what I needed to do, and did a few text and binary file comparisons to figure out the particular settings I needed to change. :)

The hardest part of my solution involved creating an AutoIt script that converts a given bitrate into the Base64 used in SetCompData (this is one of those times I wish I knew some C). Binary string support is only available in the beta versions of AutoIt; one of those are required if you want to use the .au3. The _ToBase64 AutoIt UDF doesn't work for binary input yet due to a limitation in AutoIt itself, so my script creates a temp binary file which a GPL command-line app simply called base64.exe reads and converts to a temp text file, which is then read back into AutoIt and then displayed in a popup text box. I figured someone else might have some use for this, so I'm attaching it. Note that base64.exe has to be in the same directory as BitrateBase64_Beta.exe for the conversion to work.

The first four Base64 letters are "AQAA" for the first pass and "AgAA" for the second pass (01 and 02 in hex, with some zeros on the end). Then comes the 4-letter/digit bitrate string mentioned above, then the rest of the options. I left some stuff commented-out in the .au3 that might be useful if you want to find the place to edit for cartoon mode and for keyframe interval, like I did (but the rest of the string after bitrate will be different than mine unless you happen to have the exact same options setup).

I'm using Koepi's build, XviD-1.1.0-30122005, and I imagine the pass and bitrate info is stored in the same place for other versions, but the additional info probably isn't correct for older and possibly future builds.

Here's the URL for the base64.exe (source is there): http://www.rtner.de/software/base64.html

FreQi
20th May 2007, 02:52
This is so close to what I need. Your app/script returns the result to a dialog box, but I wanted to make it print out to the console, so when running it from command line, it just returns the 4 characters (for use in scripting). I tried to download autoit3 to modify the source file, but it will not run or compile your .au3. It says...

C:\Documents and Settings\freqi\My Documents\Downloads\BitrateBase64\BitrateBase64_Beta.au3 (11) : ==> Unknown function name.:
FileWrite ($BinFile, StringTrimRight (BinaryString (0), 3) & StringTrimRight (BinaryString (Number($Bitrate)), 2))
FileWrite ($BinFile, StringTrimRight (^ ERROR


Since I am new to AutiIt, can you help me figure out what's wrong? For some reason, it doesn't think that "BinaryString" is valid function. Is it a plugin or something I have to include with the source maybe? Like I said, AutoIt is totally new to me. :/

FreQi
20th May 2007, 04:16
Well, it appears the "BinaryString" function has been renamed to just "Binary" which I found out at AutoiIt's Forum (http://www.autoitscript.com/forum/index.php?showtopic=43881&hl=BinaryString+Renamed). In addition to renaming the function, it seems they have changed the way it works since the .bin file that my modified au3 file is generating is not the same as the one your .exe creates. I'm still tryiing to find a way to correct or revert this behaviour, so any insight would be great.

FreQi
20th May 2007, 06:08
OK, scratch that, I managed to fix it. I changed

FileWrite ($BinFile, StringTrimRight (BinaryString (0), 3) & StringTrimRight (BinaryString (Number($Bitrate)), 2))
to
FileWrite ($BinFile, BinaryMid(Binary(0),1,1) & BinaryMid(Binary(Number($Bitrate)),1,2))

and now it works like you originally designed. Now, to make it do what I need...