ffmpeg - 如何从输入->输出不变地传递所有流 audio/tmcd 等

ffmpeg - how to pass all streams audio/tmcd, etc from input->output unchanged

请帮助我,希望将特定的 ffmpeg 参数包含在我的视频编码中。

我的工作只与视频流有关,所以这是我要更改的唯一一个。 我收到一个已经为特定广播公司预编译的 .mov 文件,其中一些自包含视频有 4 个流(1 个视频、2 个音频和一些其他时间码流)。其他最多17个流:1个视频,15个音频流,最后一个是不支持的tmcd。

我的处理管道包括 仅 re-encoding/re-processing 视频 流,以及我需要传递到输出文件的所有其他流 - 所有其他流都没有任何更改或变更。

在这个编码步骤中,我将 icon.png 从第 2-3、4-5 和 6-8 插入位置 5:21。为此,我使用了 map 选项,因此我的编码字符串如下所示:

ffmpeg -i in.mov -i icon.png -i icon.png -i icon.png
    -filter_complex "  [0][1]overlay=5:21:enable='between(t,2,3)'[v1];
                      [v1][2]overlay=5:21:enable='between(t,4,5)'[v2];
                      [v2][3]overlay=5:21:enable='between(t,6,8)'[v3]" -map '[v3]' -map 0:a
    -c:v dvvideo -pix_fmt yuv422p -b:v 115084915 -maxrate 115084915 -minrate 115084915 -r 29.97 -top 1 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -vtag dvh6
    -c:a copy -c:s copy -y out.mov

问题是 out.mov 只显示 2 个流而不是 17 个(1 个视频和 2 个音频)。所有其他 15 个流都被完全截断。 阅读其他一些 Whosebug 帖子后,我找到了一种传输所有其他流的方法,即使用 -map 0:

但是当我尝试在最后一行添加 -map 0 时:

    ...
    -map 0 -c:a copy -c:s copy -y out.mov

但这会使流的数量从 17 增加一倍到 34 - 输出文件大小也会增加一倍。 如果我从原始编码字符串中删除 map '[v3]' -map 0:a 并且只包含 -map 0,我会得到正确的流数,但是,当然 icon.png 没有在正确的时间插入。我该怎么办?

是否有办法在不使用此 -map 选项的情况下重新映射我的 -filter_complex 以覆盖图像?或者,具体说明每个 -map 指的是什么?

如果没有,我还可以使用什么 arguments/parameters 来复制所有流、潜艇和所有其他音频,如果存在的话,可能还有一些其他音频损伤信号。

请帮忙,这样我才能最终包装我的输出并提交我的作品。

编辑 1: 这是我的输出:

ffprobe version N-99345-g904ab5365c Copyright (c) 2007-2020 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --enable-filter=qrrabbit --enable-opengl --enable-gpl --enable-libx264 --extra-libs='-lqrencode -lpthread'
  libavutil      56. 59.100 / 56. 59.100
  libavcodec     58.106.100 / 58.106.100
  libavformat    58. 58.100 / 58. 58.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 2020-02-29T22:07:42.000000Z
    encoder         : Lavf58.58.100
  Duration: 00:00:20.05, start: 0.000000, bitrate: 133544 kb/s
    Stream #0:0: Video: dvvideo (dvh6 / 0x36687664), yuv422p(bt709, top first), 1280x1080 [SAR 3:2 DAR 16:9], 115084 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 29.97 tbc (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : VideoHandler
      encoder         : Lavc58.106.100 dvvideo
      timecode        : 00:00:00;00
    Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:4(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:5(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:6(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:7(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:8(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:9(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:10(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:11(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:12(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:13(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:14(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:15(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:16(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:17(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : VideoHandler
      timecode        : 00:00:00;00
Unsupported codec with id 0 for input stream 17

这是来自输入文件的 ffprobe:

ffprobe version N-99345-g904ab5365c Copyright (c) 2007-2020 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --enable-filter=qrrabbit --enable-opengl --enable-gpl --enable-libx264 --extra-libs='-lqrencode -lpthread'
  libavutil      56. 59.100 / 56. 59.100
  libavcodec     58.106.100 / 58.106.100
  libavformat    58. 58.100 / 58. 58.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2020-02-29T22:07:42.000000Z
  Duration: 00:00:20.05, start: 0.000000, bitrate: 133935 kb/s
    Stream #0:0(eng): Video: dvvideo (dvh6 / 0x36687664), yuv422p(bt709, top coded first (swapped)), 1280x1080 [SAR 3:2 DAR 16:9], 115084 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Video Media Handler
      encoder         : DVCPRO HD 1080i60
      timecode        : 00:00:00;00
    Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:4(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:5(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:6(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:7(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:8(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:9(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:10(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:11(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:12(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:13(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:14(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:15(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:16(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Apple Sound Media Handler
      timecode        : 00:00:00;00
    Stream #0:17(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2020-02-29T22:07:42.000000Z
      handler_name    : Time Code Media Handler
      timecode        : 00:00:00;00
Unsupported codec with id 0 for input stream 17

有条件地映射所有 non-video 流(即如果存在则包含)。复杂过滤图的输出会自动映射到第一个输出,因此不需要手动映射。复制除视频以外的所有流。您可以对多个时间范围使用单个覆盖实例。

ffmpeg -i in.mov -i icon.png -filter_complex "[0][1]overlay=5:21:enable='between(t,2,3)+between(t,4,5)+between(t,6,8)'" -map 0:a? -map 0:s? -pix_fmt yuv422p -r 30000/1001 -c copy -c:v dvvideo -b:v 115084915 -maxrate 115084915 -minrate 115084915 -top 1 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -vtag dvh6 -y out.mov