Como mesclar arquivos de áudio e vídeo com o FFmpeg?

3

Esta é uma pergunta, semelhante a este . Eu tentei seguir o comando ffmpeg:

ffmpeg -i "video.mpg" -i "audio.mp3" -t 00:01:35.13 -vcodec copy -acodec copy result.with.sound.mpg

E eu tenho algum tipo de arquivo de saída, que nada pode jogar.

Ao executar o comando, recebi muitas mensagens sobre o buffer underflow e seguindo:

frame=    1 fps=0.2 q=-1.0 Lsize=    4672kB time=00:00:00.00 bitrate=3479365818.2kbits/s
video:909kB audio:3716kB subtitle:0 global headers:0kB muxing overhead 1.021293%

(bitrate = 3479365818.2 é provavelmente a razão pela qual o vídeo não é reproduzido).

Ambos video.mpg e audio.mp3 pode ser jogado em um jogador sem problemas.

O que há de errado e como posso consertar isso?

ATUALIZAR

Aqui está a saída completa do console sem cortes:

ffmpeg version N-42347-g299387e Copyright (c) 2000-2012 the FFmpeg developers
  built on Jul  8 2012 15:48:29 with gcc 4.7.1
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-
mrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libt
eora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      51. 64.100 / 51. 64.100
  libavcodec     54. 33.100 / 54. 33.100
  libavformat    54. 15.102 / 54. 15.102
  libavdevice    54.  1.100 / 54.  1.100
  libavfilter     3.  1.100 /  3.  1.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, avi, from 'video.mpg':
  Metadata:
    encoder         : MEncoder Sherpya-SVN-r34401-4.6.2
  Duration: 00:01:35.04, start: 0.000000, bitrate: 272 kb/s
    Stream #0:0: Video: mpeg1video ([1][0][0][16] / 0x10000001), yuv420p, 425x330 [SAR 1:1 DAR 85:66], 104857 kb/s, 25 tbr, 25 tbn, 25 tbc
[mp3 @ 0000000002065840] max_analyze_duration 5000000 reached at 5016000
Input #1, mp3, from 'audio.mp3':
  Metadata:
    TIT1            : XRCD048
    title           : Super Human (No Vox) (build at 0:52)
    album           : Bare Bones
    genre           : Soundtrack
    artist          : X-Ray Dog
    track           : 24/50
    date            : 2010
  Duration: 00:01:35.13, start: 0.000000, bitrate: 399 kb/s
    Stream #1:0: Audio: mp3, 48000 Hz, stereo, s16, 320 kb/s
    Stream #1:1: Video: png, rgba, 643x643, 90k tbr, 90k tbn, 90k tbc
    Metadata:
      title           :
      comment         : Other
[mpeg @ 00000000020ac020] VBV buffer size not set, muxing may fail
Output #0, mpeg, to 'result.with.sound.mpg':
  Metadata:
    encoder         : Lavf54.15.102
    Stream #0:0: Video: png, rgba, 643x643, q=2-31, 90k tbn, 90k tbc
    Metadata:
      title           :
      comment         : Other
    Stream #0:1: Audio: mp3, 48000 Hz, stereo, 320 kb/s
Stream mapping:
  Stream #1:1 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
buffer underflow i=0 bufi=234681 size=930322ime=00:00:00.00 bitrate=   0.0kbits/s
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=234681 size=930322
    Last message repeated 1 times
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=234681 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=236722 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=236722 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=238763 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=238763 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=240804 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=240804 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=242845 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=242845 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=244886 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=244886 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=246927 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=246927 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=248968 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=248968 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=251009 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=251009 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=253050 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=253050 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=255091 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=255091 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=257132 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=257132 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=259173 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=259173 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=261214 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=261214 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=263255 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=263255 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=265296 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=265296 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=267337 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=267337 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=269378 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=269378 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=271419 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=271419 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=273460 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=273460 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=275501 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=275501 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=277542 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=277542 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=279583 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=279583 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=281624 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=281624 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=283665 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=283665 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=285706 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=285706 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=287747 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=287747 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=289788 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=289788 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=291829 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=291829 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=293870 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=293870 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=295911 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=295911 size=930322
    .......
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=912293 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=912293 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=914334 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=914334 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=916375 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=916375 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=918416 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=918416 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=920457 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=920457 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=922498 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=922498 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=924539 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=924539 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=926580 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=926580 size=930322
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=928621 size=930322
[mpeg @ 00000000020ac020] packet too large, ignoring buffer limits to mux it
[mpeg @ 00000000020ac020] buffer underflow i=0 bufi=928621 size=930322
frame=    1 fps=0.2 q=-1.0 Lsize=    4672kB time=00:00:00.00 bitrate=3479365818.2kbits/s
video:909kB audio:3716kB subtitle:0 global headers:0kB muxing overhead 1.021293%
Arsen Zahray
fonte
Por favor, inclua a saída de console completa e sem cortes!
slhck
Esta saída parece truncada. Por que Input #1 (o áudio) tem um fluxo de vídeo ( Stream #1:1 ) De qualquer forma, você precisa que a saída seja um contêiner MPEG? Você não pode usar MP4, ou MOV, ou MKV?
slhck
Eu realmente não preciso que a saída seja um mpeg, mas a entrada deve ser mpeg
Arsen Zahray
1
Bem, então tente com o MKV e relate seus resultados, por favor. Eu sinto que pode haver uma diferença.
slhck
1
por que não tentar mapear? -i input -map 0: 0 -map 1: 0
Art Shayderov

Respostas:

7

o -map opção (link para ffmpeg docs: 5.11 Opções avançadas ) seleciona um fluxo do arquivo de entrada. Primeiro você tem que especificar o número do arquivo de entrada, segundo o número do fluxo.

E se -map não é especificado, o ffmpeg seleciona os melhores fluxos e normalmente o faz corretamente. Mas, do ponto de vista do ffmpeg, o fluxo de vídeo tem maior prioridade do que o áudio, por isso selecionou a arte da imagem (marcada como vídeo) a partir do seu arquivo MP3.

Para selecionar o fluxo de áudio primeiro do segundo arquivo, tente

-i file_0 -i file_1 -map 0:0 -map 1:0

e depois suas outras opções. Isso também funcionará para arquivos MP3 sem imagem (segunda transmissão).

Art Shayderov
fonte