FFmpeg 无法正确拼接我的 avi/mp3 音频文件?

FFmpeg 无法正确拼接我的 avi/mp3 音频文件?

尝试#1在 mp3 格式的 avi 文件上:

我想拼接我手头的一部电影的第一部分。下面是我使用的命令:

ffmpeg -i file.avi -ss 0 -t 90 -acodec copy -vcodec copy output-4.avi

该命令的结果如下:

FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Mar  4 2010 12:35:30, gcc: 4.4.3
[NULL @ 0x92e0570]Invalid and inefficient vfw-avi packed B frames detected

Seems stream 0 codec frame rate differs from container frame rate: 29.98 (65535/2186) -> 29.97 (2997/100)
Input #0, avi, from 'file.avi':
  Duration: 01:30:57.84, start: 0.000000, bitrate: 1075 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 512x288 [PAR 1:1 DAR 16:9], 29.97 tbr, 29.97 tbn, 29.98 tbc
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 32 kb/s
File 'output-4.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'output-4.avi':
    Stream #0.0: Video: mpeg4, yuv420p, 512x288 [PAR 1:1 DAR 16:9], q=2-31, 90k tbn, 29.97 tbc
    Stream #0.1: Audio: 0x0055, 48000 Hz, stereo, s16, 32 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 2698 fps=  0 q=-1.0 Lsize=    8995kB time=90.02 bitrate= 818.5kbits/s    
video:7342kB audio:1490kB global headers:0kB muxing overhead 1.847673%

存在不一致。音频的输出是0x0055而输入是mp3。为什么会这样?所以我没有正确的mp3包?

当我打开视频时,音频明显混乱,听起来非常失真,就像音频通道连在一起一样。视频看起来完好无损。

尝试#2在 mp2 混合的 mpg 文件上:

为了进行比较,我能够拼接具有 mp2 音频的 mpeg:

原始命令:

ffmpeg -i file.mpg -ss 15 -t 60 -acodec copy -vcodec copy output-2.mpg

结果:

FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Mar  4 2010 12:35:30, gcc: 4.4.3
Input #0, mpeg, from 'file.mpg':
  Duration: 00:15:36.76, start: 0.339000, bitrate: 1394 kb/s
    Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x240 [PAR 200:219 DAR 880:657], 1150 kb/s, 29.97 tbr, 90k tbn, 29.97 tbc
    Stream #0.1[0x1c0]: Audio: mp2, 44100 Hz, stereo, s16, 224 kb/s
File 'output-2.mpg' already exists. Overwrite ? [y/N] y
Output #0, mpeg, to 'output-2.mpg':
    Stream #0.0: Video: mpeg1video, yuv420p, 352x240 [PAR 200:219 DAR 880:657], q=2-31, 1150 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1: Audio: mp2, 44100 Hz, stereo, s16, 224 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
[mpeg @ 0x8b0a1a0]buffer underflow i=1 bufi=0 size=731
frame= 1799 fps=  0 q=-1.0 Lsize=   10154kB time=75.42 bitrate=1103.0kbits/s    
video:8429kB audio:1651kB global headers:0kB muxing overhead 0.724915%

编辑#1:根据 fedeli,这是 ffmpeg -formats | grep mp3 的输出:

ffmpeg -formats | grep mp3
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Mar  4 2010 12:35:30, gcc: 4.4.3
 DE mp3             MPEG audio layer 3
 D A    mp3             MP3 (MPEG audio layer 3)
 D A    mp3adu          ADU (Application Data Unit) MP3 (MPEG audio layer 3)
 D A    mp3on4          MP3onMP4
 text2movsub remove_extra noise mov2textsub mp3decomp mp3comp mjpegadump imxdump h264_mp4toannexb dump_extra

答案1

您实际上想要的是来自以下的输出:

ffmpeg -codecs | grep libmp3lame

如果没有的话你很可能需要重新编译并添加缺失的内容:

--enable-libmp3lame

并且为了更好的衡量:

--enable-gpl --enable-version3

除了 -acodec copy 等之外...如果您简单地执行以下操作会发生什么:

ffmpeg -i file.avi -t 90 output.avi

相关内容