Я пытаюсь объединить два видео вместе (и некоторые другие эффекты) с помощью FFmpeg. Команда, которую я использую, используется для работы с более старой версией FFmpeg. Теперь я создал FFmpeg с последним снимком, и выходное видео начало зависать на полпути.

ffmpeg -y \
 -i bunny_320x180.mp4 \
 -i bunny_320x180.mp4 \
 -f lavfi -i color=black \
 -filter_complex "
[0:v]trim=0:6[v0];
[0:a]atrim=0:6[a0];
[1:v]trim=10:18[v1_trim];
[1:a]atrim=10:18[a1_trim];
[v1_trim]setpts=expr=PTS-STARTPTS+7/TB[v1];
aevalsrc=0:d=7[na1];
[na1][a1_trim]concat=n=2:v=0:a=1[a1];
[a0][a1]amix=inputs=2[amixed];
[2:v]scale=320x180,trim=duration=15[over0];
[over0][v0]overlay=eof_action=pass[over1];
[over1][v1]overlay=eof_action=pass[over2]
" \
 -vcodec libx264 \
 -map [over2] \
 -map [amixed] \
 -c:a libfdk_aac \
 output.mp4

Я пытался свести мою команду к простейшему состоянию, сохраняя при этом ошибку. Вводимые видео, кажется, не имеют значения, поэтому я использую Big Bunny Bunny. Мои переходы исчезают, и вместо этого я оставляю черный разрыв. Я играл с различной длиной обрезки и смещениями, но не видел рисунка. Выходное видео, кажется, зависает на 10 секунд.

Выход из FFmpeg:

ffmpeg version N-82183-g6089c44 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
  configuration: --prefix=/home/jon/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/jon/ffmpeg_build/include --extra-ldflags=-L/home/jon/ffmpeg_build/lib --bindir=/home/jon/bin --enable-gpl --disable-doc --enable-yasm --disable-decoders --enable-decoder='mpeg4,aac,h264,mpegvideo,mpeg1video,mpeg2video,png,mjpeg,rawvideo,mp3,pcm_s16le,pcm_u8' --disable-encoders --enable-encoder='mpeg4,aac,h264,libx264,mpeg1video,mpeg2video,png,mjpeg,libfdk_aac,rawvideo,pcm_s16le' --disable-parsers --enable-parser='aac,mpeg4video,ac3,h261,h264,vc1,mpegvideo' --disable-demuxers --enable-demuxer='aac,h264,mpegvideo,m4v,mov,vc1,mp4,concat,image2,mpegts,mp3,pcm_s16le' --disable-muxers --enable-muxer='h264,mpeg1video,mpeg2video,m4v,mov,vc1,md5,mp4,image2,mpegts,segment,null' --enable-protocols --disable-filters --enable-filter='aresample,scale,movie,overlay,color,fade,afade,pad,asetpts,amerge,aevalsrc,concat,amix,eq,colorchannelmixer,setsar,hue,atempo,crop,hflip,vflip,transpose,lut3d,volume,anullsrc,drawtext,streamselect,sendcmd' --enable-avfilter --disable-indevs --enable-indev=v4l2 --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-symver --enable-network --enable-libx264 --enable-zlib --enable-nonfree --enable-libfdk-aac --enable-pthreads --enable-libmp3lame --enable-openssl
  libavutil      55. 35.100 / 55. 35.100
  libavcodec     57. 65.100 / 57. 65.100
  libavformat    57. 57.100 / 57. 57.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 66.100 /  6. 66.100
  libswscale      4.  3.100 /  4.  3.100
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bunny_320x180.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny
    artist          : Blender Foundation
    composer        : Blender Foundation
    date            : 2008
    encoder         : Lavf56.25.101
  Duration: 00:01:30.02, start: -0.012000, bitrate: 315 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x180 [SAR 1:1 DAR 16:9], 182 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'bunny_320x180.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny
    artist          : Blender Foundation
    composer        : Blender Foundation
    date            : 2008
    encoder         : Lavf56.25.101
  Duration: 00:01:30.02, start: -0.012000, bitrate: 315 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x180 [SAR 1:1 DAR 16:9], 182 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #2, lavfi, from 'color=black':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #2:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x182b2e0] using SAR=3/4
[libx264 @ 0x182b2e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x182b2e0] profile High, level 1.2
[libx264 @ 0x182b2e0] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=6 lookahead_threads=1 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 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny
    artist          : Blender Foundation
    composer        : Blender Foundation
    date            : 2008
    encoder         : Lavf57.57.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 320x180 [SAR 3:4 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc57.65.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, s16, 139 kb/s (default)
    Metadata:
      encoder         : Lavc57.65.100 libfdk_aac
Stream mapping:
  Stream #0:0 (h264) -> trim
  Stream #0:1 (aac) -> atrim
  Stream #1:0 (h264) -> trim
  Stream #1:1 (aac) -> atrim
  Stream #2:0 (rawvideo) -> scale
  overlay -> Stream #0:0 (libx264)
  amix -> Stream #0:1 (libfdk_aac)
Press [q] to stop, [?] for help
[Parsed_overlay_11 @ 0x1827040] [framesync @ 0x1827168] Buffer queue overflow, dropping.
    Last message repeated 118 times
frame=  375 fps=0.0 q=-1.0 Lsize=     456kB time=00:00:15.01 bitrate= 248.7kbits/s speed=  22x    
video:187kB audio:257kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.760969%
[libx264 @ 0x182b2e0] frame I:4     Avg QP:17.13  size: 10993
[libx264 @ 0x182b2e0] frame P:120   Avg QP:20.45  size:   963
[libx264 @ 0x182b2e0] frame B:251   Avg QP:24.37  size:   124
[libx264 @ 0x182b2e0] consecutive B-frames:  7.5%  7.5%  7.2% 77.9%
[libx264 @ 0x182b2e0] mb I  I16..4: 33.6% 23.5% 42.8%
[libx264 @ 0x182b2e0] mb P  I16..4:  4.6%  5.3%  2.0%  P16..4: 28.1%  5.9%  3.4%  0.0%  0.0%    skip:50.7%
[libx264 @ 0x182b2e0] mb B  I16..4:  1.4%  1.0%  0.2%  B16..8: 14.9%  0.5%  0.1%  direct: 2.0%  skip:79.8%  L0:45.0% L1:49.2% BI: 5.7%
[libx264 @ 0x182b2e0] 8x8 transform intra:39.8% inter:56.9%
[libx264 @ 0x182b2e0] coded y,uvDC,uvAC intra: 22.2% 51.1% 21.4% inter: 5.4% 9.6% 1.3%
[libx264 @ 0x182b2e0] i16 v,h,dc,p: 52% 22% 20%  6%
[libx264 @ 0x182b2e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 18% 55%  1%  1%  1%  2%  1%  2%
[libx264 @ 0x182b2e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 56%  9% 10%  4%  4%  4%  5%  4%  5%
[libx264 @ 0x182b2e0] i8c dc,h,v,p: 59% 21% 16%  3%
[libx264 @ 0x182b2e0] Weighted P-Frames: Y:15.0% UV:10.8%
[libx264 @ 0x182b2e0] ref P L0: 76.6%  7.8% 11.2%  4.4%
[libx264 @ 0x182b2e0] ref B L0: 90.7%  7.9%  1.4%
[libx264 @ 0x182b2e0] ref B L1: 96.5%  3.5%
[libx264 @ 0x182b2e0] kb/s:101.72

Это ошибка FFmpeg или неправильное использование сложных фильтров?

1 ответ1

1

Пытаться

ffmpeg -y \
 -i bunny_320x180.mp4 \
 -i bunny_320x180.mp4 \
 -f lavfi -i color=black:s=320x180:d=15 \
 -f lavfi -t 7 -i anullsrc
 -filter_complex "
[0:v]trim=0:6,setpts=PTS-STARTPTS[v0];
[0:a]atrim=0:6[a0];
[1:v]trim=10:18,setpts=PTS-STARTPTS+7/TB,fifo[v1];
[1:a]atrim=10:18,asetpts=PTS-STARTPTS+7/TB[a1_trim];
[3][a1_trim]concat=n=2:v=0:a=1[a1];
[a0][a1]amix=inputs=2[amixed];
[2][v0]overlay=eof_action=pass[over1];
[over1][v1]overlay=eof_action=pass[over2]
" \
 -vcodec libx264 \
 -map [over2] \
 -map [amixed] \
 -c:a libfdk_aac \
 output.mp4

Обычно, если один вход должен использоваться параллельно, лучше подать его один раз, а затем разбить его внутри фильтра. Я добавил фильтр fifo во 2-й обрезанный сегмент, чтобы сохранить живые кадры при 2-м наложении.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .