Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFProbe won't output result to a file

Tags:

vb6

ffprobe

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

like image 714
Duke Avatar asked Nov 20 '25 15:11

Duke


1 Answers

Somewhat similar problem with ffprobe in Linux for me. I found that ffprobe doesn't write to standard output but instead to standard error. So, use the "2>" syntax to capture standard error to a file.

# ffprobe test.mkv 2>target.txt
# cat target.txt
Input #0, matroska,webm, from 'test.mkv':
  Metadata:
    COMPATIBLE_BRANDS: iso6avc1mp41
...
like image 121
Otho Avatar answered Nov 23 '25 06:11

Otho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!