gpt4 book ai didi

ffmpeg - 合并 4 个视频并将音频放在不同的轨道/ channel 中

转载 作者:行者123 更新时间:2023-12-04 23:00:46 29 4
gpt4 key购买 nike

我对ffmpeg很陌生,所以我有点挣扎。

我找到了一种方法,可以使用以下代码将 4 个视频合并到一个并排的视频网格(2x2)中:

ffmpeg -y -i vid1.mp4 -i vid2.mp4 -i vid3.mp4 -i vid4.mp4 -filter_complex "[0:0]pad=iw*2:ih*2[a];[1:0]null[b];[2:0]null[c];[3:0]null[d];[a][b]overlay=w[x];[x][c]overlay=0:h[y];[y][d]overlay=w:h" multiple_input_grid.mp4

我想做的是按如下方式分发每个视频的音频
  • 从 vid1 到音轨 1 的音频 -> 左声道
  • 从 vid2 到音轨 1 的音频 -> 右声道
  • 从 vid3 到音轨 2 的音频 -> 左声道
  • 从 vid4 到音轨 2 的音频 -> 右声道

  • 所以 multiple_input_grid.mp4 将有 2 个具有不同左/右音频的音轨

    有没有办法在ffmpeg中做到这一点?

    谢谢

    我正在使用的命令(这应该有 4 个不同的来源,但有 4 个相同的来源):
    C:\Users\Gijs\Documents\ffmpeg-20130820-git-68b63a3-win64-static\bin>ffmpeg -y -
    i VIDEO0050.mp4 -i VIDEO0050.mp4 -i VIDEO0050.mp4 -i VIDEO0050.mp4 -filter_compl
    ex "[0:0]pad=iw*2:ih*2[a];[1:0]null[b];[2:0]null[c];[3:0]null[d];[a][b]overlay=w
    [x];[x][c]overlay=0:h[y];[y][d]overlay=w:h" multiple_input_grid.mp4

    输出:
    ffmpeg version N-55644-g68b63a3 Copyright (c) 2000-2013 the FFmpeg developers
    built on Aug 19 2013 20:32:00 with gcc 4.7.3 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
    e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
    ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
    ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
    eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-
    amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
    enable-libxvid --enable-zlib
    libavutil 52. 42.100 / 52. 42.100
    libavcodec 55. 28.100 / 55. 28.100
    libavformat 55. 13.103 / 55. 13.103
    libavdevice 55. 3.100 / 55. 3.100
    libavfilter 3. 82.100 / 3. 82.100
    libswscale 2. 5.100 / 2. 5.100
    libswresample 0. 17.103 / 0. 17.103
    libpostproc 52. 3.100 / 52. 3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEO0050.mp4':
    Metadata:
    major_brand : isom
    minor_version : 0
    compatible_brands: isom3gp4
    creation_time : 2013-08-13 13:32:27
    Duration: 00:00:28.35, start: 0.000000, bitrate: 5298 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu
    v420p, 720x1280, 5001 kb/s, SAR 65536:65536 DAR 9:16, 29.40 fps, 30.17 tbr, 90k
    tbn, 180k tbc
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : VideoHandle
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 95 k
    b/s
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : SoundHandle
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEO0050.mp4':
    Metadata:
    major_brand : isom
    minor_version : 0
    compatible_brands: isom3gp4
    creation_time : 2013-08-13 13:32:27
    Duration: 00:00:28.35, start: 0.000000, bitrate: 5298 kb/s
    Stream #1:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu
    v420p, 720x1280, 5001 kb/s, SAR 65536:65536 DAR 9:16, 29.40 fps, 30.17 tbr, 90k
    tbn, 180k tbc
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : VideoHandle
    Stream #1:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 95 k
    b/s
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : SoundHandle
    Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEO0050.mp4':
    Metadata:
    major_brand : isom
    minor_version : 0
    compatible_brands: isom3gp4
    creation_time : 2013-08-13 13:32:27
    Duration: 00:00:28.35, start: 0.000000, bitrate: 5298 kb/s
    Stream #2:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu
    v420p, 720x1280, 5001 kb/s, SAR 65536:65536 DAR 9:16, 29.40 fps, 30.17 tbr, 90k
    tbn, 180k tbc
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : VideoHandle
    Stream #2:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 95 k
    b/s
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : SoundHandle
    Input #3, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEO0050.mp4':
    Metadata:
    major_brand : isom
    minor_version : 0
    compatible_brands: isom3gp4
    creation_time : 2013-08-13 13:32:27
    Duration: 00:00:28.35, start: 0.000000, bitrate: 5298 kb/s
    Stream #3:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yu
    v420p, 720x1280, 5001 kb/s, SAR 65536:65536 DAR 9:16, 29.40 fps, 30.17 tbr, 90k
    tbn, 180k tbc
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : VideoHandle
    Stream #3:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 95 k
    b/s
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : SoundHandle
    [libx264 @ 0000000002788fc0] using SAR=1/1
    [libx264 @ 0000000002788fc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    AVX
    [libx264 @ 0000000002788fc0] profile High, level 5.0
    [libx264 @ 0000000002788fc0] 264 - core 135 r2345 f0c1c53 - H.264/MPEG-4 AVC cod
    ec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 r
    ef=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_pski
    p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci
    mate=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=2
    5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.6
    0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to 'multiple_input_grid.mp4':
    Metadata:
    major_brand : isom
    minor_version : 0
    compatible_brands: isom3gp4
    encoder : Lavf55.13.103
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1440x2
    560 [SAR 1:1 DAR 9:16], q=-1--1, 11584 tbn, 30.17 tbc
    Stream #0:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100
    Hz, mono, s16, 128 kb/s
    Metadata:
    creation_time : 2013-08-13 13:32:27
    handler_name : SoundHandle
    Stream mapping:
    Stream #0:0 (h264) -> pad (graph 0)
    Stream #1:0 (h264) -> null (graph 0)
    Stream #2:0 (h264) -> null (graph 0)
    Stream #3:0 (h264) -> null (graph 0)
    overlay (graph 0) -> Stream #0:0 (libx264)
    Stream #0:1 -> #0:1 (aac -> libvo_aacenc)
    Press [q] to stop, [?] for help
    frame= 19 fps=0.0 q=0.0 size= 0kB time=00:00:00.94 bitrate= 0.4kbits/s
    frame= 42 fps= 41 q=0.0 size= 0kB time=00:00:01.64 bitrate= 0.2kbits/s
    frame= 46 fps= 23 q=0.0 size= 0kB time=00:00:01.76 bitrate= 0.2kbits/s
    frame= 54 fps= 21 q=29.0 size= 179kB time=00:00:01.99 bitrate= 735.9kbits/
    frame= 58 fps= 19 q=29.0 size= 338kB time=00:00:02.22 bitrate=1245.2kbits/
    frame= 65 fps= 17 q=29.0 size= 546kB time=00:00:02.34 bitrate=1908.9kbits/
    frame= 73 fps= 16 q=29.0 size= 778kB time=00:00:02.57 bitrate=2476.6kbits/
    frame= 80 fps= 16 q=29.0 size= 927kB time=00:00:02.92 bitrate=2599.0kbits/
    frame= 85 fps= 15 q=29.0 size= 1089kB time=00:00:02.92 bitrate=3053.5kbits/
    frame= 91 fps= 14 q=29.0 size= 1268kB time=00:00:03.15 bitrate=3293.1kbits/
    frame= 99 fps= 14 q=29.0 size= 1481kB time=00:00:03.50 bitrate=3462.3kbits/
    frame= 107 fps= 14 q=29.0 size= 1666kB time=00:00:03.73 bitrate=3653.1kbits/
    frame= 115 fps= 14 q=29.0 size= 1898kB time=00:00:03.96 bitrate=3919.8kbits/
    frame= 123 fps= 13 q=29.0 size= 2121kB time=00:00:04.19 bitrate=4137.0kbits/
    frame= 130 fps= 13 q=29.0 size= 2267kB time=00:00:04.43 bitrate=4190.3kbits/
    frame= 135 fps= 13 q=29.0 size= 2428kB time=00:00:04.66 bitrate=4265.3kbits/
    frame= 143 fps= 13 q=29.0 size= 2625kB time=00:00:04.89 bitrate=4392.4kbits/
    frame= 149 fps= 13 q=29.0 size= 2783kB time=00:00:05.01 bitrate=4548.5kbits/
    frame= 155 fps= 13 q=29.0 size= 2984kB time=00:00:05.36 bitrate=4560.0kbits/
    frame= 163 fps= 13 q=29.0 size= 3195kB time=00:00:05.59 bitrate=4680.1kbits/
    frame= 171 fps= 13 q=29.0 size= 3396kB time=00:00:05.82 bitrate=4776.1kbits/
    frame= 179 fps= 13 q=29.0 size= 3573kB time=00:00:06.05 bitrate=4832.0kbits/
    frame= 186 fps= 13 q=29.0 size= 3785kB time=00:00:06.28 bitrate=4929.5kbits/
    frame= 192 fps= 13 q=29.0 size= 3949kB time=00:00:06.52 bitrate=4960.0kbits/
    frame= 200 fps= 13 q=29.0 size= 4150kB time=00:00:06.75 bitrate=5033.0kbits/
    frame= 206 fps= 13 q=29.0 size= 4306kB time=00:00:06.87 bitrate=5134.7kbits/
    frame= 212 fps= 12 q=29.0 size= 4513kB time=00:00:07.21 bitrate=5121.3kbits/
    frame= 220 fps= 12 q=29.0 size= 4707kB time=00:00:07.45 bitrate=5175.1kbits/
    frame= 228 fps= 12 q=29.0 size= 4918kB time=00:00:07.68 bitrate=5244.0kbits/
    frame= 235 fps= 12 q=29.0 size= 5068kB time=00:00:07.91 bitrate=5245.4kbits/
    frame= 241 fps= 12 q=29.0 size= 5249kB time=00:00:08.14 bitrate=5277.5kbits/
    frame= 248 fps= 12 q=29.0 size= 5444kB time=00:00:08.37 bitrate=5321.9kbits/
    frame= 256 fps= 12 q=29.0 size= 5666kB time=00:00:08.61 bitrate=5390.4kbits/
    frame= 264 fps= 12 q=29.0 size= 5869kB time=00:00:08.84 bitrate=5436.2kbits/
    frame= 268 fps= 12 q=29.0 size= 5976kB time=00:00:09.07 bitrate=5393.6kbits/
    frame= 276 fps= 12 q=29.0 size= 6201kB time=00:00:09.30 bitrate=5457.8kbits/
    frame= 284 fps= 12 q=29.0 size= 6416kB time=00:00:09.54 bitrate=5509.1kbits/
    frame= 292 fps= 12 q=29.0 size= 6622kB time=00:00:09.77 bitrate=5551.1kbits/
    frame= 297 fps= 12 q=29.0 size= 6744kB time=00:00:10.00 bitrate=5521.7kbits/
    frame= 306 fps= 12 q=29.0 size= 7125kB time=00:00:10.23 bitrate=5701.5kbits/
    frame= 314 fps= 12 q=29.0 size= 7364kB time=00:00:10.46 bitrate=5762.2kbits/
    frame= 321 fps= 12 q=29.0 size= 7540kB time=00:00:10.70 bitrate=5771.5kbits/
    frame= 327 fps= 12 q=29.0 size= 7732kB time=00:00:11.04 bitrate=5732.3kbits/
    frame= 331 fps= 12 q=29.0 size= 7834kB time=00:00:11.16 bitrate=5747.2kbits/
    frame= 337 fps= 12 q=29.0 size= 8025kB time=00:00:11.28 bitrate=5827.0kbits/
    frame= 342 fps= 12 q=29.0 size= 8191kB time=00:00:11.39 bitrate=5887.2kbits/
    frame= 349 fps= 12 q=29.0 size= 8395kB time=00:00:11.63 bitrate=5912.9kbits/
    frame= 357 fps= 12 q=29.0 size= 8648kB time=00:00:11.97 bitrate=5914.6kbits/
    frame= 365 fps= 12 q=29.0 size= 8908kB time=00:00:12.21 bitrate=5976.1kbits/
    frame= 372 fps= 12 q=29.0 size= 9100kB time=00:00:12.44 bitrate=5991.4kbits/
    frame= 377 fps= 12 q=29.0 size= 9281kB time=00:00:12.55 bitrate=6054.1kbits/
    frame= 382 fps= 12 q=29.0 size= 9435kB time=00:00:12.79 bitrate=6042.7kbits/
    frame= 389 fps= 12 q=29.0 size= 9633kB time=00:00:13.02 bitrate=6059.2kbits/
    frame= 397 fps= 12 q=29.0 size= 9864kB time=00:00:13.25 bitrate=6096.3kbits/
    frame= 405 fps= 12 q=29.0 size= 10104kB time=00:00:13.48 bitrate=6137.0kbits/
    frame= 412 fps= 12 q=29.0 size= 10289kB time=00:00:13.83 bitrate=6091.8kbits/
    frame= 417 fps= 12 q=29.0 size= 10465kB time=00:00:13.95 bitrate=6144.6kbits/
    frame= 424 fps= 12 q=29.0 size= 10691kB time=00:00:14.18 bitrate=6174.5kbits/
    frame= 429 fps= 12 q=29.0 size= 10895kB time=00:00:14.30 bitrate=6241.0kbits/
    frame= 434 fps= 12 q=29.0 size= 11068kB time=00:00:14.41 bitrate=6289.4kbits/
    frame= 441 fps= 12 q=29.0 size= 11281kB time=00:00:14.76 bitrate=6258.8kbits/
    frame= 448 fps= 12 q=29.0 size= 11507kB time=00:00:14.99 bitrate=6285.4kbits/
    frame= 453 fps= 12 q=29.0 size= 11713kB time=00:00:15.11 bitrate=6348.8kbits/
    frame= 460 fps= 12 q=29.0 size= 11936kB time=00:00:15.34 bitrate=6372.2kbits/
    frame= 464 fps= 12 q=29.0 size= 12124kB time=00:00:15.57 bitrate=6375.6kbits/
    frame= 471 fps= 12 q=29.0 size= 12394kB time=00:00:15.80 bitrate=6422.1kbits/
    frame= 474 fps= 12 q=29.0 size= 12519kB time=00:00:15.80 bitrate=6486.8kbits/
    frame= 481 fps= 12 q=29.0 size= 12790kB time=00:00:16.04 bitrate=6531.2kbits/
    frame= 488 fps= 12 q=29.0 size= 13020kB time=00:00:16.27 bitrate=6553.7kbits/
    frame= 493 fps= 11 q=29.0 size= 13261kB time=00:00:16.50 bitrate=6581.2kbits/
    frame= 499 fps= 11 q=29.0 size= 13430kB time=00:00:16.73 bitrate=6572.9kbits/
    frame= 504 fps= 11 q=29.0 size= 13643kB time=00:00:16.85 bitrate=6631.1kbits/
    frame= 508 fps= 11 q=29.0 size= 13788kB time=00:00:16.97 bitrate=6655.8kbits/
    frame= 514 fps= 11 q=29.0 size= 13995kB time=00:00:17.08 bitrate=6709.5kbits/
    frame= 519 fps= 11 q=29.0 size= 14187kB time=00:00:17.43 bitrate=6665.6kbits/
    frame= 525 fps= 11 q=29.0 size= 14402kB time=00:00:17.55 bitrate=6722.0kbits/
    frame= 531 fps= 11 q=29.0 size= 14653kB time=00:00:17.78 bitrate=6750.1kbits/
    frame= 537 fps= 11 q=29.0 size= 14909kB time=00:00:17.89 bitrate=6823.4kbits/
    frame= 544 fps= 11 q=29.0 size= 15172kB time=00:00:18.13 bitrate=6854.6kbits/
    frame= 553 fps= 11 q=29.0 size= 15667kB time=00:00:18.48 bitrate=6945.0kbits/
    frame= 558 fps= 11 q=29.0 size= 15829kB time=00:00:18.59 bitrate=6972.8kbits/
    frame= 564 fps= 11 q=29.0 size= 16067kB time=00:00:18.82 bitrate=6990.6kbits/
    frame= 570 fps= 11 q=29.0 size= 16264kB time=00:00:18.94 bitrate=7033.1kbits/
    frame= 576 fps= 11 q=29.0 size= 16530kB time=00:00:19.29 bitrate=7019.1kbits/
    frame= 582 fps= 11 q=29.0 size= 16754kB time=00:00:19.40 bitrate=7071.5kbits/
    frame= 588 fps= 11 q=29.0 size= 17015kB time=00:00:19.64 bitrate=7096.9kbits/
    frame= 595 fps= 11 q=29.0 size= 17255kB time=00:00:19.87 bitrate=7112.8kbits/
    frame= 601 fps= 11 q=29.0 size= 17491kB time=00:00:19.98 bitrate=7168.3kbits/
    frame= 606 fps= 11 q=29.0 size= 17659kB time=00:00:20.22 bitrate=7153.8kbits/
    frame= 611 fps= 11 q=29.0 size= 17835kB time=00:00:20.45 bitrate=7143.0kbits/
    frame= 618 fps= 11 q=29.0 size= 18125kB time=00:00:20.56 bitrate=7218.1kbits/
    frame= 624 fps= 11 q=29.0 size= 18306kB time=00:00:20.80 bitrate=7208.9kbits/
    frame= 631 fps= 11 q=29.0 size= 18510kB time=00:00:21.15 bitrate=7169.4kbits/
    frame= 638 fps= 11 q=29.0 size= 18771kB time=00:00:21.26 bitrate=7230.6kbits/
    frame= 644 fps= 11 q=29.0 size= 18953kB time=00:00:21.49 bitrate=7221.9kbits/
    frame= 647 fps= 11 q=29.0 size= 19065kB time=00:00:21.61 bitrate=7225.8kbits/
    frame= 653 fps= 11 q=29.0 size= 19312kB time=00:00:21.73 bitrate=7280.0kbits/
    frame= 660 fps= 11 q=29.0 size= 19499kB time=00:00:22.07 bitrate=7234.8kbits/
    frame= 666 fps= 11 q=29.0 size= 19717kB time=00:00:22.19 bitrate=7277.2kbits/
    frame= 673 fps= 11 q=29.0 size= 19897kB time=00:00:22.42 bitrate=7267.7kbits/
    frame= 679 fps= 11 q=29.0 size= 20081kB time=00:00:22.54 bitrate=7297.2kbits/
    frame= 685 fps= 11 q=29.0 size= 20324kB time=00:00:22.89 bitrate=7273.1kbits/
    frame= 692 fps= 11 q=29.0 size= 20536kB time=00:00:23.12 bitrate=7275.0kbits/
    frame= 700 fps= 11 q=29.0 size= 20776kB time=00:00:23.47 bitrate=7251.0kbits/
    frame= 707 fps= 11 q=29.0 size= 20948kB time=00:00:23.58 bitrate=7275.1kbits/
    frame= 711 fps= 11 q=29.0 size= 21160kB time=00:00:23.70 bitrate=7312.5kbits/
    frame= 716 fps= 11 q=29.0 size= 21299kB time=00:00:23.82 bitrate=7324.8kbits/
    frame= 722 fps= 11 q=29.0 size= 21472kB time=00:00:24.16 bitrate=7277.8kbits/
    frame= 728 fps= 11 q=29.0 size= 21674kB time=00:00:24.28 bitrate=7311.2kbits/
    frame= 736 fps= 11 q=29.0 size= 21912kB time=00:00:24.63 bitrate=7287.1kbits/
    frame= 744 fps= 11 q=29.0 size= 22163kB time=00:00:24.86 bitrate=7301.6kbits/
    frame= 749 fps= 11 q=29.0 size= 22354kB time=00:00:24.98 bitrate=7330.2kbits/
    frame= 755 fps= 11 q=29.0 size= 22555kB time=00:00:25.09 bitrate=7362.0kbits/
    frame= 761 fps= 11 q=29.0 size= 22739kB time=00:00:25.33 bitrate=7354.2kbits/
    frame= 767 fps= 11 q=29.0 size= 23006kB time=00:00:25.56 bitrate=7372.7kbits/
    frame= 774 fps= 11 q=29.0 size= 23232kB time=00:00:25.79 bitrate=7378.2kbits/
    frame= 781 fps= 11 q=29.0 size= 23464kB time=00:00:26.02 bitrate=7385.5kbits/
    frame= 788 fps= 11 q=29.0 size= 23711kB time=00:00:26.14 bitrate=7430.0kbits/
    frame= 792 fps= 11 q=29.0 size= 23853kB time=00:00:26.25 bitrate=7441.6kbits/
    frame= 799 fps= 11 q=29.0 size= 24083kB time=00:00:26.60 bitrate=7414.9kbits/
    frame= 806 fps= 11 q=29.0 size= 24519kB time=00:00:26.83 bitrate=7483.7kbits/
    frame= 813 fps= 11 q=29.0 size= 24713kB time=00:00:27.07 bitrate=7478.3kbits/
    frame= 818 fps= 11 q=29.0 size= 24926kB time=00:00:27.18 bitrate=7510.7kbits/
    frame= 823 fps= 11 q=29.0 size= 25074kB time=00:00:27.41 bitrate=7491.2kbits/
    frame= 830 fps= 11 q=29.0 size= 25314kB time=00:00:27.65 bitrate=7499.2kbits/
    frame= 836 fps= 11 q=29.0 size= 25541kB time=00:00:27.76 bitrate=7535.0kbits/
    frame= 841 fps= 11 q=29.0 size= 25669kB time=00:00:28.00 bitrate=7510.0kbits/
    frame= 850 fps= 11 q=29.0 size= 25971kB time=-577014:-32:-22.-77 bitrate=N/A
    frame= 850 fps= 10 q=-1.0 Lsize= 27415kB time=00:00:28.37 bitrate=7915.7kbits
    /s dup=21 drop=0
    video:26940kB audio:444kB subtitle:0 global headers:0kB muxing overhead 0.113344
    %
    [libx264 @ 0000000002788fc0] frame I:4 Avg QP:20.92 size:166382
    [libx264 @ 0000000002788fc0] frame P:246 Avg QP:23.11 size: 60370
    [libx264 @ 0000000002788fc0] frame B:600 Avg QP:26.45 size: 20116
    [libx264 @ 0000000002788fc0] consecutive B-frames: 4.2% 1.9% 9.2% 84.7%
    [libx264 @ 0000000002788fc0] mb I I16..4: 12.5% 73.1% 14.4%
    [libx264 @ 0000000002788fc0] mb P I16..4: 1.9% 3.4% 0.5% P16..4: 55.6% 14.5
    % 7.5% 0.0% 0.0% skip:16.6%
    [libx264 @ 0000000002788fc0] mb B I16..4: 0.2% 0.3% 0.1% B16..8: 43.8% 3.9
    % 0.8% direct: 2.9% skip:48.0% L0:50.7% L1:46.7% BI: 2.6%
    [libx264 @ 0000000002788fc0] 8x8 transform intra:60.5% inter:79.4%
    [libx264 @ 0000000002788fc0] coded y,uvDC,uvAC intra: 50.1% 56.3% 11.6% inter: 1
    4.5% 16.6% 0.1%
    [libx264 @ 0000000002788fc0] i16 v,h,dc,p: 35% 23% 12% 31%
    [libx264 @ 0000000002788fc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 15% 25% 6% 4%
    5% 4% 9% 5%
    [libx264 @ 0000000002788fc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 14% 13% 6% 6%
    7% 4% 8% 4%
    [libx264 @ 0000000002788fc0] i8c dc,h,v,p: 61% 14% 21% 3%
    [libx264 @ 0000000002788fc0] Weighted P-Frames: Y:2.8% UV:2.0%
    [libx264 @ 0000000002788fc0] ref P L0: 58.0% 6.9% 26.5% 8.4% 0.1%
    [libx264 @ 0000000002788fc0] ref B L0: 86.3% 10.7% 3.0%
    [libx264 @ 0000000002788fc0] ref B L1: 93.4% 6.6%
    [libx264 @ 0000000002788fc0] kb/s:7832.26

    最佳答案

    scaled grid example
    2x2 叠加网格示例(Gijserman 输入中的垂直方向)

    创建 2x2 网格叠加并将 4 个单声道输入组合成 1 个立体声输出

    使用 pad 的示例创建背景的视频滤镜, overlay 用于放置每个视频的视频过滤器, amerge 音频过滤器将所有音频流合并为一个 4 channel 流,和 pan 音频过滤器将生成的 4 个声道组合成立体声(vid1.mp4vid3.mp4 音频到左声道,vid2.mp4vid4.mp4 音频到右声道):

    ffmpeg -y -i vid1.mp4 -i vid2.mp4 -i vid3.mp4 -i vid4.mp4 -filter_complex \
    "[0:v]pad=iw*2:ih*2[bg]; \
    [bg][1:v]overlay=w[z]; \
    [z][2:v]overlay=0:h[y]; \
    [y][3:v]overlay=w:h; \
    [0:a][1:a][2:a][3:a]amerge=inputs=4,pan=stereo:c0<c0+c2:c1<c1+c3" \
    output.mp4

    或者您可以简单地使用 -ac 2而不是 pan :
    ffmpeg -y -i vid1.mp4 -i vid2.mp4 -i vid3.mp4 -i vid4.mp4 -filter_complex \
    "[0:v]pad=iw*2:ih*2[bg]; \
    [bg][1:v]overlay=w[z]; \
    [z][2:v]overlay=0:h[y]; \
    [y][3:v]overlay=w:h; \
    [0:a][1:a][2:a][3:a]amerge=inputs=4" \
    -ac 2 output.mp4
    pan的优势|超过 -ac 2 ,我相信是 pan可以重新归一化增益以避免削波噪声。这就是为什么第一个例子更安静的原因。

    请注意,如果您的输入包含多个音频流,那么您的流说明符必须更具体,例如 [2:a:0] (第三个输入 [ 0 ] 的第一个 [ a ] 音频流 [ 2 ])。

    创建 2x2 网格叠加并将 4 个单声道输入组合成 2 个立体声输出

    同上,但 vid1.mp4 (左声道)和 vid2.mp4 (右声道)音频将是一个立体声输出流, vid3.mp4 (左声道)和 vid4.mp4 (右声道)音频将是第二个输出音频流:
    ffmpeg -y -i vid1.mp4 -i vid2.mp4 -i vid3.mp4 -i vid4.mp4 -filter_complex \
    "[0:v]pad=iw*2:ih*2[bg]; \
    [bg][1:v]overlay=w[z]; \
    [z][2:v]overlay=0:h[y]; \
    [y][3:v]overlay=w:h; \
    [0:a][1:a]amerge;
    [2:a][3:a]amerge" \
    output.mp4

    创建 2x2 网格叠加并将 4 个立体声输入组合成 2 个立体声输出
  • 来自 vid1.mp4 的立体声音频将成为左声道
    首先输出立体声流。
  • 来自 vid2.mp4 的立体声音频将成为正确的 channel
    首先输出立体声流。
  • 来自 vid3.mp4 的立体声音频将成为左声道
    第二个输出立体声流。
  • 来自 vid4.mp4 的立体声音频将成为正确的 channel
    第二个输出立体声流。

  • 例子:
    ffmpeg -y -i vid1.mp4 -i vid2.mp4 -i vid3.mp4 -i vid4.mp4 -filter_complex \
    "[0:v]pad=iw*2:ih*2[bg]; \
    [bg][1:v]overlay=w[z]; \
    [z][2:v]overlay=0:h[y]; \
    [y][3:v]overlay=w:h[vid]; \
    [0:a]pan=stereo:c0<c0+c1[left1]; \
    [1:a]pan=stereo:c1<c0+c1[right1]; \
    [left1][right1]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[audio1]; \
    [2:a]pan=stereo:c0<c0+c1[left2]; \
    [3:a]pan=stereo:c1<c0+c1[right2]; \
    [left2][right2]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[audio2]" \
    -map "[vid]" -map "[audio1]" -map "[audio2]" output.mkv

    关于ffmpeg - 合并 4 个视频并将音频放在不同的轨道/ channel 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18353772/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com