使用C#代码中的ffprobe获取视频文件中的帧数

时间:2014-02-24 10:33:21

标签: c# count ffmpeg frame ffprobe

我可以使用命令提示符下的Ffprobe使用以下命令在test.mp4中成功读取framres的数量:

>ffprobe -i 'c://test.mp4' -show_frames | find /c 'pict_type'

但是当我尝试使用以下参数从C#代码运行'ffprobe.exe'时:

string params = " -i 'c://test.mp4' -show_frames | find /c 'pict_type'";

错误如下:

ffprobe version N-59453-gd52882f Copyright (c) 2007-2013 the FFmpeg developers
  built on Dec 30 2013 22:07:23 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-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 59.100 / 52. 59.100
  libavcodec     55. 47.100 / 55. 47.100
  libavformat    55. 22.101 / 55. 22.101
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  0.103 /  4.  0.103
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Argument '|' provided as input filename, but ''c://test.mp4'' was already specified.

如何为C#修复此问题?

我知道有一种使用Ffmpeg的解决方法,但这种方式不够干净。

1 个答案:

答案 0 :(得分:0)

可能是因为C#控制台不支持管道或查找。我会考虑使用ffprobe输出的结果在C#中编写pict_type的查找实例。

  

string params =“ - i'c://test.mp4'-show_frames”;

类似的东西:

  

output.Count(x => x ==“pict_type”);