Contact

Technology

Dec 30, 2008

Using FFMpeg to Encode Movies for the iPhone

Vikalp Jain

Vikalp Jain

Default image background

FFmpeg (http://www.ffmpeg.org/) is a great tool for encoding movies in any format and works nicely for encoding movies for the iPhone. The main issue we ran into was finding the right parameters for FFMpeg. As is the case with most open source projects, the documentation for FFMpeg is sparse. From Apple’s documentation we knew the specifications for encoding were:

  • MP4 file format

  • H.264 Baseline Profile Level 3.0 video, up to 640 x 480 at 30 fps. Note that B frames are not supported in the Baseline profile.

  • MPEG-4 Part 2 video (Simple Profile)

Our own requirements were to produce two encodings, a full size one for the web and a secondary one that was optimized for the iPhone. We tried several different combinations, gathered from various forums and blogs, before we were able to find the right set. The parameters that worked successfully for us are:

[code lang=”C”]/usr/local/bin/ffmpeg -i $INPUT -acodec libfaac -vcodec libx264 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me_method umh -subq 5 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bufsize 2M -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -vb 1500k -ab 128k $OUTPUT_WEB -vcodec libx264 -s 480×320 -ab 64k -vb 480k $OUTPUT_IPHONE[/code]

Conversation Icon

Contact Us

Ready to achieve your vision? We're here to help.

We'd love to start a conversation. Fill out the form and we'll connect you with the right person.

Searching for a new career?

View job openings