

mp3 (Windows CMD, see stackoverflow for bash and PowerShell versions.)įor %i in (*.mp4) do ffmpeg -i "%i" "%~ni.mp3"
#Google ffmpeg tutorial 720p
In this example, the size is divided by twice the value required and then multiplied by two to ensure the pixel size is a multiple of two, which is required for some codecs.Ĭhange the Sample Aspect Ratio (SAR) of a video from 720p to 540 (4:3):įfmpeg -i "input.mp4" -vf scale=720:540 -c:v "output.mp4"Ĭhange the Display Aspect Ratio (DAR) of a video from 720p to 540 (4:3) this sets a metadata flag at the container level:įfmpeg -i "input.mp4" -aspect 720:540 -c copy "output.mp4" Batch conversionsīatch convert a folder of. To copy the video from invideo0.mp4 and the audio from inaudio1.mp4 and mux together matching the duration of the -shortest input stream:įfmpeg -i invideo0.mp4 -i inaudio1.mp4 -c copy -map 0:0 -map 1:1 -shortest output.mp4 Audio/video syncįfmpeg -i input.mp4 -itsoffset 0.2 -i input.mp4 -map 1:v -map 0:a -vcodec copy -acodec copy out.mp4įfmpeg -i input.mp4 -itsoffset 0.2 -i input.mp4 -map 0:v -map 1:a -vcodec copy -acodec copy out.mp4 Rotate a videoĠ = 90CounterClockwise + Vertical Flip (default)įfmpeg -i input.mp4 -vf "transpose= 1" output.mp4įfmpeg -i input.mp4 -vf "transpose= 2,transpose= 2" output.mp4 Change Aspect ratioĬhanging the resolution will always requires re-encoding.Ĭhange the Sample Aspect Ratio to be half that of the input file, this will create a significantly smaller (but lower quality) file:įfmpeg -i "input.mp4" -vf "scale=trunc(iw/4)*2:trunc(ih/4)*2" ~/output.mp4 Trimming can be done with or without -c copy, if you leave out -c copy, ffmpeg will re-encode the output file.Ĭopy only the first 60 seconds of a video:įfmpeg -i input.mp4 -t 60 -c copy output.mp4Ĭopy 2.5 minutes from the middle of a video without re-encoding it:įfmpeg -ss "00:00:59.59" -i "input.mp4" -c copy -map 0 -to "00:03:30.00" "output.mp4" Mux video and audio Times and duration can be given as hh:mm:ss.msec or a simple number of seconds. To Trim a file, add the options -ss -t or -to This can give a jagged appearance on a computer monitor.ĭeinterlace a file using "yet another deinterlacing filter".įfmpeg -i input.mp4 -vf yadif output.mp4 Extracting partial content

Interlaced video is generated for TV/broadcasting with even lines are captured for one half frame followed by the odd lines in the next half frame.
#Google ffmpeg tutorial mp4
mp4 specifying a high bitrate (-b) audio for best quality sound.įfmpeg -i ~/input.webm -c:v libx264 -c:a aac -strict experimental -b:a 192k output.mp4 Deinterlace mp3 specifying a high bitrate (-b) audio for best quality sound.įfmpeg -i ~/input.webm -b:a 192k ~/output.mp3Ĭonvert a. 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. I'll leave some links down below, so you can explore this amazing command line/library/converter/ everything related to media.A cross-platform solution to record, convert and stream audio and video. For sure, it also relies strongly on many libs such as, codecs like x264, measurements tools like VMAF among others. I'm still perplexed by the versatility of this incredible tool, you can do pretty much anything related to media.
