ffmpeg: объединить видео и объединить с одним аудио - PullRequest
0 голосов
/ 15 апреля 2020

Я пытаюсь объединить несколько видео, предварительно перекодированных, и объединить аудиофайл поверх всего этого.

Я пробовал

ffmpeg -y  -i  ../../video_editing_input_dir/part_00.mp4 -i ../../video_editing_input_dir/part_01.mp4 -i ../../video_editing_input_dir/part_02.mp4 -i ../../video_editing_input_dir/part_03.mp4 -i ../../video_editing_input_dir/part_04.mp4 -i ../../video_editing_input_dir/part_05.mp4 -i ../../video_editing_input_dir/part_06.mp4 -i ../../video_editing_input_dir/part_07.mp4 -i ../../video_editing_input_dir/part_08.mp4 -i ../../video_editing_input_dir/part_09.mp4 -i ../../video_editing_input_dir/part_10.mp4 -i ../../video_editing_input_dir/part_11.mp4 -i ../../video_editing_input_dir/new_audio.mp3 -filter_complex " [0:v:0] setsar=1/1 [v0]; [1:v:0] setsar=1/1 [v1]; [2:v:0] setsar=1/1 [v2]; [3:v:0] setsar=1/1 [v3]; [4:v:0] setsar=1/1 [v4]; [5:v:0] setsar=1/1 [v5]; [6:v:0] setsar=1/1 [v6]; [7:v:0] setsar=1/1 [v7]; [8:v:0] setsar=1/1 [v8]; [9:v:0] setsar=1/1 [v9]; [10:v:0] setsar=1/1 [v10]; [11:v:0] setsar=1/1 [v11]; [v0] [v1] [v2] [v3] [v4] [v5] [v6] [v7] [v8] [v9] [v10] [v11] [12:a:0] concat=n=13:v=1:a=1 [v] [a] " -map [v] -map [a] -c:v h264 -pix_fmt yuv420p -c:a aac ../../video_editing_input_dir/tmp_output_video.mp4

(setsar=1/1 обязательно, в противном случае concat не работает)

И получите следующую ошибку

ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_00.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 74 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 29 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:03.02, start: 0.000000, bitrate: 29 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 17 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_02.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 74 kb/s
    Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 29 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_03.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:01.02, start: 0.000000, bitrate: 29 kb/s
    Stream #3:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 10 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #3:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #4, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_04.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:03.02, start: 0.000000, bitrate: 62 kb/s
    Stream #4:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 2813:2814 DAR 22504:12663], 50 kb/s, SAR 5625:5627 DAR 10000:5627, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #4:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #5, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_05.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 74 kb/s
    Stream #5:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 29 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #5:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #6, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_06.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 74 kb/s
    Stream #6:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 29 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #6:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #7, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_07.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:06.82, start: 0.000000, bitrate: 600 kb/s
    Stream #7:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 465 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #7:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #8, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_08.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 74 kb/s
    Stream #8:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 29 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #8:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #9, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_09.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 74 kb/s
    Stream #9:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 29 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #9:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #10, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_10.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:03.02, start: 0.000000, bitrate: 33 kb/s
    Stream #10:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 21 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #10:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #11, mov,mp4,m4a,3gp,3g2,mj2, from '../../video_editing_input_dir/part_11.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 74 kb/s
    Stream #11:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 29 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #11:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #12, mp3, from '../../video_editing_input_dir/new_audio.mp3':
  Metadata:
    encoder         : Lavf57.83.100
  Duration: 00:00:18.89, start: 0.025057, bitrate: 128 kb/s
    Stream #12:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
    Metadata:
      encoder         : Lavc57.10
[Parsed_setsar_1 @ 0x56545b465880] Media type mismatch between the 'Parsed_setsar_1' filter output pad 0 (video) and the 'Parsed_concat_12' filter input pad 1 (audio)
[AVFilterGraph @ 0x56545b66ad40] Cannot create the link setsar:0 -> concat:1
Error initializing complex filters.
Invalid argument

Я нахожусь в этой такой ситуации, но готов использовать только один аудиофайл .

Есть идеи?

Заранее спасибо

1 Ответ

0 голосов
/ 15 апреля 2020

Все сегменты, подлежащие объединению, должны иметь одинаковое количество и типы потоков. Ваш аудиовход не имеет ничего для объединения, поэтому удалите его из фильтра concat и сопоставьте его напрямую:

ffmpeg -i input0 ... -i input12 -filter_complex "[v0] [v1] [v2] [v3] [v4] [v5] [v6] [v7] [v8] [v9] [v10] [v11] concat=n=12:v=1:a=0,format=yuv420p [v]" -map "[v]" -map 12:a:0 -c:v libx264 -c:a aac -movflags +faststart -shortest output.mp4
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...