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.
5 Notes/ Hide
-
homemadecrap likes this
-
noinput posted this