Sudhakar Rayavaram
Problem solver (And maker),
Inquisitive (Root to most of my problems),
Software craftsman (Don't ask for estimates)

Works at TarkaLabs

Tech guy behind

Encoding MPEG-4 videos for S40 devices
30 Dec 2013

You bought a brand new phone with S40 OS and it promised all things like video playback for a dozen of formats like 3GPP formats (H.263), H.264/AVC, MPEG-4, WMV, ABC, blah blah…. great! So, you copy an MPEG-4 format video file and play it… Wham! “Video Not Supported”… What the… Your shiny new phone doesn’t look that shiny anymore right?

You are not alone! At least you have my company… MPEG-4/H.264 encoding is a bit complicated format with so many variations because of its different profiles & levels

Unfortunately many entry and mid segment devices (Example: Nokia Asha series phones) does not add support for all the variants…

So are we left to rot with our S40 phones without videos? No! Definitely not! So, we wear our explorer gear and stop not till we find the solution… searching… searching… resting…. searching…. scratching head…. searching… aaaahhhh…. here it is….   Handbrake our saviour… So lets go ahead and apply the hand brake to zip forward our hurdle… that was one weird statement!

Mac users, you have one more hurdle to pass. Handbrake dmg version for mac does not have controls to tweak the MPEG-4 to match S40, So you should install HandbrakeCLI (command line interface)

I am going to explain here the command I used for command line interface, I think GUI version for windows has provision to pass these parameters in advanced tab

Here are the things I did to get the videos work in Nokia Asha 200 (Note this really cool site maintained by Nokia with complete specs for ALL its phones)

  1. Install HandbrakeCLI
  2. Open terminal and run the following command:
HandBrakeCLI -e x264 --x264-profile baseline -X 176 --keep-display-aspect -r 15 -q 20 -B 64 -i input_file_path  -o output_file_path


    -e x264                 -> encoding format (x264 stands for MPEG-4)
    --x264-profile baseline -> x264 profile (could also try 'main' profile)
    -X 176                  –> Maximum width of the video (I chose 176px)
    –Keep-display-aspect    –> Maintains the aspect ratio of the input video
    -r 15                   –> frame rate (check your phone specs for supported video playback frame rate.
                            I chose 15 frames per second)
    -q 20                   –> Video quality (0 to 51 where 0 is for high quality and 51 for lowest.
                            20 is standard definition)
    -B 64                   –> Audio quality in bitrate (64 stands for 64kbps)

Play around with different values that suits your phone… Have fun!