Question

Okay guys looks like I have another question to ask, which is kind of related to my last question, which can be found on here: How to start ffprobe with Windows PowerShell. There I was asking how to start ffprobe with Windows PowerShell and after trying out a few things I got it, well lets say, started for a second before it closes again. I tried it with following commands in PowerShell:

$env:Path = ';C:\Users\Administrator\bin\'
$title = "A_Day_for_Cake_and_Accidents"
Start-Process ff-prompt.bat -ArgumentList "ffprobe -show_streams -select_streams v -print_format xml -count_frames C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov > C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml"

The result, and that is the strange thing, is the xml file with only the standard text from the ff-prompt.bat, which looks like this:

C:\Users\Administrator>ECHO OFF ffmpeg version N-60959-g669043d built on Feb 27 2014 22:01:58 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 66.100 / 52. 66.100 libavcodec 55. 52.102 / 55. 52.102 libavformat 55. 33.100 / 55. 33.100 libavdevice 55. 10.100 / 55. 10.100 libavfilter 4. 2.100 / 4. 2.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 For help run: ffmpeg -h For formats run: ffmpeg -formats | more For codecs run: ffmpeg -codecs | more Current directory is now: "C:\Users\Administrator\bin" The bin directory has been added to PATH

My first thought was, that it did not work at all, but then I was wondering why I get an XML file when it is not working at all. PowerShell executes the ff-prompt.bat for maybe a second, before PowerShell shuts down the ff-prompt.bat again without doing half of my commands. Does anybody know why ff-prompt gets closed before executing all of my commands?

EDIT: So what I tried is something that should execute it directly, but in fact I get a shitload of errors:

$title = "A_Day_for_Cake_and_Accidents"
$Cmd = ‘C:\Users\Administrator\ffmpeg\bin\ffprobe.exe’
$Arg1 = ’ffprobe '
$Arg2 = ‘-show_streams ’
$Arg3 = ‘-select_streams v '
$Arg4 = ‘-print_format xml '
$Arg5 = ‘-count_frames '
$Arg6 = "C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov >"
$Arg7 = " C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml"
& $Cmd $Arg1 $Arg2 $Arg3 $Arg4 $Arg5 $Arg6 $Arg7

Error message(s) I get:

"ffprobe.exe Failed to set value '-select_streams v ' for option 'show_streams ': Option not found"

The problem I am facing now is that -show_streams does not get a value, so maybe that is the reason why he uses the next parameter as a value, is there anything I can do?

Was it helpful?

Solution

The following worked for me:

$title = "A_Day_for_Cake_and_Accidents"
$inputFile = "C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov"
$outputFile = "C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml"

&.\bin\ffprobe.exe -show_streams -select_streams v -print_format xml -count_frames -loglevel quiet $inputFile | out-file $outputFile

I should have realised that '-select_streams v' counts a 2 command line parameters, so wrapping them up in a single argument will not work.

I removed the '>' redirection and added the | out-file .... clause.

The main issue with FFPROBE is that it writes it's logging information to the STDERR channel. PowerShell spots this and throws a NativeCommandError exception.

I tried trapping NativeCommandError, using $ErrorActionPreference = 'stop' and a try...catch construction, but the exception fires before the XML output is generated. In the end, I RTFM for FFPROBE and added the -loglevel quiet parameter which stops FFPROBE writing any log info.

NB - this code assumes it is executed from the directory above 'bin'.

OTHER TIPS

Assuming ffmpeg is in C:\users\Administrator\ffmpeg:

$title = "A_Day_for_Cake_and_Accidents"
& C:\users\Administrator\ffmpeg\bin\ffprobe -show_streams -select_streams v -print_format xml -count_frames C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov > C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top