
High-quality encoding using -crf (Constant Rate Factor) and -preset:įfmpeg -i input.mp4 -preset slower -crf 18 output.mp4Ĭonvert a. Specify the codecs for both video (-c:v) and audio (-c:a)įfmpeg -i input.mp4 -c:v vp9 -c:a mp3 output.mkvĮncode the audio as mp3 and copy the video stream unchanged: ffmpeg -i input.mp4 -c:v copy -c:a mp3 output.mkv mkv (another container format):įfmpeg -i input.webm -c:av copy output.mkv

':av' is the default so this could also be specified with just -c copy:įfmpeg -i input.mkv -c:av copy output.mp4 Remux from MKV (a container format) into MP4 (another container format), lossless copy without re-encoding. See FFmpeg Wiki: H.264 and FFmpeg Wiki: AAC for more info.A cross-platform solution to record, convert and stream audio and video.

This allows the video to begin playing faster if it is watched via progressive download playback. -movflags +faststart is an option for MP4 output that move some data to the beginning of the file after encoding is finished.-vf format=yuv420p chooses YUV 4:2:0 chroma-subsampling which is recommended for H.264 compatibility.-b:a 160k encodes the audio with a bitrate of 160k.-c:a aac selects the audio encoder aac, which is the built-in FFmpeg AAC encoder.Use the highest value that gives an acceptable quality. -crf 20 selects a CRF value of 20 which will result in a high quality output.Use the slowest preset that you have patience for. -preset slow selects the slow x264 encoding preset.-c:v libx264 selects the video encoder libx264, which is a H.264 encoder.Add -c:a aac: ffmpeg -i input.avi -c:v libx264 -preset slow -crf 20 -c:a aac -b:a 160k -vf format=yuv420p -movflags +faststart output.mp4
