web-dev-qa-db-ja.com

オーディオファイルとビデオファイルをFFmpegとマージする方法は?

これは、 これ に似た質問です。私はffmpegコマンドを次のように試しました:

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

そして、私はある種の出力ファイルを持っていますが、それは何も再生できません。

コマンドを実行すると、バッファアンダーフローと次のメッセージがたくさん表示されます。

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がおそらくビデオが再生されない理由です)。

両方とも video.mpgおよびaudio.mp3プレーヤーで問題なくプレイできます。

何が問題で、どうすればこれを修正できますか?

[〜#〜]更新[〜#〜]

完全なノーカットコンソール出力は次のとおりです。

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%
3
Arsen Zahray

-mapオプション(ffmpegドキュメントへのリンク: 5.11詳細オプション )は、入力ファイルからストリームを選択します。最初に入力ファイル番号を指定し、次にストリーム番号を指定する必要があります。

-mapが指定されていない場合、ffmpegは最適なストリームを選択し、通常は正しく実行します。しかし、ffmpegの観点からは、ビデオストリームはオーディオよりも優先度が高いため、MP3ファイルからイメージアート(ビデオとしてマーク)が選択されました。

2番目のファイルから最初にオーディオストリームを選択するには、

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

そしてあなたの他のオプション。これは、イメージアート(セカンドストリーム)のないMP3ファイルでも機能します。

7
Art Shayderov