Scope. Common FFmpeg CLI options and web/ringtone workflows. Examples require the named codecs in your local build; run ffmpeg -encoders to inspect availability. -n refuses to overwrite outputs.
Common options
-codecs # list codecs
-c:v # video codec (-vcodec) - 'copy' to copy stream
-c:a # audio codec (-acodec)
-fs SIZE # limit file size (bytes)
Bitrate
-b:v 1M # video bitrate (1M = 1Mbit/s)
-b:a 1M # audio bitrate
Video
-aspect RATIO # aspect ratio (4:3, 16:9, or 1.25)
-r RATE # frame rate per sec
-s WIDTHxHEIGHT # frame size
-vn # no video
Audio
-aq QUALITY # audio quality (codec-specific)
-ar 44100 # audio sample rate (hz)
-ac 1 # audio channels (1=mono, 2=stereo)
-an # no audio
-af volume=0.5 # halve audio volume
Examples
Convert audio to an M4R ringtone
ffmpeg -n -i foo.mp3 -ac 1 -b:a 128k -f ipod -c:a aac target.m4r
Encode video for the web
# no audio
ffmpeg -n -i input.mov -c:v libx264 -pix_fmt yuv420p -an output.mp4
ffmpeg -n -i input.mov -c:v libvpx -an output.webm
ffmpeg -n -i input.mov -c:v libx264 -pix_fmt yuv420p -c:a aac output.mp4
ffmpeg -n -i input.mov -c:v libvpx -c:a libopus output.webm
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.webm" type="video/webm">
</video>
Inspection, stream selection and resizing
Scope. FFmpeg command-line media conversion. Check ffmpeg -version and ffmpeg -encoders; codecs depend on the installed build. Examples use a POSIX-style shell and files in the current directory.
Inspect and convert
ffprobe -v error -show_format -show_streams input.mp4
ffmpeg -n -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4
-n refuses to overwrite an existing output. Lower CRF generally means higher quality and larger files with this encoder.
Select streams
# Copy the first video stream without re-encoding; discard audio.
ffmpeg -n -i input.mp4 -map 0:v:0 -c:v copy -an silent.mp4
# Extract and encode the first audio stream.
ffmpeg -n -i input.mp4 -map 0:a:0 -vn -c:a pcm_s16le audio.wav
Stream copying requires a compatible output container. These commands fail if the requested stream does not exist.
Resize and extract a frame
ffmpeg -n -i input.mp4 -vf "scale=640:-2" -c:v libx264 -c:a aac small.mp4
ffmpeg -n -ss 00:00:01 -i input.mp4 -frames:v 1 frame.png
Filtering requires re-encoding video. -ss before -i requests input seeking; exact behavior depends on format and decoding.