SkillOpen
ffmpeg-cli
Use FFmpeg to convert, process, and manipulate video and audio files from the terminal. Transcode formats, extract audio, create thumbnails, trim clips, and more.
Front matter
name: ffmpeg-cli
description: Use FFmpeg to convert, process, and manipulate video and audio files from the terminal. Transcode formats, extract audio, create thumbnails, trim clips, and more.FFmpeg
The universal multimedia framework. Convert, process, and stream video and audio.
- Official site: https://ffmpeg.org
- Docs: https://ffmpeg.org/documentation.html
Common Commands
Format Conversion
ffmpeg -i input.mp4 output.webm # Convert MP4 to WebM
ffmpeg -i input.mov output.mp4 # Convert MOV to MP4
ffmpeg -i input.wav output.mp3 # Convert WAV to MP3
ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4 # Re-encode with H.264Extract Audio
ffmpeg -i video.mp4 -vn -acodec mp3 audio.mp3 # Extract audio as MP3
ffmpeg -i video.mp4 -vn -acodec pcm_s16le audio.wav # Extract as WAV
ffmpeg -i video.mp4 -vn -c:a copy audio.aac # Extract without re-encodingTrim and Cut
ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy clip.mp4 # Cut 1:00-2:00
ffmpeg -i input.mp4 -ss 30 -t 10 -c copy clip.mp4 # 10 seconds starting at 30sThumbnails and Screenshots
ffmpeg -i input.mp4 -ss 00:00:05 -frames:v 1 thumb.png # Screenshot at 5s
ffmpeg -i input.mp4 -vf "fps=1/10" thumb_%04d.png # One frame every 10s
ffmpeg -i input.mp4 -vf "thumbnail" -frames:v 1 best_thumb.png # Best thumbnailResize and Scale
ffmpeg -i input.mp4 -vf "scale=1280:720" output.mp4 # Resize to 720p
ffmpeg -i input.mp4 -vf "scale=-1:480" output.mp4 # Scale height, keep ratioGIF Creation
ffmpeg -i input.mp4 -ss 0 -t 5 -vf "fps=10,scale=320:-1" output.gifConcatenation
# Create file list: file 'clip1.mp4'\nfile 'clip2.mp4'
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4Audio Processing
ffmpeg -i input.mp3 -af "volume=1.5" louder.mp3 # Increase volume
ffmpeg -i input.mp3 -af "atempo=1.5" faster.mp3 # Speed up audio
ffmpeg -i input.mp4 -an output_silent.mp4 # Remove audioProbe (inspect file)
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4Agent Best Practices
- Use
-c copywhen possible to avoid re-encoding (much faster) - Use
ffprobeto inspect files before processing - Use
-yflag to overwrite output without prompting - Use
-hide_bannerto reduce noisy output - CRF (Constant Rate Factor) controls quality: 18 = high, 23 = default, 28 = low
- Use
-preset ultrafastfor quick encodes,-preset slowfor quality - Pipe output to
/dev/nulland use-progress pipe:1for parseable progress
Example Workflows
Convert video for web
ffmpeg -y -hide_banner -i input.mov -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4Get video duration
ffprobe -v quiet -show_entries format=duration -of csv=p=0 input.mp4Source: written by One Giant Leap.
Related entries
There are more like this in the members library
The Claude Code library holds 13,843 entries. Members can search all of them by meaning and read every one in full.