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'.