4

I am able to convert from .mp3 files to .wav files.

me@me-desktop:~$ ffmpeg -i Desktop/input.mp3 Desktop/output.wav
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1.1 --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 31 2011 18:53:20, gcc: 4.4.3
[mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 0
    Last message repeated 1 times
[mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 1
    Last message repeated 1 times
Input #0, mp3, from 'Desktop/input.mp3':
  Duration: 00:04:45.31, start: 0.000000, bitrate: 256 kb/s
    Stream #0.0: Audio: mp3, 48000 Hz, stereo, s16, 256 kb/s
Output #0, wav, to 'Desktop/output.wav':
    Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
[mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 0
    Last message repeated 1 times
[mp3 @ 0x9449510]mdb:511, lastbuf:0 skipping granule 1
size=   42944kB time=229.03 bitrate=1536.0kbits/s    
video:0kB audio:42944kB global headers:0kB muxing overhead 0.000100%

However when I try to convert the same .wav file back to an .mp3 I get the following error: Unsupported codec for output stream #0.0

me@me-desktop:~$ ffmpeg -i Desktop/output.wav Desktop/output2.mp3
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1.1 --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 31 2011 18:53:20, gcc: 4.4.3
Input #0, wav, from 'Desktop/output.wav':
  Duration: 00:03:49.03, bitrate: 1536 kb/s
    Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Output #0, mp3, to 'Desktop/output2.mp3':
    Stream #0.0: Audio: 0x0000, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Unsupported codec for output stream #0.0

I've already tried installing unstripped-51 per a suggestion from a previous question but I am still unable to convert from .wav to .mp3

user784637
  • 15,392
  • 32
  • 93
  • 156

1 Answers1

10

I suggest to use lame:

lame -b 192 -h input.wav output.mp3  # bitrate 192, highest quality

If you don't have it, apt-get install lame.

For more options and/or examples see man lame.

Michał Šrajer
  • 30,364
  • 7
  • 62
  • 85
  • That works! By the way Michal is there any way to crop 30 seconds of an mp3 that starts at the 60 second mark using lame? Essentially I'm looking for the equivalent of this: http://stackoverflow.com/questions/43890/crop-mp3-to-first-30-seconds – user784637 Sep 19 '11 at 00:03
  • More specifically is there an equivalent of the "-acodec copy" option that does not actually transcode the mp3? – user784637 Sep 19 '11 at 00:05
  • 1
    @LedZeppelin: I don't think so. But you can do it with cutmp3. see my post: http://stackoverflow.com/questions/43890/crop-mp3-to-first-30-seconds/7465346#7465346 cutmp3 manuals says it does it without quality loss, so I assume it's similar to `-acodec copy`. – Michał Šrajer Sep 19 '11 at 00:16
  • Thanks again Michael. I just wanted to point out that I used both ffmpeg and cutmp3 to take out a part of a song from a certain start and end point. In my tests ffmpeg was off by up to 3 seconds from the start and end point when cropping an mp3 without transcoding. However cutmp3 cropped from the start and end points without being off at all. – user784637 Sep 19 '11 at 00:47