Eu quero mesclar áudio de imagem e legenda com ffmpeg

1

Eu quero mesclar áudio e legendas de imagens com o ffmpeg, mas o que eu faço não funciona:

ffmpeg -i audio.mp3 -i 1.png -vcodec libx264 -r 23.976 -vf "ass='subtitle.ass'" -acodec copy video.mp4

Eu posso ver a imagem e ouvir a música, mas não a legenda. Aqui está a saída do console:

ffmpeg version 2.6.9 Copyright (c) 2000-2016 the FFmpeg developers   built with gcc 4.9.2 (Debian 4.9.2-10)   configuration: --prefix=/usr
--extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree
--enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mips32r2 --disable-mipsdspr1 --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --disable-htmlpages --disable-podpages --enable-libutvideo --enable-libfdk-aac --enable-libx265 --enable-libiec61883 --enable-vaapi --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu   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 @ 0x1802f00] Changeing bps to 8 Input #0, mp3, from 'audio.mp3':   Metadata:
    album           : もしもからきっと
    artist          : 東條希(CV.楠田亜衣奈)
    genre           : Anime
    title           : もしもからきっと
    track           : 1/2
    date            : 2014   Duration: 00:05:18.90, start: 0.025056, bitrate: 322 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
    Metadata:
      encoder         : LAME3.99r
    Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 300x376, 90k tbr, 90k tbn, 90k tbc
    Metadata:
      title           : 
      comment         : Cover (front) Input #1, png_pipe, from '1.png':   Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgb24, 668x376 [SAR 2835:2835 DAR 167:94], 25 tbr, 25 tbn, 25 tbc [Parsed_ass_0 @ 0x17cb6c0] Added subtitle file: 'subtitle.ass' (2 styles, 11 events) No pixel format specified, yuv444p for H.264 encoding chosen. Use -pix_fmt yuv420p for compatibility with outdated media players. [libx264 @ 0x180f9a0] using SAR=1/1 [libx264 @ 0x180f9a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 [libx264 @ 0x180f9a0] profile High 4:4:4 Predictive, level 3.0, 4:4:4 8-bit [libx264 @ 0x180f9a0] 264 - core 146 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=4 threads=3 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=23 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 'video.mp4':   Metadata:
    album           : もしもからきっと
    artist          : 東條希(CV.楠田亜衣奈)
    genre           : Anime
    title           : もしもからきっと
    track           : 1/2
    date            : 2014
    encoder         : Lavf56.25.101
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv444p, 668x376 [SAR 1:1 DAR 167:94], q=-1--1, 23.98 fps, 11988 tbn,
23.98 tbc
    Metadata:
      encoder         : Lavc56.26.100 libx264
    Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, stereo, 320 kb/s
    Metadata:
      encoder         : LAME3.99r Stream mapping:   Stream #1:0 -> #0:0 (png (native) -> h264 (libx264))   Stream #0:0 -> #0:1 (copy) Press [q] to stop, [?] for help frame=    1 fps=0.0 q=28.0 Lsize=   12524kB time=00:05:18.87 bitrate= 321.7kbits/s     video:17kB audio:12457kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.394340% [libx264 @ 0x180f9a0] frame I:1     Avg QP:31.93  size: 17171 [libx264 @ 0x180f9a0] mb I  I16..4:  1.2% 77.3% 21.5% [libx264 @ 0x180f9a0] 8x8 transform intra:77.3% [libx264 @ 0x180f9a0] coded y,u,v intra: 41.5% 25.9% 25.0% [libx264 @ 0x180f9a0] i16 v,h,dc,p: 58% 25% 17%  0% [libx264 @ 0x180f9a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 39%  8% 38%  2%  2%  3%  2%  3%  3% [libx264 @ 0x180f9a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 18% 12%  7%  9%  8%  9%  7%  7% [libx264 @ 0x180f9a0] kb/s:3293.54
    
por behoimi 21.02.2017 / 07:45

1 resposta

0

Use

ffmpeg -i audio.mp3 -loop 1 -i 1.png -c:v libx264 -r 24000/1001 -vf "ass='subtitle.ass'" -pix_fmt yuv420p -c:a copy -map 1:v -map 0:a -shortest video.mp4

O FFmpeg normalmente trabalha com seqüências de mídia temporizadas, ou seja, sequências de vídeo ou áudio ou imagem. Quando alimentada com uma única imagem, ela é tratada como um quadro de duração 1/fps , em que o fps normalmente é 25. Portanto, não há tela de vídeo na qual desenhar as legendas. Adicionar a opção de loop de entrada à imagem diz ao FFmpeg para gerar um fluxo de vídeo indefinido.

    
por 21.02.2017 / 10:08