HOWTO: Convert 3GP to AVI
Sunday June 17, 2007
Some people seem to believe you need a special kind of voodoo to get videos off your mobile phone and into a media player.
With some rudimentary understanding of video codecs/formats, anyone can do this for free. That’s right – no charge, no shady shareware, no dodgy code houses charging the earth for a button – none of that thank you…
FFMPEG recently changed how it handles AMR (Adaptive Multirate Encoding – a proprietary codec), that makes things in this department far less confusing. Grab the latest source tree from their SVN), or the windows binary if you’re on windows.
If you’re compiling from source, a lot of webpages will instruct you to use —enable-amr_X. It’s rubbish, FFMPEG recently switched to using pre-built libraries (Shared Objects, or DLLs to users of Windows) for handling AMR.
Use —enable-libamr-nb —enable-libamr-wb as configure flags instead, after downloading and compiling the source to those libraries (make && make install).
Of course, all of this is outlined in the FFMPEG documentation, so refer yourself there for a finely grained guide to this.
From the command line, run:
ffmpeg -i some_input_file.3gp -f avi -acodec mp3 some_output_file.avi
You can do “man ffmpeg” on linux to see all the switches. Search that phrase on google if you can’t find the documentation in your windows build package. For example, you could use -vcodec mpeg4 to change the video encoding.
Note: if you get a warning about bitrate, just add three zeros (“000”) to the end of your parameter, so 250 becomes 250000 – alternatively, the sensible thing is to multiply by 1024 (250*1024 = 256000). -b specifies in Bits/s not KBits, so ffmpeg is just warning you that the value you entered is too low.
Update: 2008/02/06 (6th Feb)
It’s worth pointing out that in order to compile FFMPEG with libamr support, you now have to use the following flag
--enable-nonfree
In case that wasn’t clear from the standard output. If you want to see an explanation of why, please see this mailing list post by Diego Biurrun.
7 Responses to "HOWTO: Convert 3GP to AVI"
Jun 27, 04:44 PM
I’ve just realised a lot of this assumes a fair bit of background knowledge…
I guess if enough people ask for a better version I could rework some of the specifics in this article. The main point in the first place was to elucidate that ffmpeg recently changed to using pre-built libraries from AMR codecs, and there’s a lot of misinformed documentation floating about with the old —enable-amr-X flags.
Dec 20, 04:47 PM
When I run this command I get an error as follows:
ffmpeg -i 1.3gp -acodec mp3 1.avi
FFmpeg version SVN-rUNKNOWN, Copyright© 2000-2006 Fabrice Bellard, et al. configuration: —prefix=/usr —libdir=/usr/lib64 —mandir=/usr/share/man —incdir=/usr/include/ffmpeg —extra-cflags=-fPIC —enable-mp3lame —enable-libogg —enable-vorbis —enable-faad —enable-faac —enable-libgsm —enable-xvid —enable-x264 —enable-a52 —enable-a52bin —enable-dts —enable-pp —enable-shared —enable-pthreads —enable-gpl —disable-strip libavutil version: 49.1.0 libavcodec version: 51.28.0 libavformat version: 51.7.0 built on Jun 4 2007 14:17:13, gcc: 3.4.6 20060404 (Red Hat 3.4.6-8)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ’1.3gp’: Duration: 00:02:06.7, start: 0.000000, bitrate: 136 kb/s Stream #0.0(eng): Video: mpeg4, yuv420p, 160×128, 30.00 fps® Stream #0.1(eng): Audio: samr / 0×726D6173, 8000 Hz, mono
Output #0, avi, to ’1.avi’: Stream #0.0: Video: mpeg4, yuv420p, 160×128, q=2-31, 200 kb/s, 30.00 fps© Stream #0.1: Audio: 0×0000, 8000 Hz, mono, 64 kb/s
Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1
Unsupported codec for output stream #0.1
From inspecting the file it looks like ffmpeg does not know what to do with the ‘samr’ audio codec:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ’1.3gp’: Duration: 00:02:06.7, start: 0.000000, bitrate: 136 kb/s Stream #0.0(eng): Video: mpeg4, yuv420p, 160×128, 30.00 fps® Stream #0.1(eng): Audio: samr / 0×726D6173, 8000 Hz, mono
I am not sure how to fix this.
Dec 21, 09:19 PM
Hi Kevin,
Are you on windows or *nix? Did you compile FFMpeg yourself from source? Looking at your “configuration: ...” details, your ffmpeg binary hasn’t been compiled with libamr support.
Follow the links above to get the source code from their subversion repository. Download libamr, and use the compiled libraries by passing —enable-libamr-nb —enable-libamr-wb to your “configure” command.
If none of that makes any sense, or you’re on Windows, you might need different instructions. Post back if you’re still having difficulties…
Jan 17, 11:50 AM
Hi!
I’ve compiled ffmpeg as you write in this post, but it not support amr audio. If I list the codecs/formats with ffmpeg -formats the amr only in File formats, and bot in codecs. Here’s I get the same error message as Kevin, but I build with libamr-nb and libamr-wb:
FFmpeg version UNKNOWN, Copyright © 2000-2008 Fabrice Bellard, et al. configuration: —enable-libmp3lame -enable-libamr-nb —enable-libamr-wb libavutil version: 49.6.0 libavcodec version: 51.49.0 libavformat version: 52.4.0 libavdevice version: 52.0.0 built on Jan 17 2008 12:54:07, gcc: 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘MOV00158.3GP’: Duration: 00:00:56.0, start: 0.000000, bitrate: 136 kb/s Stream #0.0(jpn): Video: h263, yuv420p, 176×144 [PAR 12:11 DAR 4:3], 29.97 tb® Stream #0.1(jpn): Audio: samr / 0×726D6173, 8000 Hz, mono
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, flv, to ‘teszt2.flv’: Stream #0.0(jpn): Video: flv, yuv420p, 320×240 [PAR 1:1 DAR 4:3], q=2-31, 0 kb/s, 12.00 tb© Stream #0.1(jpn): Audio: libmp3lame, 22050 Hz, mono, 0 kb/s
Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1
Unsupported codec (id=73728) for input stream #0.1
ffmpeg -formats | grep amr output is: DE amr 3gpp amr file format
no samr there
System is Linux – Debian Etch on x86
Jan 17, 04:07 PM
Hey,
Sounds like support is compiled in but the linker isn’t picking up the library. Try following this mailing list post and it should fix the situation.
For reference, mine used to pick up “samr” as the fourcc ID, but if the library is installed/linked correctly, it should give “libamr_nb” (or similar).
May 15, 01:13 AM
I had similar problems to Kevin and csibra after removing the default Ubuntu ffmpeg package under Ubuntu 8.04 and recompiling. The default package did have amr support (but no libmp3lame).
This might be obvious but the problems I had were simply caused by duplicate ffmpeg builds in the /usr/local/lib&bin and /usr/lib&bin directories. The Ubuntu path setup was different to the default ffmpeg and libamr path targets. Make sure you have either cleaned out old libraries before building or that you set the —prefix configure option when building libamr* and ffmpeg.
Aug 1, 10:34 PM
The following command (acodec argument changed), worked for me:
ffmpeg -i in.3gp -f avi -acodec libmp3lame out.avi
I also followed this page, which details how to compile the three different components from source:
http://www.mattiouz.com/blog/2007/07/02/how-to-install-ffmpeg-with-mp3-and-amr-support/
But you need to look near the end of the comments to fine the —enable-nonfree command line switch mentioned.