noinput

  • Ping Me
  • Archive
  • RSS
  • Ask me anything

FFMPEG, A breakdown of settings

Recently for a project I was tasked with the challenge to setup a server distribution to handle any video upload, transcode it to MP4 with autostart capabilities and get it looking great on Apple/Android devices.  I accepted the challenge, and was it ever fun.  I’m not going to get into the gritty details of setting up FFMPEG on a linux machine, but after a few good hours of package installation on a Rack Cloud Debian machine, i got a really solid system running, all that was left was to write the commands to process the file uploads.

Conversion
The goal here was not only to get a small file size, decent bitrate and audio, but also keep the audio/video in sync & get it fully compatible for iPhone/iPad/Android devices.

/usr/bin/ffmpeg -i /var/dir/in_file.mov -r 24 -vsync 1 -async 1 -acodec libfaac -ab 128kb -vcodec libx264 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 560x336 -title MetaTitleName /var/dir/outfile_tmp.mp4

The keys to my success on this were as follows:

  • -r 24 -vsync 1 -async 1 helped to solve sync issues with the audio/video. I think the win here is to specify the hard framerate with the -async -vsync switches for it to work best
  • -acodec libfaac ensured that there was a compatible audio stream for Apple devices
  • -vcodec libx264 again, many to choose from but h264 was a great choice and ensured playback properly for Apple devices

Faststart
It’s always a pain when you have to sit there and wait for a file to download all the way before the packet of information is found at the end telling the video to start.  Just doing an mp4 conversion isn’t enough, you need to introduce the gt-faststart command which does some lovely magic and allows an immediate download. 

/usr/bin/qt-faststart /var/dir/outfile_tmp.mp4 /var/dir/outfile_final.mp4 

Simple, but very effective.  

    • #ffmpeg
    • #video
    • #conversion
    • #transcoding
    • #faststart
    • #gt-faststart
    • #apple
    • #android
    • #sync issues
    • #out of sync
  • 11 months ago
  • 5
  • Comments
  • Permalink
  • Share
    Tweet

About

Avatar I talk about things on the internets. Also the developer of tumtumapp.com (Free iPad client for Tumblr).

Me, Elsewhere

  • @noinput on Twitter
  • Facebook Profile
  • noinput on Vimeo
  • noinput on Youtube
  • noinput on Flickr
  • noinput on Delicious
  • noinput on Pinboard
  • noinput on Digg
  • noinput on Foursquare
  • Google
  • Linkedin Profile
  • noinput on github

Tweet Tweet

loading tweets…

Following

I Dig These Posts

  • Photo via imgfave
    Photo via imgfave
  • Photo via imgfave
    Photo via imgfave
  • Post via nfarina
    Git Is Simpler Than You Think

    It was about one year ago that we switched to Git. Previously, we used Subversion, through the Mac app Versions,...

    Post via nfarina
  • Post via chriseidhof
    "I've got an idea for an app"

    I’ve been an iPhone developer for over three years now. The first app I built was CookieCombo. We sold enough copies to...

    Post via chriseidhof
See more →
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr