mikeytown2 Posted March 14, 2008 Posted March 14, 2008 (edited) I completely automated the HEX hack that is now dead. http://forum.videohelp.com/topic336882.htmlsince its dead, I've decided to release this. Drag and drop avi/avs files or dir's onto the compiled exe.expandcollapse popup#include <GUIConstants.au3> #include <Array.au3> #include <File.au3> #include <Constants.au3> #include <String.au3> Opt("TrayIconDebug", 1) Opt("MustDeclareVars", 1) Global $filelist[1] Global $filetype = "*.avs" Global $ffmpegloc = "" Global $flvmdiloc = "" ChkCmd() If MsgBox(1, "avs/avi to flash", $filelist[0] & " Files to Be processed" & @CRLF & _ArrayToString($filelist, @CRLF, 1)) == 2 Then Exit EndIf GUI() Func FlashSix($in, $out = "", $vidbitrate = "", $mp3bitrate = "", $samplerate = "", $gopSize = "", $audch = 1, $matrix = "No Matrix") local $mp3enc, $videoenc, $matrixSet ;set default outputfile If $out == "" Then $out = $in & $matrix & ".flv" EndIf ;set default video bitrate If $vidbitrate == "" Then $vidbitrate = 280 EndIf ;set default audio bitrate If $mp3bitrate == "" Then $mp3bitrate = 32 EndIf ;set default audio samplerate If $samplerate == "" Then $samplerate = 22050 EndIf ;set default Group of Pictures Size If $gopSize == "" Then $gopSize = 60 EndIf $matrixSet = '' ;set matrix Switch $matrix Case "No Matrix"; GOOD $matrixSet = "" Case "notch matrix" ;GOOD $matrixSet = '-inter_matrix "16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44"' Case "M4G LRM V4 LRM is for low to very low bitrates" ;GOOD $matrixSet = '-inter_matrix "13,14,16,18,20,21,22,24,14,15,18,19,20,21,22,25,16,18,20,21,22,23,25,27,18,19,21,23,25,26,29,31,20,20,22,25,28,31,35,38,21,21,23,26,31,37,42,48,22,22,25,29,35,42,51,61,24,25,27,31,38,48,61,76"' Case "M4G MRM V2 MRM is supposed to work well at moderate bitrates" ;GOOD $matrixSet = '-inter_matrix "12,16,16,18,20,22,25,28,16,16,17,20,20,23,26,28,16,17,20,22,24,26,29,31,18,20,22,25,28,31,33,38,20,20,24,28,33,37,43,49,22,23,26,31,37,46,56,65,25,26,29,33,42,56,70,88,28,28,31,38,49,65,88,115"' Case "M4G High Detail V3.1 A very sharp matrix, works best at mid bitrates" ;GOOD $matrixSet = '-inter_matrix "12,12,12,12,13,16,19,25,12,12,12,12,13,16,21,27,12,12,13,15,18,21,26,33,12,12,15,21,25,30,37,45,13,13,18,25,34,43,54,64,16,16,21,30,43,60,76,94,19,21,26,37,54,76,102,132,25,27,33,45,64,94,132,177"' Case "Angel BestVeryLow" ;GOOD $matrixSet = '-inter_matrix "16,17,18,19,20,21,99,99,17,18,19,20,21,22,99,99,18,19,20,21,22,23,99,99,19,20,21,22,23,24,99,99,20,21,22,23,25,26,99,99,21,22,23,24,26,99,99,99,22,23,24,26,99,99,99,99,23,24,25,99,99,99,99,99"' EndSwitch ;set ffmpeg location If $ffmpegloc == "" Then $ffmpegloc = GetFileLoc("ffmpeg.exe", "Select ffmpeg.exe", "Program Files (*.exe)") EndIf ;set flvmdi location If $flvmdiloc == "" Then $flvmdiloc = GetFileLoc("flvmdi.exe", "Select flvmdi.exe", "Program Files (*.exe)") EndIf ;Set Video bitrate $vidbitrate = $vidbitrate *1024 ;Set mp3 bitrate $mp3bitrate = $mp3bitrate *1024 ;set mp3 ffmpeg settings If $mp3bitrate > 0 Then $mp3enc = "-acodec libmp3lame -ab " & $mp3bitrate & " -ar " & $samplerate & " -ac " & $audch ;$mp3enc = "-acodec libmp3lame -aq 8 -ar " & $samplerate & " -ac 2" Else $mp3enc = " -an " ;Disable audio recording EndIf ;set video encodeing settings, only thing to change would be -g 250 $videoenc = ' -y -vcodec flv -b ' & $vidbitrate & ' -flags mv4+obmc+qpel+loop+gmc+mv0+umv+trell+aic+cbp+qprd -g ' & $gopSize & ' -strict 5 -pred 3 -cmp 3 -subcmp 3 -mbcmp 3 -ildctcmp 3 -precmp 3 -skipcmp 3 -subq 9 -coder 5 -mbd 2 -trellis 10 -i_qfactor 0.71 -qcomp 0.6 -qblur 1 -flags2 mixed_refs+brdo+skiprd+non_linear_q -partitions parti4x4+parti8x8+partp4x4+partp8x8 ' & $matrixSet & ' ' ;pass 1 RunWait('"' & $ffmpegloc & '" -i "' & $in & '" -pass 1 ' & $mp3enc & $videoenc & '"' & $out & '"') ;pass 2 RunWait('"' & $ffmpegloc & '" -i "' & $in & '" -pass 2 ' & $mp3enc & $videoenc & '"' & $out & '"') ;add keyframes to metadata RunWait('"' & $flvmdiloc & '" ' & '"' & $out & '" /k') ;hex the File If $vidbitrate/1024 > 350 Then FLVHex($out) EndIf EndFunc ;Grab Drag-n-Droped files/dir's Func ChkCmd() ;Files where dropped onto exe If $CmdLine[0] > 0 Then Local $dirbit = 0 For $x = 1 To $CmdLine[0] Step + 1 ;run though all files droped and look for dir's If StringInStr(FileGetAttrib($CmdLine[$x]), "D") Then $dirbit += 1 If $dirbit = 1 Then ;if a dir is found then ask what type of file extension to look for $filetype = InputBox("input file extention", "input file extention", $filetype ) EndIf FileListFromDir($CmdLine[$x]) ;parce dir looking for file of that extenstion Else ;add file to list _ArrayAdd($filelist, $CmdLine[$x]) $filelist[0] += 1 EndIf Next EndIf EndFunc ;add to array, list of files in a dir Func FileListFromDir($dir) ;search for the first file with the correct file extenstion Local $file, $search = FileFindFirstFile($dir & "\" & $filetype) ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No " & $filetype & " files found") EndIf ;add found files to array While 1 $file = FileFindNextFile($search) If @error Then ExitLoop EndIf ;Add file to array _ArrayAdd($filelist, $dir & "\" & $file) $filelist[0] += 1 WEnd FileClose($search) ; Close the search handle EndFunc ;==>FileListFromDir ;Location of file Func GetFileLoc($fname, $title, $type) local $temp = FileFindFirstFile(@ScriptDir & "\" & $fname) If $temp <> -1 Then $fname = FileFindNextFile($temp) FileClose($temp) Return ($fname) Else FileClose($temp) $temp = FileOpenDialog($title, @ScriptDir, $type, 3, $fname) If @error = 1 Then Exit Return $temp EndIf EndFunc ;==>GetFileLoc ;Open File Func FLVHex($file) Local $contents, $loc, $fsz, $maxfz = Round(27.56*1024*1024), $maxsec = 660, $neededSec, $a = "0000", $b = "0000", $c = "0000", $d = "0000" $fsz = FileGetSize($file) ;1min ~=~ 2,611,907 bits $neededSec = Round($fsz/($maxfz/$maxsec)) ;Calc hextime Switch Int($neededSec/60)+1 Case 1 $a = "4E00" Case 2 $a = "5E00" Case 3 $a = "6680" case 4 $a = "6E00" case 5 $a = "72C0" Case 6 $a = "7680" Case 7 $a = "7A40" Case 8 $a = "7E00" Case 9 $a = "80E0" Case 10 $a = "82C0" Case Else $a = "84A0" EndSwitch $contents = FileRead(FileOpen($file, 16), $fsz) $loc = StringInStr($contents, "6475726174696F6E0040") $contents = StringReplace($contents, $loc, "6475726174696F6E0040" & $a & $b & $c & $d, 1 ) FileWrite(FileOpen($file, 18), ($contents)) EndFunc Func FindPower($s) Local $temp = 2, $x=0 While $temp < $s $x +=1 $temp = 2^$x WEnd Return $x EndFunc Func GUI() #Region ### START Koda GUI section ### Form=Form1.kxf Local $Form1, $Label1, $vbr, $Label2, $abr, $Label3, $Label4, $Label5, $Label6, $vgop, $asr, $ac, $vm, $ok, $cancel, $nMsg $Form1 = GUICreate("Form1") $Label1 = GUICtrlCreateLabel("Target Video Bitrate", 8, 8, 98, 17) $vbr = GUICtrlCreateInput("280", 8, 24, 121, 21) $Label2 = GUICtrlCreateLabel("Target Audio Bitrate", 264, 8, 98, 17) $abr = GUICtrlCreateInput("32", 264, 24, 121, 21) $Label3 = GUICtrlCreateLabel("Audio Sample Rate", 152, 8, 95, 17) $Label4 = GUICtrlCreateLabel("Audio Channels", 264, 56, 78, 17) $Label5 = GUICtrlCreateLabel("Video Group Of Pictures Size", 8, 56, 141, 17) $vgop = GUICtrlCreateInput("60", 8, 72, 121, 21) $Label6 = GUICtrlCreateLabel("Video Matrix", 8, 128, 62, 17) $asr = GUICtrlCreateList("", 152, 24, 49, 97) GUICtrlSetData(-1, "11025|22050|44100", "22050") $ac = GUICtrlCreateList("", 264, 72, 41, 45) GUICtrlSetData(-1, "1|2", "1") $vm = GUICtrlCreateList("", 8, 144, 401, 136) GUICtrlSetData(-1, "Angel BestVeryLow|M4G High Detail V3.1 A very sharp matrix, works best at mid bitrates.|M4G LRM V4 LRM is for low to very low bitrates|M4G MRM V2 MRM is supposed to work well at moderate bitrates|No Matrix|notch matrix", "notch matrix") $ok = GUICtrlCreateButton("ok", 80, 288, 75, 25, 0) $cancel = GUICtrlCreateButton("cancel", 256, 288, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ok For $x = 1 To $filelist[0] Step +1 FlashSix($filelist[$x], "", GUICtrlRead($vbr), GUICtrlRead($abr), GUICtrlRead($asr), GUICtrlRead($vgop), GUICtrlRead($ac), GUICtrlRead($vm)) Next Exit Case $cancel Exit EndSwitch WEnd EndFuncRequires ffmpeg.exe and flvmdi.exe to be in the same dir as this compiled exehttp://ffdshow.faireal.net/mirror/ffmpeg/http://www.buraks.com/flvmdi/Assumes video has already been resized (320x240). Edited March 14, 2008 by mikeytown2 Email: POP3 & SMTP using SSL/TLS (OpenSSL)Email: IMAPEmail: Base64 & SMTP login & Send email direct to MX Server (thanks blindwig)Win: Hook Registry ChangesWin: Read/Write to Alternate Data Streams (ini example)Utility: GPS Distance Calculations, Vincenty and Haversine formulas; angles and elevationUtility: Dell Laser Printer (3000-5100) - Print LoggerUtility: Reset Router when Wireless Link FailsUtility: ImageMagick Batch jpg ProcessorVideo HCenc Batch FrontendVideo: *DEAD* YouTube Video Encoder (avs/avi to flv)Software On CD's I Like<<back|track3 Ultimate Boot CD for Windows SpinRite Ubuntu ophcrack
ptrex Posted March 14, 2008 Posted March 14, 2008 @mikeytown2 This is great stuff !! Recently getting into flash more and more myself. I just finished a scritp to convert Flash to Gif. i'll post it sometime soon. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
mikeytown2 Posted March 14, 2008 Author Posted March 14, 2008 @ptrex thanks! btw there are gui's out there that do what i did, just without the hex hack.http://forum.doom9.org/showthread.php?p=1018336The next step would be automating the creation of Flash8 video files, although this is a little tricky, and as far as i know, hasn't been nicely packaged.Option AOption B Email: POP3 & SMTP using SSL/TLS (OpenSSL)Email: IMAPEmail: Base64 & SMTP login & Send email direct to MX Server (thanks blindwig)Win: Hook Registry ChangesWin: Read/Write to Alternate Data Streams (ini example)Utility: GPS Distance Calculations, Vincenty and Haversine formulas; angles and elevationUtility: Dell Laser Printer (3000-5100) - Print LoggerUtility: Reset Router when Wireless Link FailsUtility: ImageMagick Batch jpg ProcessorVideo HCenc Batch FrontendVideo: *DEAD* YouTube Video Encoder (avs/avi to flv)Software On CD's I Like<<back|track3 Ultimate Boot CD for Windows SpinRite Ubuntu ophcrack
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now