测试文件

测试文件

示例视频:https://youtu.be/Ib_CxhxOpxI

我正在使用以下命令:

ffmpeg -i GX014186.MP4 -i GX014187.MP4 -i GX024187.MP4 -i GX034187.MP4 -i GX044187.MP4 -i GX054187.MP4 -i GX064187.MP4 -i scaled.png -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a][3:v][3:a][4:v][4:a]concat=n=5:v=1:a=1[vv][a];[vv]overlay=main_w-overlay_w-5:main_h-overlay_h-5[v]" -map "[v]" -map "[a]" output.mp4

此命令适用于之前的视频。但这周的视频似乎将所有视频合并为一个。

也就是说,您可以在视频的边框上看到所有视频都是层叠在一起的。

因此,看起来好像只有一个视频已渲染,但实际上所有视频都已渲染,只是采用了奇怪的分层系统。

hutber@hutber:~/Videos$ ./concat.sh 
Please select folder:
1) mlt/       3) Week 2/   5) Week 4/   7) Week 6/   9) Week 8/
2) VLC/       4) Week 3/   6) Week 5/   8) Week 7/  10) Week 9/
#? 8
ffmpeg version N-49161-g50e194e6e1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.101 / 58. 28.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'GX014183.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2016-08-25T23:17:34.000000Z
    firmware        : HD6.01.01.60.00
  Duration: 00:08:03.50, start: 0.000000, bitrate: 66226 kb/s
    Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 65937 kb/s, 239.76 fps, 239.76 tbr, 240k tbn, 239.76 tbc (default)
    Metadata:
      creation_time   : 2016-08-25T23:17:34.000000Z
      handler_name    : GoPro H.265
      encoder         : GoPro H.265 encoder
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:17:34.000000Z
      handler_name    : GoPro AAC  
    Stream #0:2(eng): Data: bin_data (gpmd / 0x646D7067), 33 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:17:34.000000Z
      handler_name    : GoPro MET  
    Stream #0:3(eng): Data: none (fdsc / 0x63736466), 36 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:17:34.000000Z
      handler_name    : GoPro SOS  
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'GX024183.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2016-08-25T23:25:38.000000Z
    firmware        : HD6.01.01.60.00
  Duration: 00:08:03.48, start: 0.000000, bitrate: 66233 kb/s
    Stream #1:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 65936 kb/s, 239.76 fps, 239.76 tbr, 240k tbn, 239.76 tbc (default)
    Metadata:
      creation_time   : 2016-08-25T23:25:38.000000Z
      handler_name    : GoPro H.265
      encoder         : GoPro H.265 encoder
    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:25:38.000000Z
      handler_name    : GoPro AAC  
    Stream #1:2(eng): Data: bin_data (gpmd / 0x646D7067), 33 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:25:38.000000Z
      handler_name    : GoPro MET  
    Stream #1:3(eng): Data: none (fdsc / 0x63736466), 36 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:25:38.000000Z
      handler_name    : GoPro SOS  
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'GX034183.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2016-08-25T23:33:41.000000Z
    firmware        : HD6.01.01.60.00
  Duration: 00:08:03.48, start: 0.000000, bitrate: 66218 kb/s
    Stream #2:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 65921 kb/s, 239.76 fps, 239.76 tbr, 240k tbn, 239.76 tbc (default)
    Metadata:
      creation_time   : 2016-08-25T23:33:41.000000Z
      handler_name    : GoPro H.265
      encoder         : GoPro H.265 encoder
    Stream #2:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:33:41.000000Z
      handler_name    : GoPro AAC  
    Stream #2:2(eng): Data: bin_data (gpmd / 0x646D7067), 33 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:33:41.000000Z
      handler_name    : GoPro MET  
    Stream #2:3(eng): Data: none (fdsc / 0x63736466), 36 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:33:41.000000Z
      handler_name    : GoPro SOS  
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from 'GX044183.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2016-08-25T23:41:45.000000Z
    firmware        : HD6.01.01.60.00
  Duration: 00:08:03.50, start: 0.000000, bitrate: 66220 kb/s
    Stream #3:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 65926 kb/s, 239.76 fps, 239.76 tbr, 240k tbn, 239.76 tbc (default)
    Metadata:
      creation_time   : 2016-08-25T23:41:45.000000Z
      handler_name    : GoPro H.265
      encoder         : GoPro H.265 encoder
    Stream #3:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:41:45.000000Z
      handler_name    : GoPro AAC  
    Stream #3:2(eng): Data: bin_data (gpmd / 0x646D7067), 33 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:41:45.000000Z
      handler_name    : GoPro MET  
    Stream #3:3(eng): Data: none (fdsc / 0x63736466), 36 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:41:45.000000Z
      handler_name    : GoPro SOS  
Input #4, mov,mp4,m4a,3gp,3g2,mj2, from 'GX054183.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2016-08-25T23:49:48.000000Z
    firmware        : HD6.01.01.60.00
  Duration: 00:08:03.48, start: 0.000000, bitrate: 66199 kb/s
    Stream #4:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 65902 kb/s, 239.76 fps, 239.76 tbr, 240k tbn, 239.76 tbc (default)
    Metadata:
      creation_time   : 2016-08-25T23:49:48.000000Z
      handler_name    : GoPro H.265
      encoder         : GoPro H.265 encoder
    Stream #4:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:49:48.000000Z
      handler_name    : GoPro AAC  
    Stream #4:2(eng): Data: bin_data (gpmd / 0x646D7067), 33 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:49:48.000000Z
      handler_name    : GoPro MET  
    Stream #4:3(eng): Data: none (fdsc / 0x63736466), 36 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:49:48.000000Z
      handler_name    : GoPro SOS  
Input #5, mov,mp4,m4a,3gp,3g2,mj2, from 'GX064183.MP4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2016-08-25T23:57:52.000000Z
    firmware        : HD6.01.01.60.00
  Duration: 00:05:28.77, start: 0.000000, bitrate: 64980 kb/s
    Stream #5:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 64684 kb/s, 239.76 fps, 239.76 tbr, 240k tbn, 239.76 tbc (default)
    Metadata:
      creation_time   : 2016-08-25T23:57:52.000000Z
      handler_name    : GoPro H.265
      encoder         : GoPro H.265 encoder
    Stream #5:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:57:52.000000Z
      handler_name    : GoPro AAC  
    Stream #5:2(eng): Data: bin_data (gpmd / 0x646D7067), 33 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:57:52.000000Z
      handler_name    : GoPro MET  
    Stream #5:3(eng): Data: none (fdsc / 0x63736466), 36 kb/s (default)
    Metadata:
      creation_time   : 2016-08-25T23:57:52.000000Z
      handler_name    : GoPro SOS  
Input #6, png_pipe, from '/home/hutber/Videos/scaled.png':
  Duration: N/A, bitrate: N/A
    Stream #6:0: Video: png, rgba(pc), 320x327 [SAR 2943:2944 DAR 45:46], 25 tbr, 25 tbn, 25 tbc
File '../Week_7_merged.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 (hevc) -> concat:in0:v0
  Stream #0:1 (aac) -> concat:in0:a0
  Stream #1:0 (hevc) -> concat:in1:v0
  Stream #1:1 (aac) -> concat:in1:a0
  Stream #2:0 (hevc) -> concat:in2:v0
  Stream #2:1 (aac) -> concat:in2:a0
  Stream #3:0 (hevc) -> concat:in3:v0
  Stream #3:1 (aac) -> concat:in3:a0
  Stream #4:0 (hevc) -> concat:in4:v0
  Stream #4:1 (aac) -> concat:in4:a0
  Stream #5:0 (hevc) -> overlay:overlay
  overlay -> Stream #0:0 (libx264)
  concat:out:a0 -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[swscaler @ 0xd7aaec0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7584640] using SAR=1/1
[libx264 @ 0x7584640] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7584640] profile Progressive High, level 5.2, 4:2:0, 8-bit
[libx264 @ 0x7584640] 264 - core 157 r2969 d4099dd - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '../Week_7_merged.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    firmware        : HD6.01.01.60.00
    encoder         : Lavf58.28.101
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 239.76 fps, 240k tbn, 239.76 tbc (default)
    Metadata:
      encoder         : Lavc58.53.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc58.53.101 aac
[hevc @ 0x78f7dc0] Could not find ref with POC 100:00:10.79 bitrate=27198.8kbits/s speed=0.333x    
frame=579608 fps=143 q=-1.0 Lsize= 1505572kB time=00:40:17.45 bitrate=5101.9kbits/s dup=46 drop=18 speed=0.597x    
video:1459191kB audio:37970kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.561760%
[libx264 @ 0x7584640] frame I:2334  Avg QP:17.89  size:171199
[libx264 @ 0x7584640] frame P:147051 Avg QP:22.49  size:  5517
[libx264 @ 0x7584640] frame B:430223 Avg QP:25.37  size:   659
[libx264 @ 0x7584640] consecutive B-frames:  0.9%  0.2%  0.2% 98.7%
[libx264 @ 0x7584640] mb I  I16..4:  8.8% 63.2% 28.0%
[libx264 @ 0x7584640] mb P  I16..4:  0.3%  0.4%  0.1%  P16..4:  5.3%  1.4%  1.2%  0.0%  0.0%    skip:91.4%
[libx264 @ 0x7584640] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  3.3%  0.2%  0.1%  direct: 0.1%  skip:96.3%  L0:39.5% L1:56.3% BI: 4.1%
[libx264 @ 0x7584640] 8x8 transform intra:60.0% inter:68.4%
[libx264 @ 0x7584640] coded y,uvDC,uvAC intra: 55.6% 57.8% 29.1% inter: 1.1% 0.7% 0.0%
[libx264 @ 0x7584640] i16 v,h,dc,p: 20% 18%  8% 54%
[libx264 @ 0x7584640] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 13% 21%  7%  7%  8%  6%  7%  7%
[libx264 @ 0x7584640] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 18% 10%  8% 14%  9%  6%  5% 10%
[libx264 @ 0x7584640] i8c dc,h,v,p: 58% 18% 17%  7%
[libx264 @ 0x7584640] Weighted P-Frames: Y:0.4% UV:0.2%
[libx264 @ 0x7584640] ref P L0: 67.6% 12.8% 14.9%  4.6%  0.1%
[libx264 @ 0x7584640] ref B L0: 89.5%  9.0%  1.5%
[libx264 @ 0x7584640] ref B L1: 96.1%  3.9%
[libx264 @ 0x7584640] kb/s:4944.75
[aac @ 0x78a6ec0] Qavg: 180.332

测试文件

https://drive.google.com/drive/folders/187EjGlksHrHo7xBGdbArFEivD4wsqKXt?usp=sharing

#!/bin/bash

checkFolders(){    
    printf "Please select folder:\n"
    select d in */; do test -n "$d" && break; echo ">>> Invalid Selection"; done
}

checkFolders

cd "$d"

filesList=""
for file in $(ls -1v *.MP4);do 
    filesList="${filesList} -i ${file}"
done

videoName="${d/ /_}"

#ffmpeg $filesList -i /home/hutber/Videos/scaled.png -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a][3:v][3:a][4:v][4:a]concat=n=5:v=1:a=1[vv][a];[vv]overlay=main_w-overlay_w-5:main_h-overlay_h-5[v]" -map "[v]" -map "[a]" ../${videoName%/}_merged.mp4
ffmpeg $filesList -i /home/hutber/Videos/scaled.png -bsf:v h264_mp4toannexb -reset_timestamps 1 -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a][3:v][3:a][4:v][4:a]concat=n=5:v=1:a=1[vv][a];[vv]overlay=main_w-overlay_w-5:main_h-overlay_h-5[v]" -map "[v]" -map "[a]" ../${videoName%/}_merged.mp4

答案1

此命令的问题在于不正确使用覆盖过滤器,这需要 2 个输入视频流。OP 只有一个,第二个导致视频被一个覆盖在另一个之上,而不是 png 文件。此外,视频输入列表不完整。

因此在这种情况下正确的命令应该是

ffmpeg -i GX014186.MP4 -i GX014187.MP4 -i GX024187.MP4 -i GX034187.MP4 -i GX044187.MP4 -i GX054187.MP4 -i GX064187.MP4 -i scaled.png -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a][3:v][3:a][4:v][4:a][5:v][5:a][6:v][6:a]concat=n=7:v=1:a=1[vv][a];[vv][7:v]overlay=main_w-overlay_w-5:main_h-overlay_h-5[v]" -map "[v]" -map "[a]" output.mp4 `

相关内容