In this article we will show you how to convert any video supported by the FFMPEG software to 3GP format.
The 3GP format is a multimedia container file format that was developed to be used on 3G mobile phones but is also used on 2G and 4G phones. It can include video, audio and timed text. We will be using FFMPEG to convert from any video supported by the software into a 3GP valid file.
The 3GP file format stores video streams as H.263 or H.264 codecs and various audio streams format are allowed. We will see some of these.
One important limitation of this format is the resolution of the converted video (as long as it is using H.263 codec). As 3GP format was developed to work on 3G mobile phones so it can work only with sizes of 128x96, 176x144, 352x288, 704x576 or 1408x1152 pixels in its basic configuration using the H.263 codec.
We can convert any supported video by FFMPEG with the command:
ffmpeg -i input_video.avi output_video.3gp
FFMPEG will detect 3GP format on the output file and will use some basic configration encoding the video using H.263 encoder and AMR-NB audio encoder. If you want to specify the options you can use:
ffmpeg -i input_video.avi -f 3gp -vcodec h263 -acodec amr_nb output_video.3gp
We are using the parameters:
- -f 3gp which specifies that the output file format is 3GP.
- -vcodec h263 which specifies that the output file will use H.263 codec for video stream.
- -acodec amr_nb which specifies that the output file will use AMR_NB codec for audio stream.
Notice that you have the limitation of the video resolution that we have said before. Also with the audio codec you have some limitations as the audio must be in mono and not in stereo, and the sample rate of the audio must be 8000Hz. (Remember that 3GP was designed to work on mobile phones so it didn't need stereo or high quality audio).
Addressing input video file limitations
So if you want to convert any video into this 3GP format using H.263 and AMR_NB codecs you should need to resize the video, and to convert the audio into a supported audio stream. This is done by the FFMPEG command:
ffmpeg -i input_video.avi -f 3gp -vcodec h263 -vf scale=352x288 -acodec amr_nb -ar 8000 -ac 1 output_video.3gp
- -f 3gp same as before, we specify that the output file format is 3GP
- -vcodec h263 which specifies output file using H.263 encoder.
- -vf scale=352x288 which will resize the image from the input video into a 352x288px size. This is one of the sizes allowed by H.263 codec, but you can use the one you want from the list of supported sizes (128x96, 176x144, 352x288, 704x576 or 1408x1152). If the input video is in a different aspect ratio size, FFMPEG will add outer black boxes mantaining the original video aspect ratio and using the new size. Know more about resizing videos using FFMPEG.
- -acodec amr_nb which specifies output audio codec
- -ar 8000 will convert audio streams into 8000Hz audio streams. This is required by the AMR_NB encoder.
- -ac 1 will transform audio from stereo into mono. This is also required by the AMR_NB encoder.
Using H.264 codec and AAC in the output file
You can use H.264 codec with libx264 library to produce a valid 3GP file (well, in fact it is valid and it is very extended the use of this codec in the 3GP formta). You can also use AAC audio format in the output file. Use this command:
ffmpeg -i input_video.avi -f 3gp -vcodec libx264 -acodec aac output_video.3gp
- -f 3gp which specifies that the output file will be using 3GP format.
- -vcodec libx264 which specifies that we want to use libx264 encoder which will produce H.264 encoded streams. There's more information about this powerfull encoder in out article about How to Convert Videos to MP4 format.
- -acodec aac which specifies that audio streams will be encoded using AAC encoder.
Notice that when using this codecs you don't have limitations over video resolution or limitations over audio from the original file. In the end you will be producing a video file similar to one file in MP4 format (as it uses H.264 and AAC streams as its usual configuration) but using 3GP format. Most modern terminals can use this configuration and it is usual that they can use it better than the basic 3GP format (with H.263 and AMR_NB). If you want to know more about H.264 encoding using FFMPEG you can read our article on How to Convert Videos to MP4 format.
Did you find this article helpful?