如何使用 ffmpeg 复制不受支持的数据流?

如何使用 ffmpeg 复制不受支持的数据流?

简报

我有一些 .wmv 文件(实际上,我的完整批处理文件处理多种文件类型),其中有奇怪的数据流,需要外部程序才能识别它们。

我正在尝试删除每个非数据或音频的流,这些流也需要重新编码。

我当前的命令是

fmpeg -y -loglevel debug -flags global_header -err_detect ignore_err -fflags +igndts -copy_unknown -i "%%~fV" -f !ext! -c copy -map 0 -vn -sn -b:a 32k "%%~pnxV.tmpoutput"

它适用于具有相同数据流类型的其他文件类型,如果我添加,它将适用于 .wmv -dn(即使我的文件无法被外部程序识别)。上面的命令,对于 .wmv 文件,将输出错误Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted

从 FFprobe(下面是完整输出)中,我可以看到消息Unsupported codec with id 0 for input stream 2,因此我相信毫无疑问原因确实是数据流。


问题

问题是我本想-copy_unknown处理这个问题,但事实并非如此。我的问题是:如何复制这个不受支持、未在其他地方使用的数据流?还有其他方法可以解决这个问题吗?

谢谢


额外信息

完整的 FFmpeg 输出(带有-loglevel debug):

ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-flags' ... matched as AVOption 'flags' with argument 'global_header'.
Reading option '-err_detect' ...Routing option err_detect to both codec and muxer layer
 matched as AVOption 'err_detect' with argument 'ignore_err'.
Reading option '-fflags' ... matched as AVOption 'fflags' with argument '+igndts'.
Reading option '-copy_unknown' ... matched as option 'copy_unknown' (Copy unknown stream types) with argument '1'.
Reading option '-i' ... matched as input url with argument 'C:\Users\Fabio\Desktop\Testes\test\a.wmv'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'asf'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0'.
Reading option '-vn' ... matched as option 'vn' (disable video) with argument '1'.
Reading option '-sn' ... matched as option 'sn' (disable subtitle) with argument '1'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '32k'.
Reading option '\Users\Fabio\Desktop\Testes\test\a.wmv.tmpoutput' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option copy_unknown (Copy unknown stream types) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url C:\Users\Fabio\Desktop\Testes\test\a.wmv.
Successfully parsed a group of options.
Opening an input file: C:\Users\Fabio\Desktop\Testes\test\a.wmv.
[NULL @ 0000025955e7af40] Opening 'C:\Users\Fabio\Desktop\Testes\test\a.wmv' for reading
[file @ 0000025955e7b740] Setting default whitelist 'file,crypto'
[asf @ 0000025955e7af40] Format asf probed with size=2048 and score=100
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=244
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=26
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=3295
[asf @ 0000025955e7af40] Payload extension 50 2
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=42
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=44
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=834
[asf @ 0000025955e7af40] Before avformat_find_stream_info() pos: 5793 bytes read:32768 seeks:0 nb_streams:3
[asf @ 0000025955e7af40] parser not found for codec wmav2, packets or times may be invalid.
[wmv3 @ 0000025955eb4480] Header: 46690A01
[wmv3 @ 0000025955eb4480] Profile 1:
frmrtq_postproc=3, bitrtq_postproc=6
LoopFilter=1, MultiRes=0, FastUVMC=0, Extended MV=0
Rangered=0, VSTransform=1, Overlap=1, SyncMarker=0
DQuant=0, Quantizer mode=0, Max B-frames=0
[wmv3 @ 0000025955eb4480] Extra data: 8 bits left, value: 0
[wmv3 @ 0000025955eb4480] Format yuv420p chosen by get_format().
    Last message repeated 1 times
[asf @ 0000025955e7af40] parser not found for codec wmav2, packets or times may be invalid.
[asf @ 0000025955e7af40] All info found
[asf @ 0000025955e7af40] After avformat_find_stream_info() pos: 191671 bytes read:196608 seeks:0 frames:58
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from 'C:\Users\Fabio\Desktop\Testes\test\a.wmv':
  Metadata:
    copyright       : ChessBase GmbH
    WMFSDKVersion   : 12.0.9600.17415
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    DeviceConformanceTemplate: MP@ML
  Duration: 00:00:23.08, start: 0.000000, bitrate: 526 kb/s
    Stream #0:0, 17, 1/1000: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, stereo, fltp, 96 kb/s
    Stream #0:1, 41, 1/1000: Video: wmv3 (Main), 1 reference frame (WMV3 / 0x33564D57), yuv420p(left), 640x480, 0/1, 415 kb/s, 25 tbr, 1k tbn, 1k tbc
    Stream #0:2, 0, 1/1000: Data: none, 0/1, 10 kb/s
Successfully opened the file.
Parsing a group of options: output url \Users\Fabio\Desktop\Testes\test\a.wmv.tmpoutput.
Applying option f (force format) with argument asf.
Applying option c (codec name) with argument copy.
Applying option map (set input stream mapping) with argument 0.
Applying option vn (disable video) with argument 1.
Applying option sn (disable subtitle) with argument 1.
Applying option b:a (video bitrate (please use -b:v)) with argument 32k.
Successfully parsed a group of options.
Opening an output file: \Users\Fabio\Desktop\Testes\test\a.wmv.tmpoutput.
[file @ 0000025955eee200] Setting default whitelist 'file,crypto'
Successfully opened the file.
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
    Last message repeated 1 times
[AVIOContext @ 0000025955eee2c0] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 0000025955e83980] Statistics: 196608 bytes read, 0 seeks

FFprobe 在示例文件上:

ffprobe version 4.3 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200621
  configuration: --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-libopenmpt --enable-amf
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
[wmv3 @ 00000180012e1440] Extra data: 8 bits left, value: 0
Input #0, asf, from 'test/a.wmv':
  Metadata:

    WMFSDKVersion   : 12.0.9600.17415
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    DeviceConformanceTemplate: MP@ML
  Duration: 00:00:23.08, start: 0.000000, bitrate: 526 kb/s
    Stream #0:0: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, 2 channels, fltp, 96 kb/s
    Stream #0:1: Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 415 kb/s, 25 tbr, 1k tbn, 1k tbc
    Stream #0:2: Data: none, 10 kb/s
[wmv3 @ 0000018001324a80] Extra data: 8 bits left, value: 0
Unsupported codec with id 0 for input stream 2

其他

我选择指定-f.tmpoutput促进我的流程的其他不相关部分。

答案1

尝试:

  • 将 ffmpeg 更新到最新版本。
  • 将扩展名告知.wmvffmpeg中的输出文件。
  • mkvtoolnix将文件重新混合到.mkv支持所有内容的新容器中。

相关内容