tips
38 tips Ffmpeg
One command, setting or habit at a time about Ffmpeg: what it does, the line to copy and a caveat or two.
Files and media 38
-
Repeats an input a set number of times, which is handy for loops and background videos.
ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 -
Fades the picture and the sound in at the start and out at the end of a clip.
ffmpeg -i in.mp4 \ -
Puts an SRT file into an MP4 as a subtitle track instead of burning it into the picture.
ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 -
Converts surround audio to two channels so it plays well on laptops and headphones.
ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv -
Saves the sound of a video file as a separate audio file without re-encoding it.
ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a -
Makes ffmpeg skip an output that is already there instead of asking or replacing it.
ffmpeg -n -i "$f" -c copy "${f%.mkv}.mp4" -
Rotates the picture of a video by 90 degrees, clockwise or counterclockwise.
ffmpeg -i sideways.mp4 -vf transpose=1 -c:a copy upright.mp4 -
Makes a video from a still image and a sound file, for sites that only accept video.
ffmpeg -loop 1 -i cover.jpg -i episode.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -shortest episode.mp4 -
Deinterlaces old TV or camcorder footage so moving parts don't show striped edges.
ffmpeg -i tape.avi -vf yadif -c:v libx264 -crf 20 -c:a aac tape.mp4 -
Builds a GIF from a video with a color palette made for that clip.
ffmpeg -i clip.mp4 -vf "fps=10,scale=480:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse" clip.gif -
Sets the codec tag Apple players expect, so an HEVC file plays in QuickTime and Safari.
ffmpeg -i input.mkv -c:v libx265 -crf 26 -tag:v hvc1 -c:a aac output.mp4 -
Turns a video into a series of still images at a fixed interval, for previews or contact sheets.
ffmpeg -i recording.mp4 -vf fps=1/60 thumbs/thumb-%03d.jpg -
Reports the average and peak volume of a file so you know how much to adjust it.
ffmpeg -i episode.mp3 -af volumedetect -f null - 2>&1 | grep -E 'mean_volume|max_volume' -
Changes the playback speed of the picture, for a timelapse or a slow motion clip.
ffmpeg -i build.mp4 -vf "setpts=0.25*PTS" -an build-4x.mp4 -
Makes ffmpeg copy all audio and subtitle tracks instead of picking one per type.
ffmpeg -i film.mkv -map 0 -c copy film-copy.mkv -
Makes a silent copy of a video, with the video stream copied as it is.
ffmpeg -i clip.mp4 -c:v copy -an clip-silent.mp4 -
Decodes a whole file without saving anything and prints only the errors it finds.
ffmpeg -v error -i movie.mkv -f null - -
Sets the language tag on audio or subtitle tracks so players show the right name.
ffmpeg -i film.mkv -map 0 -c copy -metadata:s:a:0 language=eng -metadata:s:a:1 language=nld film-tagged.mkv -
Cuts a part out of a video between two times, with a fast or an exact method.
ffmpeg -ss 00:01:00 -to 00:01:30 -i match.mp4 -c:v libx264 -crf 20 -c:a aac goal.mp4 -
Remuxes an audio-only file to .mka without re-encoding when Jellyfin will not play it.
ffmpeg -i input.mkv -c:a copy output.mka -
Starts the cut a fixed time before the end of the file, whatever its length.
ffmpeg -sseof -30 -i recording.mkv -c copy last30.mkv -
Joins several video files into one without re-encoding, using a text file as the list.
file 'part1.mp4' -
Builds a video from a folder of numbered images, with the frame rate you pick.
ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv -
Delays one stream against another, which fixes audio that is a fixed moment out of sync.
ffmpeg -i movie.mp4 -itsoffset 0.5 -i movie.mp4 -map 0:v -map 1:a -c copy fixed.mp4 -
Measures the black borders in a video so you know the exact crop to use.
ffmpeg -i file.mp4 -vf cropdetect,metadata=mode=print -f null - -
Makes an audio file play faster or slower and writes it as a new file.
ffmpeg -i talk.mp3 -af atempo=1.25 talk-fast.mp3 -
Lists where an audio file goes quiet, without changing the file.
ffmpeg -i recording.mp3 -af silencedetect=n=-50dB:d=5 -f null - -
Prints the hardware acceleration methods your ffmpeg build was compiled with.
ffmpeg -hide_banner -hwaccels -
Cuts one video into numbered files of a fixed length in a single command.
ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4 -
Copies a video to a new file without its global metadata or chapters.
ffmpeg -i in.mp4 -map_metadata -1 -map_chapters -1 -c copy out.mp4 -
Rewrites an MP4 so the index is at the start and playback begins before the download ends.
ffmpeg -i in.mp4 -c copy -movflags +faststart out.mp4 -
Seeks to a timestamp before reading the file, then saves a single frame as an image.
ffmpeg -ss 00:01:30 -i input.mp4 -frames:v 1 thumbnail.png -
Marks a different audio or subtitle track as the default in a video file, without re-encoding.
ffmpeg -i in.mkv -map 0 -c copy -disposition:a:0 0 -disposition:a:1 default out.mkv -
Normalizes the loudness of audio or a video's soundtrack to a fixed target with ffmpeg.
ffmpeg -i in.mp4 -c:v copy -af loudnorm=I=-23:TP=-2:LRA=7 -ar 48000 -c:a aac -b:a 192k out.mp4 -
Draws an .srt or embedded subtitle track permanently onto the picture of a video.
ffmpeg -i clip.mp4 -vf subtitles=clip.nl.srt -c:a copy clip-subbed.mp4 -
Encodes video at constant quality with H.264 or H.265, so you pick a CRF number instead of a bitrate.
ffmpeg -i in.mp4 -c:v libx264 -crf 23 -preset medium -c:a copy out.mp4 -
Scales a video to a fixed width and works out an even height so the picture is not stretched.
ffmpeg -i in.mp4 -vf scale=1280:-2 -c:a copy out.mp4 -
Moves a video into another file format in seconds, without re-encoding or quality loss.
ffmpeg -i movie.mkv -c copy movie.mp4
Nothing in this filter yet.