1

In fact I have succeeded to convert FLV to 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%

But I failed to convert FLV to MP4. Why is the encoder 'mp4' unknown? What's more, how can I find the codecs which are already supported by my 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'

Edit 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

Edit 2: cannot use libfaac codec, why?

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
0

1 Answer 1

6

Why you can't "convert to MP4 video":

Here's why it doesn't work:

  • What you know as "MP3" is MPEG-2 Layer III, an audio codec, and also the name of the container the codec is often stored in. It'll give you .mp3 files.

  • MP4 is not a codec. MP4 is the name of the MPEG-4 Part 14 container, which can store MPEG-4 Part 2 video (such as XviD), MPEG-4 Part 10 video (such as x264), or MPEG-4 audio in .mp4 files. MPEG-4 audio is called Advanced Audio Coding (AAC) and can also be stored in .m4a – it's just a different extension but the same container.

This is why you can't encode to "MP4" – there's no such audio codec. To understand the difference, please read the following: What is a Codec (e.g. DivX?), and how does it differ from a File Format (e.g. MPG)?


How to encode to AAC audio in MP4:

To encode to AAC audio – without the video at all – you have various options, such as the built-in AAC encoder:

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

You have to include the -vn option because FFmpeg will assume with an MP4 container you want both audio and video streams encoded. -vn disables video encoding.

If you want video along with the audio, simply remove the -vn option and choose .mp4 as an extension again. FFmpeg will now use libx264 to encode the video.


How to control the quality

To control the output quality, use -b:a to supply a bitrate, e.g. -b:a 192k.


How to get a list of codecs:

Finally, to find out what codecs FFmpeg can decode (D) or encode (E):

ffmpeg -codecs

And to find out the containers FFmpeg can read (D) or write (E):

ffmpeg -formats

* In your exact case, only libvo_aacenc is enabled, libfaac is not. This is because it wasn't compiled with your static Windows build.

10
  • why some of ffmpeg output is not catch by pipe? (see edit 1)
    – hugemeow
    Oct 15, 2012 at 10:08
  • 1
    FFmpeg writes to stderr for whatever reason – you have to redirect output with ffmpeg -formats 2>1 | … or ffmpeg -formats 2>&1 | … depending on what you want.
    – slhck
    Oct 15, 2012 at 10:25
  • why it don't write to stdout rather than stderr, i don't think this is kind of error information...
    – hugemeow
    Oct 15, 2012 at 10:37
  • 1
    Don't ask me why, I have no idea :) Of course it'd make sense to print everything to stdout instead.
    – slhck
    Oct 15, 2012 at 10:44
  • why you choose m4a extension rather than mp4 extension? seems if -vn option is used, i cannot get the video parts, where can i find the detailed description of options such as -vn? btw, why i cannot use libfaac codec? see edit2 :)
    – hugemeow
    Oct 15, 2012 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .