为什么 MP3 可以运行,但是无法使用 FFmpeg 将 FLV 转换为 MP4 格式?

为什么 MP3 可以运行,但是无法使用 FFmpeg 将 FLV 转换为 MP4 格式?

事实上我已经成功将 FLV 转换为 MP3:

D:\tmp\ffmpeg-20121005-git-d9dfe9a-win64-static\ffmpeg-20121005-git-d9dfe9a-win
4-static\bin>ffmpeg.exe -i a.flv -acodec mp3 a.mp3
ffmpeg version N-45080-gd9dfe9a Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct  5 2012 16:49:01 with gcc 4.7.1 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-run
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass
-enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-
ibfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopen
peg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libthe
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-l
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --en
ble-zlib
  libavutil      51. 73.102 / 51. 73.102
  libavcodec     54. 63.100 / 54. 63.100
  libavformat    54. 29.105 / 54. 29.105
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, flv, from 'a.flv':
  Metadata:
    metadatacreator : iku
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : false
    datasize        : 16906383
    videosize       : 14558526
    audiosize       : 2270465
    lasttimestamp   : 530
    lastkeyframetimestamp: 529
    lastkeyframelocation: 16893721
  Duration: 00:08:49.73, start: 0.000000, bitrate: 255 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p, 448x336 [SAR 1:1 DAR 4:3], 218 kb
s, 15 tbr, 1k tbn, 30 tbc
    Stream #0:1: Audio: aac, 44100 Hz, stereo, s16, 32 kb/s
File 'a.mp3' already exists. Overwrite ? [y/N] y
Output #0, mp3, to 'a.mp3':
  Metadata:
    metadatacreator : iku
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : false
    datasize        : 16906383
    videosize       : 14558526
    audiosize       : 2270465
    lasttimestamp   : 530
    lastkeyframetimestamp: 529
    lastkeyframelocation: 16893721
    TSSE            : Lavf54.29.105
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16
Stream mapping:
  Stream #0:1 -> #0:0 (aac -> libmp3lame)
Press [q] to stop, [?] for help
size=    8279kB time=00:08:49.78 bitrate= 128.0kbits/s
video:0kB audio:8278kB subtitle:0 global headers:0kB muxing overhead 0.006842%

但是我没能将 FLV 转换为 MP4。为什么编码器“mp4”未知?此外,如何找到我的 FFmpeg 已经支持的编解码器?

D:\tmp\ffmpeg-20121005-git-d9dfe9a-win64-static\ffmpeg-20121005-git-d9dfe9a-win6
4-static\bin>ffmpeg.exe -i a.flv -acodec mp4 aa.mp4
ffmpeg version N-45080-gd9dfe9a Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct  5 2012 16:49:01 with gcc 4.7.1 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass -
-enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-l
ibfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenj
peg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena
ble-zlib
  libavutil      51. 73.102 / 51. 73.102
  libavcodec     54. 63.100 / 54. 63.100
  libavformat    54. 29.105 / 54. 29.105
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, flv, from 'a.flv':
  Metadata:
    metadatacreator : iku
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : false
    datasize        : 16906383
    videosize       : 14558526
    audiosize       : 2270465
    lasttimestamp   : 530
    lastkeyframetimestamp: 529
    lastkeyframelocation: 16893721
  Duration: 00:08:49.73, start: 0.000000, bitrate: 255 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p, 448x336 [SAR 1:1 DAR 4:3], 218 kb/
s, 15 tbr, 1k tbn, 30 tbc
    Stream #0:1: Audio: aac, 44100 Hz, stereo, s16, 32 kb/s
Unknown encoder 'mp4'

编辑1

[bigmeow@home bin]$ ./ffmpeg -formats | wc -l
ffmpeg version N-45533-gb08273c Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 15 2012 17:59:59 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-52)
  configuration: --disable-yasm --prefix=/var/lib/gforge/chroot/home/users/mirror/ins/ins-ffmpeg
  libavutil      51. 76.100 / 51. 76.100
  libavcodec     54. 66.100 / 54. 66.100
  libavformat    54. 32.101 / 54. 32.101
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
221

编辑2:无法使用 libfaac 编解码器,为什么?

4-static\bin>ffmpeg -i a.flv -c:a libfaac -vn aa2x.m4a
ffmpeg version N-45080-gd9dfe9a Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct  5 2012 16:49:01 with gcc 4.7.1 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass -
-enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-l
ibfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenj
peg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena
ble-zlib
  libavutil      51. 73.102 / 51. 73.102
  libavcodec     54. 63.100 / 54. 63.100
  libavformat    54. 29.105 / 54. 29.105
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, flv, from 'a.flv':
  Metadata:
    metadatacreator : iku
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : false
    datasize        : 16906383
    videosize       : 14558526
    audiosize       : 2270465
    lasttimestamp   : 530
    lastkeyframetimestamp: 529
    lastkeyframelocation: 16893721
  Duration: 00:08:49.73, start: 0.000000, bitrate: 255 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p, 448x336 [SAR 1:1 DAR 4:3], 218 kb/
s, 15 tbr, 1k tbn, 30 tbc
    Stream #0:1: Audio: aac, 44100 Hz, stereo, s16, 32 kb/s
Unknown encoder 'libfaac'

D:\tmp\ffmpeg-20121005-git-d9dfe9a-win64-static\ffmpeg-20121005-git-d9dfe9a-win6

答案1

为什么不能“转换为 MP4 视频”:

这就是为什么它不起作用的原因:

这就是您无法编码为“MP4”的原因——没有这样的音频编解码器。要了解区别,请阅读以下内容:什么是编解码器(例如 DivX?),它与文件格式(例如 MPG)有何不同?


如何在 MP4 中编码为 AAC 音频:

要编码为 AAC 音频(完全不包含视频),您有多种选择,例如内置 AAC 编码器:

ffmpeg -i a.flv -c:a aac -strict -2 -vn aa.m4a

您必须包括-vn选项,因为 FFmpeg 会假设使用 MP4 容器时,你需要同时使用音频视频流编码。-vn禁用视频编码。

如果您想要同时获得视频和音频,只需删除该-vn选项并.mp4再次选择扩展名。FFmpeg 现在将用于libx264对视频进行编码。


如何控制质量

为了控制输出质量,请使用-b:a提供比特率,例如-b:a 192k


如何获取编解码器列表:

最后,找出 FFmpeg 可以解码(D)或编码(E)的编解码器:

ffmpeg -codecs

找出 FFmpeg 可以读取 ( D) 或写入 ( E) 的容器:

ffmpeg -formats

* 就您的具体情况而言,只有libvo_aacenc启用,libfaac没有启用。这是因为它不是使用您的静态 Windows 版本进行编译的。

相关内容