Some ffmpeg commands
Crop:
ffmpeg -i in.mp4 -vf "crop=out_w:out_h:x:y" out.mp4
out_w
,out_h
– width/height of the output rectangle (e.g.850/2
)(x,y)
– top left corner for the output rectanglein_w
,in_h
– input width/height (e.g.in_w-40
,in_w/2
)
Trim:
ffmpeg -i in.mp4 -ss hh:mm:ss -to hh:mm:ss out.mp4
-ss
– starting timestamp-to
– ending timestamp-t
– duration
Mute:
ffmpeg -i in.mp4 -an out.mp4
Adjust audio:
ffmpeg -i in.mp4 -af "volume=0.1" out.mp4
-af
filter audio stream
Add audio to video:
ffmpeg -i in.mp4 -i audio.mp3 -filter_complex "amix=inputs=2:duration=first" -c:v copy out.mp4
- loop audio:
-stream_loop -1 -i background.wav
Format:
-f rawvideo
to force input/output file format (usually auto-determined by file extension)-
-pix_fmt rgb24
per Wikipedia, the format in which the image data output is represented - List of all formats from
ffmpeg -formats
- List of all pixel formats from
ffmpeg -pix_fmts
General:
-c copy
for no re-encoding-preset veryfast|ultrafast|...
for faster compression (tradeoff size/quality) listffplay
to play a video (mostly used to test ffmpeg transformations)ffmpeg -i in.mp4 -filter_complex "select=bitor(gt(scene\,0.5)\,eq(n\,0))" -vsync drop "frames/%04d.jpg"
export unique frames? (magick in.mp4[0]
for single frame) (src)