Runwait comspec problem escaping characters

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kakashi524
Posts: 2
Joined: 18 Dec 2016, 20:47

Runwait comspec problem escaping characters

03 Nov 2018, 22:58

It's been a while since I've been back, mostly because I haven't been scripting much. But now I find myself trying to convert quite a few movies and I finally decided to script a process to save some time. The problem I find myself in, is that I try to do the conversion using FFMPEG but I get errors while trying to run the commands using RUNWAIT and COMSPEC.

The line of code that's giving me a hard time is:

Code: Select all

audioLn:=RunWait %comspec% /c ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "F:\Audio.mp3"
The code outside of AHK is:

Code: Select all

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "F:\Audio.mp3"
What this code do is retrieve the Length of a media file in seconds, and store it in the audioLn variable. For example 1253.78. I need that number so I can either straight mux the video and audio OR, if needed, stretch or shrink the audio to match the video length.

I either get errors at the : or at the =1

I tried to use ":" but the I get error at =1, if I try "=1" I still get errors. How do I escape those characters or is there any other way to run that code and get the time?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Runwait comspec problem escaping characters

04 Nov 2018, 06:45

Code: Select all

CMD = %A_ComSpec% /q /c ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "F:\Audio.mp3"
MsgBox % ComObjCreate("WScript.Shell").Exec(CMD).StdOut.ReadAll()
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: Runwait comspec problem escaping characters

04 Nov 2018, 08:27

Hi,

that does the trick:

Code: Select all


; ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "F:\Audio.mp3"

shellstring:="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 " chr(34) "F:\Audio.mp3" chr(34)
run, %comspec% /c %shellstring%,,hide
Debug that "shellstring", than you see whats in there...

J.B.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
kakashi524
Posts: 2
Joined: 18 Dec 2016, 20:47

Re: Runwait comspec problem escaping characters

04 Nov 2018, 18:08

Thanks for the quick replies to my cry for help:

@Jovannb, I tried your approach and it does not cause any error, but it didn't work for me. Maybe I made a mistake somewhere along the way. I would still like to thank you for taking your time.
@swagfag, I adapted your code and it worked, thanks.

Code: Select all

audioLn = %A_ComSpec% /q /c ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "%audio%"
audioLn := ComObjCreate("WScript.Shell").Exec(audioLn).StdOut.ReadAll()

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb and 400 guests