我正在尝试使用 powershell 和 ffmpeg 工具自动进行视频转换。如果在没有所有必要参数的情况下调用 Ffmpeg,则会有关于视频的详细输出。通常它会报告错误并在指定时显示输入文件信息。例如,我交互式地执行了这样的命令:
d:\video.Enc\ffmpeg.exe -id:\video.Enc\1.wmv
这是powershell控制台输出
ffmpeg.exe : FFmpeg version SVN-r20428, Copyright (c) 2000-2009 Fabrice Bellard, et al.
row:1 char:24
+ d:\video.Enc\ffmpeg.exe <<<< -i d:\video.Enc\1.wmv
+ CategoryInfo : NotSpecified: (FFmpeg version ...Bel
lard, et al.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
built on Nov 1 2009 04:03:50 with gcc 4.2.4
configuration: --enable-memalign-hack --prefix=/mingw --cross-pre
fix=i686-mingw32- --cc=ccache-i686-mingw32-gcc --target-os=mingw32
--arch=i686 --cpu=i686 --enable-avisynth --enable-gpl --enable-vers
ion3 --enable-zlib --enable-bzlib --enable-libgsm --enable-libfaad
--enable-pthreads --enable-libvorbis --enable-libtheora --enable-li
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
libavformat 52.39. 2 / 52.39. 2
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0. 7. 1 / 0. 7. 1
[wmv3 @ 0x144dc00]Extra data: 8 bits left, value: 0
Seems stream 1 codec frame rate differs from container frame rate:
1000.00 (1000/1) -> 15.00 (15/1)
Input #0, asf, from 'd:\video.Enc\1.wmv':
Duration: 00:12:0
2.00, start: 5.000000, bitrate: 197 kb/s
Stream #0.0(eng): Audio: wmav2, 44100 Hz, 1 channels, s16, 48 k
b/s
Stream #0.1(eng): Video: wmv3, yuv420p, 1024x768, 137 kb/s, 15 tbr, 1k tbn, 1k tbc Metadata
title : Silverlight 2.0 Hello World Application
author : Sergey Pugachev
copyright :
comment :
WMFSDKVersion : 11.0.6001.7000
WMFSDKNeeded : 0.0.0.0000
IsVBR : 1
ASFLeakyBucketPairs:
VBR Peak : 715351
Buffer Average : 127036
At least one output file must be specified
但我不知道如何编写脚本并将输出捕获到任何类型的豪华对象。我尝试了直接脚本,其中 ps1 文件包含精确表达式“d:\video.Enc\ffmpeg.exe -id:\video.Enc\1.wmv” - 它不起作用。我也尝试使用调用命令和调用表达式来做到这一点。第一个返回一个带有命令的精确字符串,第二个 - 将错误转储到输出控制台,但没有转储到我指定的 -ErrorVariable (我确实设置了所有变量,不仅是错误一个 - 它们都是空的)。
谁能指出在豪华中调用控制台应用程序和捕获输出的正确语法?
第二个问题是关于解析该输出 - 我需要视频分辨率数据来计算正确的宽高比以进行转换。因此,如果有人指出如何处理捕获的错误输出并解析字符串,那就太酷了
流#0.1(eng):视频:wmv3,yuv420p,1024x768,