Jak połączyć pliki audio i wideo z FFmpeg?

3

To pytanie jest podobne do tego . Próbowałem następujące polecenie ffmpeg:

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

I mam jakiś plik wyjściowy, którego nic nie może odtworzyć.

Podczas wykonywania polecenia mam wiele komunikatów o przepełnieniu bufora i następujących:

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 jest prawdopodobnie przyczyną, dla której wideo nie jest odtwarzane).

Zarówno video.mpgi audio.mp3mogą być odtwarzane w odtwarzaczu bez żadnych problemów.

Co jest nie tak i jak mogę to naprawić?

AKTUALIZACJA

Oto pełne nieoszlifowane wyjście konsoli:

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
źródło
Dołącz pełne, nieoszlifowane wyjście konsoli!
slhck 17.07.12
To wyjście wydaje się zniekształcone. Dlaczego Input #1(dźwięk) miałby strumień wideo ( Stream #1:1)? W każdym razie, czy potrzebujesz wyjścia jako kontenera MPEG? Nie możesz używać MP4, MOV lub MKV?
slhck
Tak naprawdę nie potrzebuję, aby wyjście było MPEG, ale wejście musi być MPEG
Arsen Zahray
1
Więc spróbuj z MKV i zgłoś swoje wyniki. Czuję, że może być różnica.
slhck,
1
dlaczego nie spróbować mapowania? -i wejście -mapa 0: 0 -mapa 1: 0
Art Shayderov

Odpowiedzi:

7

-mapOpcja (Link do ffmpeg docs: 5.11 Opcje zaawansowane ) Wybór strumienia z pliku wejściowego. Najpierw musisz podać numer pliku wejściowego, a następnie numer strumienia.

Jeśli -mapnie jest określony, ffmpeg wybiera najlepsze strumienie i zwykle robi to dobrze. Ale z punktu widzenia ffmpeg strumień wideo ma wyższy priorytet niż audio, więc wybrał grafikę (oznaczoną jako wideo) z pliku MP3.

Aby najpierw wybrać strumień audio z drugiego pliku, spróbuj

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

a następnie inne opcje. Działa to również w przypadku plików MP3 bez grafiki (drugi strumień).

Art Shayderov
źródło