3

我正在运行以获取有关...avprobe中的视频的流信息JSON

avprobe -loglevel quiet -show_format -show_streams file.m4v -of json

这基本上与ffprobeor完全相同ffmpeg -i(并且我得到相同的错误。)

ffprobe -loglevel quiet -show_format -show_streams file.m4v -print_format json

该命令大部分时间都有效......但是,有时我会有一个视频,其中有一个“不受支持”的奇怪流,我会得到这样的东西(缩写。)

Unsupported codec with id 94213 for input stream 2
{  "format" : {
    "filename" : "file.m4v",
    "nb_streams" : 3,
    "format_name" : "mov,mp4,m4a,3gp,3g2,mj2" ...

当我运行命令时,我返回JSON+ 中的错误plain text,这使结果无效JSON,我必须稍后“清理”它。

我正在抑制输出中的错误,-loglevel quiet但错误仍然出现。

我如何告诉avprobe/ffprobe不显示此错误并因此取回正确的JSON对象?


更长的输出示例

ffprobe, 来自源代码, MacOS

ffprobe version 0.9.1-subsplash, Copyright (c) 2007-2012 the FFmpeg developers
  built on Feb  5 2012 01:35:36 with gcc 4.2.1 (Apple Inc. build 5664)
  configuration: --prefix=/Volumes/Ramdisk/sw --as=yasm --extra-version=subsplash --disable-shared --enable-static --disable-ffplay --disable-ffserver --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libfaac --enable-libvorbis --enable-libtheora --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --arch=x86_64 --enable-runtime-cpudetect --enable-nonfree
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 42. 4 / 53. 42. 4
  libavformat  53. 24. 2 / 53. 24. 2
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 53. 0 /  2. 53. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file.m4v':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2012-01-01 06:38:43
    encoder         : HandBrake 0.9.5 2011010300
  Duration: 00:30:47.53, start: 0.000000, bitrate: 1558 kb/s
    Chapter #0.0: start -0.066733, end 17.784433
    Metadata:
      title           : Chapter  1

...

    Stream #0:2(und): Subtitle: mov_text (text / 0x74786574)
    Metadata:
      creation_time   : 2012-01-01 06:38:43
      handler_name    : 
Unsupported codec with id 94213 for input stream 2
{

...

avprobe,来自源代码,Ubuntu Linux

avprobe version 10_alpha1-6:10~~git20130307.4be368b-1~quantal1, Copyright (c) 2007-2013 the Libav developers
  built on Mar  7 2013 22:12:44 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file.m4v':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2012-01-01 06:38:43
    encoder         : HandBrake 0.9.5 2011010300
  Duration: 00:30:47.53, start: 0.000000, bitrate: 1558 kb/s
    Chapter #0.0: start -0.066733, end 17.784433
    Metadata:
      title           : Chapter  1

...

    Stream #0.2(und): Subtitle: text / 0x74786574
    Metadata:
      creation_time   : 2012-01-01 06:38:43
Unsupported codec with id 94213 for input stream 2
{

...
4

1 回答 1

0

您看到的是 STDOUT 和 STDERR 的输出。如果要过滤掉Unsupported codec with id 94213 for input stream 2,例如,可以通过在 bash 中将其重定向到 /dev/null 来过滤掉 STDERR 输出:

avprobe -loglevel quiet -show_format -show_streams file.m4v -of json 2>/dev/null

于 2018-04-19T03:42:07.303 回答