View Full Version : Starting 2 Programs and an Action at the same time?
BlockABoots
18th November 2015, 23:59
I have 2 capture program (video and audio) that i would like to be able to start the recording of each at the exact same time (press record on both at the same time), so the video and audio of the 2 output files sync up.
I know i can make a simple batch file to start the programs up at the same time, ie....
@echo off
start "CaptureProg1" "C:\CaptureProg1.exe"
start "CaptureProg2" "C:\CaptureProg2.exe"
exit
but is there a way i can start both programs at the same time and tell them to start recording at the same time also?, im guessing i need to find out what the dos command is for actually starting a recording?, if so how do i do that please?
LoRd_MuldeR
19th November 2015, 00:12
That totally depends on those programs! Many programs understand additional command-line parameters that you can pass. A capture program might support a command-line switch in the vein of "/record" or "--start-recording".
If the program doesn't support command-line parameters, it still might support some sort of of IPC (inter-process communication) to receive "instructions" from other processes. On Windows, using Window Messages (https://msdn.microsoft.com/en-us/library/windows/desktop/ff381405%28v=vs.85%29.aspx) would be a common approach.
But this all really depends on what the individual programs support, or not! But, even if the particular program supports nothing like this, you could still emulate mouse clicks/movement or keyboard strokes by using a tool like AutoIt (https://www.autoitscript.com/site/autoit/).
BlockABoots
19th November 2015, 20:58
Thanks!, is there a tutorial about that explains how to use AutoIt for starting 2 programs and then simulating the mouse to click on the record button for each program at the same time?
LoRd_MuldeR
19th November 2015, 21:35
See AutoIt documentation ;)
* https://www.autoitscript.com/autoit3/docs/introduction.htm
* https://www.autoitscript.com/autoit3/docs/tutorials/helloworld/helloworld.htm
* https://www.autoitscript.com/autoit3/docs/tutorials/notepad/notepad.htm
BlockABoots
19th November 2015, 21:53
Ok thats great for opening note pad and get it to type some text, but what about actual getting a script together for activating the record button in my capture software, as that guide just seems to deal with common commands like, 'save', 'open' and 'close'?
I worked out how to actually get both programs to open up and the same time, but im at a lose how to write the script for it to activate the record function
LoRd_MuldeR
19th November 2015, 22:26
Ok thats great for opening note pad and get it to type some text, but what about actual getting a script together for activating the record button in my capture software, as that guide just seems to deal with common commands like, 'save', 'open' and 'close'?
The purpose of the tutorial is to give you a basic idea on how things work :)
Now you need to do the transfer to "your" program. Guess you'll need to dig a little deeper:
https://www.autoitscript.com/autoit3/docs/
If you can't figure it out yourself, they also have a forum:
https://www.autoitscript.com/forum/
BlockABoots
19th November 2015, 22:29
Ok, ive managed to do it using keyboard short cuts at the moment. Heres my current script....
Run("C:\Pro Capture HDMI\CaptureExpress\CaptureExpress.exe")
WinWaitActive("Magewell CaptureExpress V2.0 - Video (00 Pro Capture HDMI)")
send ("{CTRLDOWN}")
send ("{r}")
send ("{CTRLUP}")
Run("C:\Pro Capture HDMI\SDK\Bin\x64\Release\XID_MultiAudioCapture.exe")
WinWaitActive("XID_MultiAudioCapture")
send ("{space}")
That opens both programs and starts recording straight away, or though one program loads up about a second before the other, i guess i need to add a delay?. So i guess i have to make another script now for stopping the capture on both programs right?
LoRd_MuldeR
19th November 2015, 22:44
There's a function for switching to a specific window:
https://www.autoitscript.com/autoit3/docs/functions/WinActivate.htm
Also a function for a certain window to be created:
https://www.autoitscript.com/autoit3/docs/functions/WinWait.htm
BlockABoots
19th November 2015, 22:56
What about stopping the recording, i obviously dont want to use the 'run' command again as that will open up another instance of the program again?
LoRd_MuldeR
19th November 2015, 23:04
What about making a separate "stop" script? There's a function to close a window:
https://www.autoitscript.com/autoit3/docs/functions/WinKill.htm
mariush
20th November 2015, 00:00
No matter how hard you try, you'll never get them to record in sync. People use those clapper things (https://www.google.ro/search?q=clapper&source=lnms&tbm=isch&sa=X&ved=0CAcQ_AUoAWoVChMI4760o8udyQIVxy8PCh1tdA3Q&biw=2144&bih=1052&dpr=0.9) for this reason, the sound of the clapper is your cue to sync the audio to the actual video frame where the clapper closes completely, it makes it easy to sync a video with the external audio
Each application will take a different amount of time to start, depending on how many libraries and related files the application needs to load from disk when it initializes. Then, depending on what codec you choose to encode video and the audio, it will take a few milliseconds to actually start the capture and encoding process, and the codec itself will probably miss a few video frames before it's actually capable of capturing and compressing content.
Audio applications like Soundforce or Cool Edit Pro (if I remember correctly) have a sort of recording system where you can prepare the application to instantly record when you press a button. I think it's called pre-arm or something like that. You basically open the record sound window, click on a button which basically makes the application start recording all the time (so the audio codec is loaded in memory, it fills its buffers with data, everything is allocated and ready so there's no hiccups when the actual recording will happen) but doesn't save anything to disk, it just goes in a loop filling and dropping audio data. When you hit another button, that instant the application will start writing to disk , so not even one millisecond is lost.
However, I don't know of an equivalent for video encoders.
My advice would be to research and see if you can't actually do what you want with applications like Virtualdub or basically any standalone application that would record both things simultaneously.
BlockABoots
25th November 2015, 23:19
What about making a separate "stop" script? There's a function to close a window:
https://www.autoitscript.com/autoit3/docs/functions/WinKill.htm
Ok i have made a script....
WinClose("[CLASS:Qt5QWindowIcon]")
WinClose("[CLASS:#32770]")
which close the windows, but the video capture software has a confirmation window pop up to confirm that you want to close the program. I have tired to use Autoit Window info app, but it doesnt seem to bring any info up on the confirmation windows.
What script do i need to add to confirm the software closure?
LoRd_MuldeR
25th November 2015, 23:24
You can try WinKill() (https://www.autoitscript.com/autoit3/docs/functions/WinKill.htm), but forcefully terminating the program in that way may not be the safest solution.
What about calling WinClose() (https://www.autoitscript.com/autoit3/docs/functions/WinClose.htm) a second time to also close the "confirmation pop up" window? Or, what about using ControlClick() (https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm) to emulate a click on the "OK" button in the "confirmation pop up" window?
BlockABoots
25th November 2015, 23:47
You can try WinKill() (https://www.autoitscript.com/autoit3/docs/functions/WinKill.htm), but forcefully terminating the program in that way may not be the safest solution.
What about calling WinClose() (https://www.autoitscript.com/autoit3/docs/functions/WinClose.htm) a second time to also close the "confirmation pop up" window? Or, what about using ControlClick() (https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm) to emulate a click on the "OK" button in the "confirmation pop up" window?
Figured it out....
WinClose("[CLASS:Qt5QWindowIcon]")
WinActivate("[CLASS:Qt5QWindowIcon]")
send ("{space}")
WinClose("[CLASS:#32770]")
So basically had to use 'WinActivate" to refocus the software window again and then space bar to confirm the closure.
BlockABoots
25th November 2015, 23:50
No matter how hard you try, you'll never get them to record in sync. People use those clapper things (https://www.google.ro/search?q=clapper&source=lnms&tbm=isch&sa=X&ved=0CAcQ_AUoAWoVChMI4760o8udyQIVxy8PCh1tdA3Q&biw=2144&bih=1052&dpr=0.9) for this reason, the sound of the clapper is your cue to sync the audio to the actual video frame where the clapper closes completely, it makes it easy to sync a video with the external audio
My advice would be to research and see if you can't actually do what you want with applications like Virtualdub or basically any standalone application that would record both things simultaneously.
Yeah i understand that, but i can always sync it up in avisynth, i guess once i know the exact value to delay (or bring forward) the audio it should always be the same.
Does Virtualdub support 5.1 audio then?
BlockABoots
26th November 2015, 00:00
Ok, now a new issue.
The audio capture software saves the audio in a wav format, but when you record another clip it overwrites the previous .wav file, so basically the program doesnt have the ability to name the files different. I can see myself at somepoint forgetting to move the saved .wav file to a safe location and then starting another audio recording and losing the previous recording.
Does Autoit have the ability to move a file from one location to another??. If so in my 'stop capture' script i would want to add a line to tell it to move the just created .wav file to another location, is this possible at all?
raffriff42
26th November 2015, 00:27
Let me Google that for you:
https://www.google.com/search?q=Autoit+move+file
oh yes:
https://www.autoitscript.com/autoit3/docs/functions/FileMove.htm
BlockABoots
26th November 2015, 00:31
Ok so ive used script...
$firstpartofaddress = "C:/Users/*****/Desktop/XID_MultiAudioCapture.wav"
$lastpartofaddress = "c:/wav"
Filemove($firstpartofaddress, $lastpartofaddress)
which indeed does move the wav file, but it only seems to move it the first time, if theres a wav file already in c:\wav it wont move another file utill i delete the file in c:\wav
Ive seen a script that can move and rename a file to a time stamp format, but im a bit lost with it
foxyshadis
26th November 2015, 10:32
try:
$filename = "XID_MultiAudioCapture"
$ext = ".wav"
$firstpartofaddress = "C:/Users/*****/Desktop/" & $filename & $ext
$lastpartofaddress = "c:/wav/" & $filename & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & $ext
Filemove($firstpartofaddress, $lastpartofaddress)
BlockABoots
26th November 2015, 19:17
That worked, thanks!!
One final thing is it possible to add a dot between each value and a space between the date and time, for example..
2015.11.26 18.15.23
StainlessS
26th November 2015, 20:41
Try eg
@YEAR & "." & @MON
to insert "." between year and month, similar for rest.
BlockABoots
26th November 2015, 21:18
Nah that just gave me a script error
raffriff42
26th November 2015, 21:34
StainlessS' suggestion was correct. Please post your script and the exact error message.
StainlessS
26th November 2015, 22:05
for each eg
@YEAR & @MON
replace with
@YEAR & "." & @MON
ie insert stuff in BLUE
BlockaBoots, do insertions ONE-AT-A-TIME, so you know where to look for a problem.
BlockABoots
26th November 2015, 22:25
Ah sorry, didnt notice the '&' in your first post.
All working now, thanks for your help
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.