Home > FFmpeg, Video > Optimised x264 Encoding with FFmpeg

Optimised x264 Encoding with FFmpeg

A request on the Ubuntu forums asked for some assistance creating x264 files from footage originating on DVD. The following FFmpeg command represents input from a couple of users regarding what might be the best options:

ffmpeg -y -i input_file -an -v 1 -threads auto -vcodec libx264 -deinterlace -b 5000k -bt 175k -flags +loop -coder ac -refs 1 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me epzs -subq 1 -me_range 21 -chroma 1 -slice 2 -bf 3 -b_strategy 1 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 5000k -bufsize 2M -cmp 1 -s 720x480 -f mp4 -pass 1 /dev/null

ffmpeg -y -i input_file -v 1 -threads auto -vcodec libx264 -deinterlace -b 5000k -bt 175k -flags +loop -coder ac -refs 5 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me full -subq 6 -me_range 21 -chroma 1 -slice 2 -bf 3 -b_strategy 1 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 5000k -bufsize 2M -cmp 1 -s 720x480 -acodec libfaac -ab 256k -ar 48000 -ac 2 -f mp4 -pass 2 new_file.mp4

This command, as an overview does the following:

  • Uses libx264 as the output video codec
  • Uses libfaac as the output audio codec
  • Deinterlaces the original DVD sourced footage
  • Allows FFmpeg to choose the number of threads to use for multi-core systems
  • Sets the output video bitrate at 5000kbps (or roughly 5Mbps)
  • Sets the output audio bitrate at 256kbps
  • Deblocks the output footage
  • Uses CABAC encoding
  • Uses .mp4 as the output file container
  • Uses B-Frames
  • Uses 2 pass encoding - directing the first output to /dev/null and the second pass to a new file

There are of course many other options included in this command. Further useful reading can be found on the FFmpeg documentation page:

http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html

Also, this Mencoder specific page has some useful information regarding encoding using x264:

http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html

About these ads
Categories: FFmpeg, Video Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: