FFMPEG - crie mp4 a partir de imagens e aplique marca d'água e filtro zoompan

0

Eu tenho um comando que captura imagens e cria um vídeo mp4 com o filtro zoompan em cada imagem, aplica uma marca d'água sobre o vídeo e faz a transição entre as imagens:

ffmpeg -y -i img-1.jpg -i img-2.jpg -i img-3.jpg -f lavfi -i color=black:r=25:s=1280x720:d=15 -loop 1 -i watermark.png -filter_complex [0:v]setsar=1,setdar=16/9,scale=5120:2880,zoompan=z='min(zoom+0.0005,1.1)':x='0':y='0':d=125,format=yuv420p,setpts=PTS-STARTPTS[va0];[1:v]setsar=1,setdar=16/9,scale=7680:4320,zoompan=z='if(lte(zoom,1.0),1.1,max(1.001,zoom-0.0005))':x='0':y='ih/2-(ih/zoom/2)':d=125,format=yuv420p,format=yuva420p,fade=t=in:st=0:d=0.5:alpha=1,setpts=PTS-STARTPTS+5/TB[va1];[2:v]setsar=1,setdar=16/9,scale=5120:2880,zoompan=z='min(zoom+0.0005,1.1)':x='5120':y='2880':d=125,format=yuv420p,format=yuva420p,fade=t=in:st=0:d=0.5:alpha=1,setpts=PTS-STARTPTS+10/TB[va2];[3:v][va0]overlay[over1];[over1][va1]overlay[over2];[over2][va2]overlay[over3];[over3][4:v]overlay=W-w:H-h:shortest=1,fade=t=in:st=0:d=0.5,fade=t=out:st=14.5:d=0.5,format=yuv420p[outv] -c:v libx264 -map [outv] -s 1280x720 -aspect 16:9 -r 25 -crf 18 -preset ultrafast output.mp4

Saída:

ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libdc1394 --enable-libfaac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[mjpeg @ 0x1d78dc0] Changeing bps to 8
Input #0, image2, from 'img-1.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 25016 kb/s
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 940x749 [SAR 1:1 DAR 940:749], 25 tbr, 25 tbn, 25 tbc
[mjpeg @ 0x1d7b660] Changeing bps to 8
Input #1, image2, from 'img-2.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 35632 kb/s
    Stream #1:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 962x642 [SAR 150:150 DAR 481:321], 25 tbr, 25 tbn, 25 tbc
[mjpeg @ 0x1d7c540] Changeing bps to 8
Input #2, image2, from 'img-3.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 20180 kb/s
    Stream #2:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 750x500 [SAR 100:100 DAR 3:2], 25 tbr, 25 tbn, 25 tbc
Input #3, lavfi, from 'color=black:r=25:s=1280x720:d=15':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #3:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #4, png_pipe, from 'watermark.png':
  Duration: N/A, bitrate: N/A
    Stream #4:0: Video: png, rgba, 1280x720 [SAR 2835:2835 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[swscaler @ 0x1d27220] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x247af80] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x250e260] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x24576e0] using SAR=1/1
[libx264 @ 0x24576e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x24576e0] profile Constrained Baseline, level 3.1
[libx264 @ 0x24576e0] 264 - core 142 r2438 af8e768 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf56.25.101
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc56.26.100 libx264
Stream mapping:
  Stream #0:0 (mjpeg) -> setsar
  Stream #1:0 (mjpeg) -> setsar
  Stream #2:0 (mjpeg) -> setsar
  Stream #3:0 (rawvideo) -> overlay:main
  Stream #4:0 (png) -> overlay:overlay
  format -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[Parsed_overlay_22 @ 0x24544e0] [framesync @ 0x24553e8] Buffer queue overflow, dropping.
    Last message repeated 58 times
[Parsed_overlay_23 @ 0x1fac660] [framesync @ 0x24559e8] Buffer queue overflow, dropping.
    Last message repeated 59 times
[swscaler @ 0x6962820] Warning: data is not aligned! This can lead to a speedloss
[Parsed_overlay_24 @ 0x1faedc0] [framesync @ 0x2456008] Buffer queue overflow, dropping.
    Last message repeated 59 times
frame=  375 fps= 24 q=-1.0 Lsize=   15650kB time=00:00:15.00 bitrate=8547.0kbits/s    
video:15648kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.015783%
[libx264 @ 0x24576e0] frame I:2     Avg QP:10.50  size:196471
[libx264 @ 0x24576e0] frame P:373   Avg QP:13.66  size: 41902
[libx264 @ 0x24576e0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x24576e0] mb P  I16..4:  7.9%  0.0%  0.0%  P16..4: 53.6%  0.0%  0.0%  0.0%  0.0%    skip:38.5%
[libx264 @ 0x24576e0] coded y,uvDC,uvAC intra: 74.5% 63.6% 36.4% inter: 37.1% 23.4% 8.1%
[libx264 @ 0x24576e0] i16 v,h,dc,p: 39% 44% 11%  7%
[libx264 @ 0x24576e0] i8c dc,h,v,p: 29% 37% 27%  6%
[libx264 @ 0x24576e0] kb/s:8545.37

Cada parte deste comando está funcionando conforme o esperado, exceto pela duração do filtro zoompan. Com este vídeo a 25 fps e a duração dos filtros de zoompan especificados em 125 quadros, o filtro de zoom deve durar os 5 segundos inteiros de cada imagem. Mas, dura apenas 2 segundos e depois pára. O que eu estou fazendo errado aqui?

    
por Jon Stevens 06.10.2016 / 22:45

1 resposta

2

Seu ffmpeg é muito antigo. Recomenda-se que os usuários usem uma compilação a partir da ramificação do master do git atual. Você pode fazer o download ou compilar

    
por 07.10.2016 / 21:44