ffmpeg - ffprobe 或 avprobe 在 JSON 输出中返回纯文本错误

标签 ffmpeg ffprobe avconv avprobe

我正在运行 avprobe 来获取有关 JSON 格式的视频的流信息 ...

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

这基本上与 ffprobe 或 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 + 一个 纯文本 错误,这使得结果无效 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
{

...

最佳答案

您看到的是 STDOUT 和 STDERR 的输出。如果您想过滤掉输入流 2 的 Unsupported codec with id 94213,您可以通过将 STDERR 输出重定向到/dev/null 来过滤掉 STDERR 输出,如下所示,在 bash 中:

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

关于ffmpeg - ffprobe 或 avprobe 在 JSON 输出中返回纯文本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15914874/

相关文章:

bash - 使用 xargs 打印不良视频文件

python - 在 Python 中打印 subprocess.Popen() 输出

audio - 无法使用 sox、avconv 将特定的 .wav 文件转换为 mp3 或 m4a

ios - avconv - 根据元数据自动改变方向

ubuntu - 为什么我在使用 ffmpeg 时收到关于 '{localtime' 附近未终止的 %{} 的错误

video - 如何将文本流(字幕)添加到 .mp4 或 .m4v

image - FFMPEG - 将全帧图像添加到视频的开头

ffmpeg - ffprobe 两次返回视频流数据

xml - FFProbe XML XPath

video - 我可以从带时间戳的图像创建 VFR 视频吗?