PitbullRaven Posted October 9, 2007 Share Posted October 9, 2007 ...I'm having a hard time with my first script. Basically, I receive some MKV encoded video demo and publicity files from our main branch office. We used to play them with the PC, but now we play them from our standalone DVD which supports MP4 files. So I have to run a series of programs to convert from MKV to MP4. My script so far: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 Author: Pitbull_Raven Script Function: Convert MKV with AC3 audio to MP4 level 4.1 with AAC Stereo #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here ;~ MsgBox(48, "Auto MKV to MP4 Conversion", "MKV to MP4 conversion will start automatically. Please do not interrupt the process.", 10) $var = FileOpenDialog("Please select MKV file to process.", "c:\work", "MKV Files (*.mkv)", 1+2 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else $var = StringReplace($var, "|", @CRLF) MsgBox(4096,"The Chosen One!","You chose "& $var, 10) EndIf Run(@ComSpec & '/k "c:\work\extract.bat c:\work\"'& $var) This enables me to open up the file I want to process and hopefully stores the file name as $var. What I have to do next is run c:\work\mkvtoolnix\mkvextract tracks $var --raw 1:$var(minus file extension which is MKV if possible).h264 2:$var(minus the same file extension again).m4a. I can't do it. And believe me I have googled. Probably I tried starting off with too ambitious a project, but this is what I need, rather than what I want Since I couldn't get it I tried running a batch file as you can see and have autoit run c:\work\extract.bat c:\work\$var. This would hopefully make the batch file run using that variable and the batch would process the first command I wrote down, but no joy again Anyone that can help me? I would really appreciate it. Link to comment Share on other sites More sharing options...
smashly Posted October 9, 2007 Share Posted October 9, 2007 Hi, Post the cmd line that you'd use in the cmd prompt window please, don't bother with the variable ftm.. just the hard path cmd line you'd normally run from a cmd prompt ... (just use dummy file names for the moment) and/or Post your bat file if you like as well... Can probably translate it to autoit so it won't need a bat file Cheers Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 9, 2007 Author Share Posted October 9, 2007 Hi,Post the cmd line that you'd use in the cmd prompt window please, don't bother with the variable ftm.. just the hard path cmd line you'd normally run from a cmd prompt ... (just use dummy file names for the moment)and/orPost your bat file if you like as well... Can probably translate it to autoit so it won't need a bat fileCheers You lost me with the part where you said I wouldn't need the batch file, but here goes:c:\work\mkvtoolnix\mkvextract tracks chosen_file_name.mkv --raw 1:chosen_file_name.h264 2:chosen_file_name.m4aThe bat file contents:c:\work\mkvtoolnix\mkvextract tracks %1.mkv --raw 1:%1.h264 2:%1.m4aI can get autoit to run "extract.bat chosen_file_name.mkv" but this results in the creation of "chosen_file_name.mkv.m4a and mkv.h264 and I really want to loose the mkv part and preferably do without the bat file. Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 9, 2007 Author Share Posted October 9, 2007 Anyone? Oh God. Is this too much of a noob question that it doesn't even warrant an answer? Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 9, 2007 Author Share Posted October 9, 2007 I just tried RunWait("c:\work\mkvtoolnix\mkvextract.exe tracks c:\work\",$var1," 1:c:\work\video.h264 2:c:\work\audio.m4a") instead of Run(@ComSpec & '/k "c:\work\extract.bat c:\work\"'& $var) to try and eliminate the batch file from the process but I keep getting a "The directory name is invalid.". Link to comment Share on other sites More sharing options...
smashly Posted October 9, 2007 Share Posted October 9, 2007 (edited) Hi, Supports spaces in path and filenames, can multiselect files and it'll process them 1 by 1... ;Path to mkvextract.exe, change it to suite your needs Global $MkvEx = @ProgramFilesDir & "\MKVtoolnix\mkvextract.exe" ;Path to mkvextract.exe, change it to suite your needs Global $OpenDir = @HomeDrive & "\work" ;7 File Must Exist + Path Must Exist + MultiSelect Local $fod = FileOpenDialog("Please select MKV file(s) to process.", $OpenDir, "MKV Files (*.mkv)", 7 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else Local $Start = 1, $Count = 1, $p = 1 Dim $SMF = StringSplit($fod, "|") If $SMF[0] > 1 Then $Start = 2 $Count = $SMF[0] -1 EndIf For $i = $Start To $SMF[0] Local $mb = MsgBox(3, $Count & " files chosen", "Procees file " & $p & ": " & $SMF[$i] & @LF & @LF & _ "Click Yes to procees file." & @LF & "Click No to skip this file." & @LF & _ "Click Cancel to abort processing all files." & @LF & @LF & _ "Note: Click nothing and this MsgBox will close on it's own and process this file.", 10) $p += 1 If $mb = 6 Or $mb = -1 Then RunWait(@ComSpec & ' /c ' & FileGetShortName($MkvEx) & ' tracks "' & $SMF[$i] & _ '" --raw 1:"' & StringTrimRight($SMF[$i], 4) & '.h264"' & _ ' 2:"' & StringTrimRight($SMF[$i], 4) & '.m4a"') ElseIf $mb = 7 Then ContinueLoop ElseIf $mb = 2 Then ExitLoop EndIf Next EndIf Cheers Edit: Fixed the count that showed 0 when 1 file was selected...lol Edited October 9, 2007 by smashly Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 9, 2007 Moderators Share Posted October 9, 2007 (edited) The ampersand is what we use here to join strings, not commas. Based onmkvextract tracks <inname> [options] [TID1:out1 [TID2:out2 ...]]I'd think it to be more like:$sFileExtract = "c:\work\mkvtoolnix\mkvextract.exe" $sInName = "c:\work\" & $var1 $sTID1 = "c:\work\video.h264" $sTID2 = "c:\work\audio.m4a" RunWait('"' & $sFileExtract & '" tracks "' & $sInName & '" −−raw "' & $sTID1 & '" "' & $sTID2 & '"', '', @SW_HIDE) http://www.bunkus.org/videotools/mkvtoolni...mkvextract.html Edited October 9, 2007 by SmOke_N Edit Added link and --raw option :doh: Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 10, 2007 Author Share Posted October 10, 2007 Is there any way I can keep the window open to see the result of the command line? I get a quick flash of the DOS window but then it's gone and although I don't get any errors with the script, it doesn't work. Link to comment Share on other sites More sharing options...
smashly Posted October 10, 2007 Share Posted October 10, 2007 RunWait(@ComSpec & ' /k ' ..........Did you set the path mkvextract.exe in the global variable ?I had set to suite where my mkvextract.exe is on my pc ...for you I gather it'sGlobal $MkvEx = @HomePath & "\work\mkvtoolnix\mkvextract.exe"Cheers Link to comment Share on other sites More sharing options...
smashly Posted October 10, 2007 Share Posted October 10, 2007 (edited) Global $MkvEx = @HomeDrive & "\work\MKVtoolnix\mkvextract.exe" Global $OpenDir = @HomeDrive & "\work" ;7 File Must Exist + Path Must Exist + MultiSelect Local $fod = FileOpenDialog("Please select MKV file(s) to process.", $OpenDir, "MKV Files (*.mkv)", 7 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else Local $Start = 1, $Count = 1, $p = 1 Dim $SMF = StringSplit($fod, "|") If $SMF[0] > 1 Then $Start = 2 $Count = $SMF[0] -1 EndIf For $i = $Start To $SMF[0] Local $mb = MsgBox(3, $Count & " files chosen", "Procees file " & $p & ": " & $SMF[$i] & @LF & @LF & _ "Click Yes to procees file." & @LF & "Click No to skip this file." & @LF & _ "Click Cancel to abort processing all files." & @LF & @LF & _ "Note: Click nothing and this MsgBox will close on it's own and process this file.", 10) $p += 1 If $mb = 6 Or $mb = -1 Then RunWait(@ComSpec & ' /c ' & FileGetShortName($MkvEx) & ' tracks "' & $SMF[$i] & _ '" --raw 1:"' & StringTrimRight($SMF[$i], 4) & '.h264"' & _ ' 2:"' & StringTrimRight($SMF[$i], 4) & '.m4a"', _ FileGetShortName(StringLeft($fod, StringInStr($fod, "\", 0, -1) - 1)), @SW_SHOW) ElseIf $mb = 7 Then ContinueLoop ElseIf $mb = 2 Then ExitLoop EndIf Next EndIf Try this, Added the working directory and set it to the path you'd use.. Edited October 10, 2007 by smashly Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 10, 2007 Author Share Posted October 10, 2007 (edited) Global $MkvEx = @HomeDrive & "\work\MKVtoolnix\mkvextract.exe" Global $OpenDir = @HomeDrive & "\work" ;7 File Must Exist + Path Must Exist + MultiSelect Local $fod = FileOpenDialog("Please select MKV file(s) to process.", $OpenDir, "MKV Files (*.mkv)", 7 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else Local $Start = 1, $Count = 1, $p = 1 Dim $SMF = StringSplit($fod, "|") If $SMF[0] > 1 Then $Start = 2 $Count = $SMF[0] -1 EndIf For $i = $Start To $SMF[0] Local $mb = MsgBox(3, $Count & " files chosen", "Procees file " & $p & ": " & $SMF[$i] & @LF & @LF & _ "Click Yes to procees file." & @LF & "Click No to skip this file." & @LF & _ "Click Cancel to abort processing all files." & @LF & @LF & _ "Note: Click nothing and this MsgBox will close on it's own and process this file.", 10) $p += 1 If $mb = 6 Or $mb = -1 Then RunWait(@ComSpec & ' /c ' & FileGetShortName($MkvEx) & ' tracks "' & $SMF[$i] & _ '" --raw 1:"' & StringTrimRight($SMF[$i], 4) & '.h264"' & _ ' 2:"' & StringTrimRight($SMF[$i], 4) & '.m4a"', _ FileGetShortName(StringLeft($fod, StringInStr($fod, "\", 0, -1) - 1)), @SW_SHOW) ElseIf $mb = 7 Then ContinueLoop ElseIf $mb = 2 Then ExitLoop EndIf Next EndIf Try this, Added the working directory and set it to the path you'd use.. Thanks. That worked great. If I need to change the mkvextract path how do I do it? Edit: By the way... thanks for the extra effort to open up and process multiple items at the same time and I'm even ashamed of asking this and please feel free to strike me down if you want cuz I'll totally deserve it, but could you please remove it? I'm planning on running more commands after this one and I'm sure I'm going to have a hard time just trying to work with single files, let alone multiple batch processes. If not, just look at the disaster I was putting together for this first command Edited October 10, 2007 by PitbullRaven Link to comment Share on other sites More sharing options...
smashly Posted October 10, 2007 Share Posted October 10, 2007 (edited) Thanks. That worked great. If I need to change the mkvextract path how do I do it? Edit: By the way... thanks for the extra effort to open up and process multiple items at the same time and I'm even ashamed of asking this and please feel free to strike me down if you want cuz I'll totally deserve it, but could you please remove it? I'm planning on running more commands after this one and I'm sure I'm going to have a hard time just trying to work with single files, let alone multiple batch processes. If not, just look at the disaster I was putting together for this first command Here I commented where to change the mkvextract.exe path, removed the multiselect files... commented where you can add whatever else you need to do to the file being processed..; Change this to where ever mkvextract.exe is. eg; $MkvEx = "C:\Program Files\MKVtoolnix\mkvextract.exe" Global $MkvEx = @HomeDrive & "\work\MKVtoolnix\mkvextract.exe" ; Change this to make the File Open Dialog box open at a differant path Global $OpenDir = @HomeDrive & "\work" ;3 File Must Exist + Path Must Exist Local $fod = FileOpenDialog("Please select MKV file(s) to process.", $OpenDir, "MKV Files (*.mkv)", 3 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else Local $mb = MsgBox(33, "File chosen", "Procees file: " & $fod & @LF & @LF & _ "Click Ok to procees file." & @LF & _ "Click Cancel to abort processing this files." & @LF & @LF & _ "Note: Click nothing and this MsgBox will close on it's own and process this file.", 10) If $mb = 1 Or $mb = -1 Then RunWait(@ComSpec & ' /c ' & FileGetShortName($MkvEx) & ' tracks "' & $fod & _ '" --raw 1:"' & StringTrimRight($fod, 4) & '.h264"' & _ ' 2:"' & StringTrimRight($fod, 4) & '.m4a"', _ FileGetShortName(StringLeft($fod, StringInStr($fod, "\", 0, -1) - 1)), @SW_SHOW) ;; From here you can add what ever else you want to do to your file... ; Do more stuff to the current file being worked on ; Do some more stuff to the current file being worked on ; Do some even more stuff to the current file being worked on ; etc....... ;; After this point your exiting processing the file... ElseIf $mb = 2 Then Exit EndIf EndIf With the original multi-select script it's basically the same place as above if your wanting to add other things to do to the current file being processed ... So you can do the multi select thing and do extra stuff to each file.. but meh .. Cheers Edited October 10, 2007 by smashly Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 10, 2007 Author Share Posted October 10, 2007 Thanks. I'll try to get the rest done myself based upon what you already provided. I'll let you know how it went. Thanks for the superb help. Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 11, 2007 Author Share Posted October 11, 2007 (edited) It's oficial. I couldn't stink more at this even if I tried. Anyways, since I am having such dificulties right at the begining, I can't see how on earth I'll pull off interacting with open windows and filling in fields and stuff, so I think I'd best abandon all hope Anyways... Thanks for the help. At least the part you guys contributed helped me out some. Edited October 11, 2007 by PitbullRaven Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 11, 2007 Moderators Share Posted October 11, 2007 It's oficial. I couldn't stink more at this even if I tried. Anyways, since I am having such dificulties right at the begining, I can't see how on earth I'll pull off interacting with open windows and filling in fields and stuff, so I think I'd best abandon all hope Anyways... Thanks for the help. At least the part you guys contributed helped me out some.It's nice to know ones limitations Good Luck with the next endeavor you try. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
DW1 Posted October 11, 2007 Share Posted October 11, 2007 Don't give up PitbullRaven, this is what makes autoit fun.... its the challenge, when the challenge gets hard, don't give up... just come to the forums AutoIt3 Online Help Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 11, 2007 Author Share Posted October 11, 2007 Don't give up PitbullRaven, this is what makes autoit fun.... its the challenge, when the challenge gets hard, don't give up... just come to the forums I don't think it's fair to always bug ppl. I mean, I appreciate the help and know that sometimes you have to make a lot of questions in order to learn some things, but to me it feels like I'm bugging people to hell. I always and only make questions when I'm really stuck, like now (again), but at some point the person or persons helping just get sick and tired of so many questions that they blow you off or wish you'd just die and go straight to hell But since you said I shouldn't give up, could I interest you in helping me out with the next step? Based on what smashly posted, I tried getting the next program to run. The next program would be Azid.exe and it is in the c:\work directory. In DOS I'd type azid.exe filename.ac3 filename.wav. So I setup a new Global like so in line 3 of smashly's script: Global $Azid = @HomeDrive & "\work\azid.exe" Now to get it to run I thought I'd do something like: RunWait(@ComSpec & ' /c ' & FileGetShortName($Azid) & $fod & _ & StringTrimRight($fod, 4) & '.ac3"' & _ & StringTrimRight($fod, 4) & '.wav"', _ FileGetShortName(StringLeft($fod, StringInStr($fod, "\", 0, -1) - 1)), @SW_SHOW) But it didn't work of course. After that I'd have to run yet another command: Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 11, 2007 Moderators Share Posted October 11, 2007 I don't think it's fair to always bug ppl. I mean, I appreciate the help and know that sometimes you have to make a lot of questions in order to learn some things, but to me it feels like I'm bugging people to hell. I always and only make questions when I'm really stuck, like now (again), but at some point the person or persons helping just get sick and tired of so many questions that they blow you off or wish you'd just die and go straight to hell If that were the case, I wouldn't have 11+ thousand posts... I only despise the questions that took no thought or you were too lazy to search for (especially when I can find the link in 20 seconds) those are the ones I tell you to go straight to hell on!! But since you said I shouldn't give up, could I interest you in helping me out with the next step? Based on what smashly posted, I tried getting the next program to run. The next program would be Azid.exe and it is in the c:\work directory. In DOS I'd type azid.exe filename.ac3 filename.wav. So I setup a new Global like so in line 3 of smashly's script: Global $Azid = @HomeDrive & "\work\azid.exe" Now to get it to run I thought I'd do something like: RunWait(@ComSpec & ' /c ' & FileGetShortName($Azid) & $fod & _ & StringTrimRight($fod, 4) & '.ac3"' & _ & StringTrimRight($fod, 4) & '.wav"', _ FileGetShortName(StringLeft($fod, StringInStr($fod, "\", 0, -1) - 1)), @SW_SHOW) But it didn't work of course. After that I'd have to run yet another command:Are we on the same app? Where is the " --raw " option? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
PitbullRaven Posted October 11, 2007 Author Share Posted October 11, 2007 If that were the case, I wouldn't have 11+ thousand posts... I only despise the questions that took no thought or you were too lazy to search for (especially when I can find the link in 20 seconds) those are the ones I tell you to go straight to hell on!! Are we on the same app? Where is the " --raw " option?The --raw option was used for MKVExtract. I was now trying to add a new app: Azid. I thought I could base the next command line of the script using what you provided as a model of sorts. My script now looks loke this: expandcollapse popup; Change this to where ever mkvextract.exe is. eg; $MkvEx = "C:\Program Files\MKVtoolnix\mkvextract.exe" Global $MkvEx = @HomeDrive & "\work\MKVtoolnix\mkvextract.exe" ;~ Change this to set path for Azid.exe file. Global $Azid = @HomeDrive & "\work\azid.exe" ; Change this to make the File Open Dialog box open at a differant path Global $OpenDir = @HomeDrive & "\work" ;3 File Must Exist + Path Must Exist Local $fod = FileOpenDialog("Please select MKV file(s) to process.", $OpenDir, "MKV Files (*.mkv)", 3 ) If @error Then MsgBox(4096,"","No File(s) chosen") Else Local $mb = MsgBox(33, "File chosen", "Procees file: " & $fod & @LF & @LF & _ "Click Ok to procees file." & @LF & _ "Click Cancel to abort processing this files." & @LF & @LF & _ "Note: Click nothing and this MsgBox will close on it's own and process this file.", 10) If $mb = 1 Or $mb = -1 Then RunWait(@ComSpec & ' /k ' & FileGetShortName($MkvEx) & ' tracks "' & $fod & _ '" --raw 1:"' & StringTrimRight($fod, 4) & '.h264"' & _ ' 2:"' & StringTrimRight($fod, 4) & '.ac3"', _ FileGetShortName(StringLeft($fod, StringInStr($fod, "\", 0, -1) - 1)), @SW_SHOW) RunWait(@ComSpec & ' /k ' & FileGetShortName($Azid) & $fod & _ & StringTrimRight($fod, 4) & '.ac3"' & _ & StringTrimRight($fod, 4) & '.wav"', _ FileGetShortName(StringLeft($fod, StringInStr($fod, "\", 0, -1) - 1)), @SW_SHOW) ;; From here you can add what ever else you want to do to your file... ; Do more stuff to the current file being worked on ; Do some more stuff to the current file being worked on ; Do some even more stuff to the current file being worked on ; etc....... ;; After this point your exiting processing the file... ElseIf $mb = 2 Then Exit EndIf EndIf But there is an error in the expression. I'm trying to get it to run c:\work\azid.exe the_ac3_file_created_in_previous_step.ac3 _same_file_name_with_wav_extension.wav After that I still have to run 2 more command lines: normalize -l 0 --peak -v the_resulting_wav_file.wav neroAacEnc_SSE2.exe -br 96000 -if the_same_resulting_wav_file.wav -of same_filename_but_with_m4a_extension.m4a And then all hell breaks loose because after that I can't use command line to control the h264info app, and that scares the crap out of me. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 11, 2007 Moderators Share Posted October 11, 2007 Are you sure you can pass these command lines to this app like this? Do you have the link to the command line parameters and options? (I had to find the last one myself... no likey ) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
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