ffmpeg 无法转换音频

ffmpeg 无法转换音频

我正在尝试转换我的视频文件。这是

Input #0, avi, from 'file.mpg':
  Metadata:
    encoder         : MEncoder SVN-r37289
  Duration: 01:32:15.60, start: 0.000000, bitrate: 123104 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16, 224 kb/s

文件本身运行良好,声音效果也很棒。但不幸的是,每当我尝试执行 ffmpeg 转换此视频时,输出文件都没有音频(这不是因为 -map)。

即使我尝试将音频(没有视频)提取到另一个文件,它也会产生没有音频的音轨。以下是我使用纯音频转换的几个示例(无论我想使用什么目标格式都没有关系):

 $ ffmpeg -i abi.mpg -map 0:1 output.mp3 
Input #0, avi, from 'abi.mpg':
  Metadata:
    encoder         : MEncoder SVN-r37289
  Duration: 01:32:15.60, start: 0.000000, bitrate: 123104 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 122872 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 224 kb/s
File 'output.mp3' already exists. Overwrite ? [y/N] y
Output #0, mp3, to 'output.mp3':
  Metadata:
    TSSE            : Lavf56.4.101
    Stream #0:0: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s16p
    Metadata:
      encoder         : Lavc56.1.100 libmp3lame
Stream mapping:
  Stream #0:1 -> #0:0 (mp2 (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
size=       3kB time=00:01:20.66 bitrate=   0.3kbits/s    
video:0kB audio:3kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.779762%

你看!3kB 的文件大小播放时间为 1 分 20 秒,如果我尝试播放源文件,声音播放效果很好。

这里甚至还有调试输出:

 $ ffmpeg -i file.mpg -ss 8 -c:a libfaac -b:a 192k -map 0:1 output.m4a
Input #0, avi, from 'file.mpg':
  Metadata:
    encoder         : MEncoder SVN-r37289
  Duration: 01:32:15.60, start: 0.000000, bitrate: 123104 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 122872 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 224 kb/s
File 'output.m4a' already exists. Overwrite ? [y/N] y
Output #0, ipod, to 'output.m4a':
  Metadata:
    encoder         : Lavf56.4.101
    Stream #0:0: Audio: aac (libfaac) (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 192 kb/s
    Metadata:
      encoder         : Lavc56.1.100 libfaac
Stream mapping:
  Stream #0:1 -> #0:0 (mp2 (native) -> aac (libfaac))
debug=1     8kB time=00:04:10.07 bitrate=   0.3kbits/s    
debug=2     8kB time=00:04:26.19 bitrate=   0.3kbits/s    
debug=4     9kB time=00:04:42.34 bitrate=   0.3kbits/s    
debug=8     9kB time=00:04:42.34 bitrate=   0.3kbits/s    
size=      12kB time=00:05:46.84 bitrate=   0.3kbits/s    
video:0kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.049674%
Input file #0 (abi.mpg):
  Input stream #0:0 (video): 9655 packets read (5932032000 bytes); 
  Input stream #0:1 (audio): 24 packets read (16128 bytes); 24 frames decoded (27648 samples); 
  Total: 9679 packets (5932048128 bytes) demuxed
Output file #0 (output.m4a):
  Output stream #0:0 (audio): 25 frames encoded (25600 samples); 26 packets muxed (11193 bytes); 
  Total: 26 packets (11193 bytes) muxed
24 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x1ab91a0] Statistics: 30 seeks, 49 writeouts
[AVIOContext @ 0x1afc500] Statistics: 5954303224 bytes read, 369 seeks

难道我做错了什么?

upd1. 这是 ffmpeg 信息:

ffmpeg version 2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct  5 2014 09:31:05 with gcc 4.9.1 (Debian 4.9.1-16)
  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-libiec61883 --enable-libfdk-aac --enable-vaapi --enable-libx265 --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
Hyper fast Audio and Video encoder

答案1

在 mp2 -> any 转换过程中,ffmpeg 计算的时间范围不正确。这就是为什么转换中断后产生的音轨太短而听不到,而且似乎是空的。

运行完整的转换产生了良好的输出。

相关内容