How to Properly Convert Video Files to Early-Nokia-Compatible 3GP (QCIF H.263 / AMR-NB) Using FFmpeg Komeil for Windows

Most of the converted 3GP videos have a wrong aspect ratio, not to mention the audio incompatibility issue with different mobile phones from time to time. The following article describes fastidious details you should know, often omitted by converters while converting media to 3GP.

Since the early days of cameraphones, common 3GP video clips have been stored as QCIF-sized H.263 video and AMR-NB audio.

Video

QCIF (Quarter Common Intermediate Format) has a 174×144 dimension, and a 1.22:1 display aspect ratio. Having a squarer ratio comparing to normal 4:3 (1.33:1) and widescreen 16:9 (1.78:1) ratios, QCIF videos should be “padded” on top and bottom once converted from wider (nearly every other) sources.

Failing to properly pad a wider-than-QCIF video clip while converting to QCIF 3GP, you’ll end up with a squeezed video, meaning fat people will look thin, and cars will lose their proportions and look ridiculously tall.

Intervening precise height/padding calculations, FFmpeg requires even numbers for screen height, top padding, and bottom padding.

Height = Picture Height + Top Padding + Bottom Padding

Width = Height × Aspect Ratio

A standard 1.33:1 (4:3) video should be resized to 132 pixels in height and padded with 6 pixels in both top and bottom:

144 = 132 + 6 + 6

176 ≈ 132 × 1.33

A widescreen 1.78:1 (16:9) video should be resized to 100 pixels in height and padded with 22 pixels in both top and bottom:

144 = 100 + 22 + 22

176 ≈ 100 × 1.78

A flat widescreen 1.85:1 video should be resized to 96 pixels in height and padded with 24 pixels in both top and bottom:

144 = 96 + 24 + 24

176 ≈ 96 × 1.85

A CinemaScope 2.21:1 video should be resized to 80 pixels in height and padded with 32 pixels in both top and bottom:

144 = 80 + 32 + 32

176 ≈ 80 × 2.21

A wide cinema 2.35:1 video should be resized to 76 pixels in height and padded with 34 pixels in both top and bottom:

144 = 76 + 34 + 34

176 ≈ 76 × 2.35

Calculations Behind

NameAspect RatioExact DimensionsCalculationsHeightPaddings
QCIF1.22:1176×144.0000144-144.0000=0.0000÷2=0.00001440
Standard1.33:1 (4:3)176×132.0003144-132.0003=11.9997÷2=5.99981326
Widescreen1.78:1 (16:9)176×98.9998144-98.9998=45.0002÷2=22.500110022
Flat Widescreen1.85:1176×95.1351144-95.1351=48.8649÷2=24.43249624
CinemaScope2.21:1176×79.6380144-79.6380=64.3620÷2=32.18108032
Wide Cinema2.35:1176×74.8936144-74.8936=69.1064÷2=34.55327634

The maximum H.263 video bit rate for a flawless playback in an early Nokia is 339 kbps and the best practice for the frame rate is to use half its original. That is 12.5 fps (25÷2) for PAL and 14.895 fps (29.97÷2) for NTSC videos. Please note cheap 3GP/H.263/AMRNB-enabled Nokia cameraphones shoot QCIF video at 14.929 fps / 142 kbps.

Audio

The audio compatible with early Nokia phones is the monaural AMR-NB (Adaptive Multi-Rate Narrow-Band) with sample rate of 8000 and bit rate of 12.2 kbps.

FFmpeg 3GP Conversion Command

Important parameters including the “-f 3gp” forces the output format to 3GP, “-s 176xHEIGHT” defines video dimensions, “-aspect 176:144” corrects QCIF aspect ratio, “-padtop PADDING” and “-padbottom PADDING” define top and bottom paddings, “-vcodec h263” forces the video codec to H.263, “-b BITRATE” specifies the video bit rate, “-r FRAMERATE” specifies the video frame rate, “-acodec libamr_nb” forces the audio codec to AMR-NB, “-ac 1” specifies mono-channel (monaural) audio, “-ar 8000” specifies the audio sample rate, and “-ab 12.2k” specifies the 12.2 kbps audio bit rate.

Sample FFmpeg command to convert a PAL 4:3 AVI file into 3GP (H.263/AMR-NB):

ffmpeg -i test.avi -f 3gp -s 176x132 -aspect 176:144 -padtop 6 -padbottom 6 -vcodec h263 -b 339k -r 12.5 -acodec libamr_nb -ac 1 -ar 8000 -ab 12.2k -y output.3gp

Sample FFmpeg command to convert an NTSC 16:9 MP4 file into 3GP (H.263/AMR-NB):

ffmpeg -i test.mp4 -f 3gp -s 176x100 -aspect 176:144 -padtop 22 -padbottom 22 -vcodec h263 -b 339k -r 14.895 -acodec libamr_nb -ac 1 -ar 8000 -ab 12.2k -y output.3gp

Download FFmpeg for Windows with AMR Support

To download an AMR-enabled FFmpeg for Windows, visit my FFmpeg SVN-r17988-Komeil for Windows blog post.

2 thoughts on “How to Properly Convert Video Files to Early-Nokia-Compatible 3GP (QCIF H.263 / AMR-NB) Using FFmpeg Komeil for Windows

Leave a Reply

Your email address will not be published. Required fields are marked *

*