叠加 2 个视频输出到 1 帧图像仅适用于其中一个视频作为主视频

叠加 2 个视频输出到 1 帧图像仅适用于其中一个视频作为主视频

我有两个类似的覆盖过滤器用法,使用两个视频作为输入,如果一个视频是主视频,它就可以工作,如果另一个视频是主视频,则覆盖会被隐藏。

表达式一:

ffmpeg.exe  -v error -stats -ss 0.40 -i "GH010161.MP4"  -ss 0.4 -i "GH010165.MP4" -vframes 1 -filter_complex "[1] scale=400:400 [a];[0] scale=200:200[b];[a][b] overlay=10:10"  -y OutFrame_e1.jpg

表达式二(切换了输入文件,因此它是顶部的另一个):

ffmpeg.exe  -v error -stats -ss 0.40 -i "GH010165.MP4"  -ss 0.4 -i "GH010161.MP4" -vframes 1 -filter_complex "[1] scale=400:400 [a];[0] scale=200:200[b];[a][b] overlay=10:10"  -y OutFrame_e2.jpg

如果我切换过滤器表达式也没有关系,因为只有视频1GH010165.MP4才能在后台/主屏幕上显示。

如果我生成完整视频输出(即 MP4),则两者都可以工作,因此只有在制作帧图像时才会出现问题。

我相信它与值有某种联系-ss,但两个视频都可以使用该时间码分别生成一帧。如果我删除 for -ssGH010161.MP4它也会起作用。

有什么想法可以解决它吗?

以下是完整报告(不含)-v error

C:\Users\mmo21\Videos\ffmpeg.exe -ss 0.20 -i "C:\Users\mmo21\Videos\GPRo\GH010161.MP4" -ss 0.20 -i "C:\Users\mmo21\Videos\GPRo\GH010171.MP4" -vframes 1 -filter_complex "[1]scale=400:trunc((400 / iw) * (ih / 2))*2[over];[0][over] overlay =10:10" -y C:\Users\mmo21\Videos\OutFrame.jpg
ffmpeg version N-83657-g7e4f32f Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 47.100 / 55. 47.100
  libavcodec     57. 81.100 / 57. 81.100
  libavformat    57. 66.102 / 57. 66.102
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 74.100 /  6. 74.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\mmo21\Videos\GPRo\GH010161.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2020-07-21T18:06:22.000000Z
    firmware        : H18.02.02.10.00
  Duration: 00:08:22.40, start: 0.000000, bitrate: 40186 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1440 [SAR 1:1 DAR 4:3], 40006 kb/s, 49.99 fps, 50 tbr, 90k tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2020-07-21T18:06:22.000000Z
      handler_name    : GoPro AVC
      encoder         : GoPro AVC encoder
      timecode        : 18:06:22:35
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2020-07-21T18:06:22.000000Z
      handler_name    : GoPro AAC
      timecode        : 18:06:22:35
    Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2020-07-21T18:06:22.000000Z
      handler_name    : GoPro TCD
      timecode        : 18:06:22:35
    Stream #0:3(eng): Data: none (gpmd / 0x646D7067), 28 kb/s (default)
    Metadata:
      creation_time   : 2020-07-21T18:06:22.000000Z
      handler_name    : GoPro MET
    Stream #0:4(eng): Data: none (fdsc / 0x63736466), 12 kb/s (default)
    Metadata:
      creation_time   : 2020-07-21T18:06:22.000000Z
      handler_name    : GoPro SOS
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\mmo21\Videos\GPRo\GH010171.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2020-07-29T12:16:22.000000Z
    firmware        : H18.02.02.10.00
  Duration: 00:01:24.20, start: 0.000000, bitrate: 30154 kb/s
    Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1440 [SAR 1:1 DAR 4:3], 30005 kb/s, 25 fps, 25 tbr, 90k tbn, 48 tbc (default)
    Metadata:
      creation_time   : 2020-07-29T12:16:22.000000Z
      handler_name    : GoPro AVC
      encoder         : GoPro AVC encoder
      timecode        : 12:16:22:16
    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2020-07-29T12:16:22.000000Z
      handler_name    : GoPro AAC
      timecode        : 12:16:22:16
    Stream #1:2(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2020-07-29T12:16:22.000000Z
      handler_name    : GoPro TCD
      timecode        : 12:16:22:16
    Stream #1:3(eng): Data: none (gpmd / 0x646D7067), 28 kb/s (default)
    Metadata:
      creation_time   : 2020-07-29T12:16:22.000000Z
      handler_name    : GoPro MET
    Stream #1:4(eng): Data: none (fdsc / 0x63736466), 9 kb/s (default)
    Metadata:
      creation_time   : 2020-07-29T12:16:22.000000Z
      handler_name    : GoPro SOS
[swscaler @ 00000000021fb6a0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'C:\Users\mmo21\Videos\OutFrame.jpg':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    firmware        : H18.02.02.10.00
    encoder         : Lavf57.66.102
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 1920x1440 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 50 fps, 50 tbn, 50 tbc (default)
    Metadata:
      encoder         : Lavc57.81.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 (h264) -> overlay:main
  Stream #1:0 (h264) -> scale
  overlay -> Stream #0:0 (mjpeg)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=8.4 Lsize=N/A time=00:00:00.02 bitrate=N/A speed=0.0761x
video:161kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

OutFrame_e1.jpg
外框_e1.jpg

OutFrame_e2.jpg
OutFrame_e2.jpg

答案1

似乎有必要将两个视频渲染为相同的帧速率。我认为 -ss 参数在某种程度上不稳定,并且并非总是能够根据 -ss 值生成帧图像。如果帧速率相同,上述示例将有效。

相关内容