How to compress video for youtube using the free and fast ffmpeg.
There is little doubt that ffmpeg is one of the most powerful and efficient video conversion tools on the market. Rumor has it that google uses a version ffmpeg to compress its youtube videos on its servers. It is however a command line application, this can be a scary word, but do not worry this is a step by step how to.
Why convert?, Of course if you can get the format right on upload but you stand to lose the least amount of quality with a given file size if it is done right. The added plus youtube will not complain that it is in the wrong format.
todo: test if youtube prefers 30fps or 27.97fps.
Aparrently 30fps (and 24, 25, 50 and 60) is preferred.
These are the ffmpeg settings I use for upload to youtube:
ffmpeg -i input.mov -c:v libx264 -preset slow -crf 18 -c:a copy -pix_fmt yuv420p -movflags faststart output.mkv
time in front of this to benchmark stuff)
A little more advanced.
inputFile=input.mov; ffmpeg -i $inputFile -c:v libx264 -preset slow -crf 18 -c:a copy -pix_fmt yuv420p -movflags faststart $inputFile.mkv; open $inputFile.mkv
Apparently you will not notice any loss in quality at this crf setting of 18.
I use a crf of 21 for larger videos where absolute quality is not required.
This is one of the shell scripts that I use before I upload my videos to youtube:
time ffmpeg -i "$1" -c:v libx264 -preset slow -crf 21 -c:a copy -pix_fmt yuv420p -movflags faststart
If you want to install this as an easy to use script here is what you need to do:
Download the script files at the bottom of the page.
Open up terminal.
This will open the new folder in finder, drag the files from your download directory to this folder.
chmod +x youtubehigh.sh
add the scripts folder to your profile:
Edit in text edit and add
~/scripts to your path so it looks something like this:
# MacPorts Installer addition on 2012-11-20_at_14:09:39: adding an appropriate PATH variable for use with MacPorts.
# Finished adapting your PATH environment variable for use with MacPorts.
If for some reason you do not have a .profile file (perhaps you do not have macports) just type
touch .profile and this single line to it:
If all has gone well you should be able to navigate to the folder that has your video file and type:
Once finished the script will print out how long the task took to complete and open the file for you to enjoy.