Wednesday, 15 August 2012

powershell and console app output -


I'm trying to automate video conversion with powershell and ffmpeg tools. There is a detailed output about FFPAP video, if all the phone is called without the assignory parameter, this usually indicates the error and display input file information if I have specified the following command:

d: \ video.Enc \ ffmpeg.exe -id: \ video.Enc \ 1.wmv

This is PowerShear console output

  Ffmpeg.exe: FFMPAG Edition SVN-R20428, Copyright (c) 2000-2009 Fabrice Bailard, et al line: 1 Characters: 24 + D: \ video.Enc \ ffmpeg.exe & lt; & Lt; & Lt; & Lt; -id: \ video.Enc \ 1.wmv + CategoryInfo: NotSpecified: (FFmpeg version ... Bell lard, et al.:String) [], RemoteException + FullyQualifiedErrorId: NativeCommandError building on November 1, 2009, 04:03: 50 GCC 4.2.4 configuration with: --enable-memalign- hack prefix = / MinGW --cross- former right = i686-mingw32- --cc = ccache-i686-mingw32- GCC --target-os = mingw32 - Hardcore = i686 --cpu = i686 --enable-AviSynth --enable- GPL --enable-vers ion3 --enable-zlib --enable-bzlib --enable-libgsm --enable-libfaad --enable-pthreads - enable a libvorbis --enable-libtheora --enable- Lee bspeex --enable-libmp3lame --enable-libopenjpeg --enable-libxvid - Enable libschroedinger --enable-libx264 --enable-libopencore_amrwb --enable-libopencore_amrnb Libavutil 50 3. 0 / 50. 3. 0 libavcodec 52.37. 1 / 52.37 1 LIBFFORMAT 52.39 2 / 52.39 2 libavdevice 52. 2. 0 / 52. 2. 0 libswscale 0. 7. 1 / 0. 7. 1 [wmv3 @ 0x144dc00] Additional Data: 8 bits left, value: 0 Stream 1 codec frame rate is different from container frame Rate: 1000.00 (1000/1) - & gt; 15.00 (15/1) '# D: \ Video from the # 0, ASF; N.C. 1.WMV': Duration: 00: 12: 0 2.00, Start: 5.000000, Bitrate: 197 KB / s Stream # 0.0 ( England): Audio: wmav2, 44100 Hz, 1 channel, s16, 48 kb / s stream # 0.1 (England): Video: wmv3, yuv420p, 1024x768, 137 kb / s, 15 TBR, 1k TBN, 1k TBC metadata Title: Silverlight 2.0 Hello World application author: Sergei Pugchev Copyright: comment: WMFSDKVersion: 11.0.6001.7000 WMFSDKNeeded: 0.0.0.0000 IsVBR: 1 ASFLeakyBucketPairs: VBR peak: 715,351 buffer average: 127,036 at the least specify an output file Or should  

But I can not virtual to capture the output of any kind of how this script and posh objects. I tried straightforward script, wher ps1 file contains the exact expression "d: \ video.Enc \ ffmpeg.exe -i d: \ video.Enc \ 1.wmv" - it did not work. Apart from this, I tried to do it with the avoc command and called for expression. First returns a precise string with one command, the other one - the dump error is not specified in the output console, but for the -rearvivalable (I have set all the variables, not only an error - all of them empty Were).

Can I suggest using a console application in posh and correcting any syntax to capture output?

The second question will be about parsing that output - to calculate the right aspect ratio for conversion, I need video resolution data so it would be good if any capture error output and pars String like

Stream # 0.1 (Impo): Video: how to work with wmv3, yuv420p, 1024x768 ,

redirect the error stream as stdout Try and then you should be able to capture both stdout and stderr in a variable such as:

  $ res = d: \ video.Enc \ ffmpeg.exe -id: \ video Enc \ 1.wmv 2 & gt; And 1  

Try to capture data:

  $ res | Selection-string '(? IMS) ^ stream. * (\ D {3,4} x \ d {3,4}) '-All | % {$ _. Matches} | % {$ _ Groups [1]. Value}  

I'm not sure that $ res will be a string or multiple, but the above version should work for both cases.


No comments:

Post a Comment