Convert movies with ffmpeg

ffmpeg -i input.mkv \
       -c:v libx264 -profile:v baseline -level 4.0 -crf 22 \
       -pix_fmt yuv420p -movflags +faststart -c:a aac -b:a 128k \
       ~/output.mp4

This command converts an input file into an MP4 file suitable for broad web and device compatibility: it re-encodes the video stream with the H.264/AVC codec using the libx264 encoder, applies the "baseline" profile and level 4.0 to ensure playback on older or less capable devices (e.g., early Android, basic media players), sets a constant rate factor of 22 for good visual quality with reasonable file size, forces a pixel format of yuv420p for universal video player support, adds the +faststart flag to relocate the moov atom to the beginning of the file for faster streaming and playback initiation, and finally re-encodes the audio to AAC with a bitrate of 128 kbit/s.

back to main page