I am trying to extract the duration of a video (.MP4) using FFProbe and require that the result be output to a file. FFProbe works perfectly and creates the file with the duration information when I enter it using the Command Prompt, however, when I place the same statement in my VB6 program, FFProbe does not create the output file..... What is the problem??
Here is the statement that works from the Command Prompt:
C:\Program Files\FFMpeg\bin>ffprobe -i InputVideo.mp4 -v quiet -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 > c:\temp\Output.txt
Here is the code snippet from my program that does not work:
Dim Txt As String
Dim AppId As Long
Dim AppHnd As Long
Dim AppRet As Long
Txt = "C:\Program Files\FFMpeg\bin>ffprobe" & _
" -i " & """" & PhotoPathFileName & """" & _
" -v quiet -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 >
""C:\temp\Output.txt"""
AppId = Shell(Txt, vbHide)
AppHnd = OpenProcess(SYNCHRONIZE, 0, AppId)
If AppHnd <> 0 Then
AppRet = WaitForSingleObject(AppHnd, WaitInfinite)
End If
We are making progress upon the suggestion from "wqw" to use cmd /c , I now get the output redirected to a file but not all the time.
This works because the video file name has no spaces:
cmd /k "C:\Program Files\FFMpeg\bin\ffprobe.exe" -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -i \\DLINK\Volume_1\Movies\Arrow.mp4 > c:\temp\Duration.txt
This does NOT work:
cmd /k "C:\Program Files\FFMpeg\bin\ffprobe.exe" -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -i \\DLINK\Volume_1\Movies\Generation Earth Part 1.mp4 > c:\temp\Duration.txt
It appears that cmd /c has some problems handling spaces in file name even if I surround them with double quotes. Also UNC filenames are not supported by cmd but ffprobe handles them OK. Still working on the problem, Thank you.
Ok, I got it working finally. Using cmd /c I found that if you changed to the directory of ffprobe first, then executed ffprobe, the mishandling of double quotes is avoided:
cmd /c cd C:\Program Files\FFMpeg\Bin & ffprobe {paramters} > output.txt