

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. Since this involves compressing the file, it will take (much longer) than the first method.A cross-platform solution to record, convert and stream audio and video. h264 video and aac audio compression: ffmpeg -i input1.mp4 -i input2.avi -c copy -map 1:v:0 -map 0:a:0 -shortest -c:v mpeg4 -c:a aac output.mp4 If you want to convert (and compress) the file in one operation, you can use this one-liner to export an MP4 file with. Note that this is a lossless (and fast) procedure, it will just copy the content from the source files. The output.avi file will have the same video content as input2.avi, but with audio from input1.mp4. Then you can use this one-liner to copy the audio from one file to the other: ffmpeg -i input1.mp4 -i input2.avi -c copy -map 1:v:0 -map 0:a:0 -shortest output.avi
