Skip to content

Instantly share code, notes, and snippets.

@NicolasReibnitz
Forked from pinge/ffmpeg.md
Created June 6, 2020 06:43
Show Gist options
  • Save NicolasReibnitz/4ebc28974738911a6acd7129a5f52d61 to your computer and use it in GitHub Desktop.
Save NicolasReibnitz/4ebc28974738911a6acd7129a5f52d61 to your computer and use it in GitHub Desktop.

FFmpeg

remove audio from video file

ffmpeg -i example.mp4 -c copy -an example_no_audio.mp4

extract audio track from video file without re-encoding

ffmpeg -i input.mp4 -vn -acodec copy audio_track.aac

convert audio track to PCM 16 bit little endian

ffmpeg -i input.aac -acode pcm_s16le output.wav

resample audio track

ffmpeg -i input.wav -ar 16000 output.16khz.wav

downmix audio track stereo channels to mono

ffmpeg -i input.wav -ac 1 output.mono.wav

cut video based on seconds

ffmpeg -i input.mp4 -ss 00:00:00 -to 00:00:10 -c copy first_ten_seconds.mp4

crop a video

ffmpeg -i input.mp4 -filter:v "crop=width:height:x:y" -c:a copy crop.mp4

rotate a video with arbitrary angle

ffmpeg -i input.mp4 -vf "rotate=0.5*PI/180" -y rotate_half_degree_clockwise.mp4

extract first frame of a video

ffmpeg -i input.mp4 -vframes 1 -f image2 first_frame.png

extract a specific frame of a video

ffmpeg -i input.mp4 -vf "select=eq(n\,100)" -vframes 1 frame_100.png

slow down video by a factor

ffmpeg -i input.mp4 -filter:v "setpts=2.0*PTS" 2x_slower.mp4

speed up video by a factor

ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" 2x_faster.mp4

smooth video with minterpolate filter

ffmpeg -i input.mp4 -filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=120'" 120fps_smooth.mp4

blur video

ffmpeg -i input.mp4 -vf "boxblur=5:1" blurred.mp4

convert 59.9 fps video to 25 fps

ffmpeg -i input.mp4 -avoid_negative_ts 1 -vf fps=30000/1001 -r 25 output_25fps.mp4

strip metadata from video

ffmpeg -i input.mp4 -map_metadata -1 -c:v copy -c:a copy output_no_metadata.mp4

stabilize video

ffmpeg -i input.mp4 -vf vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=transform_vectors.trf -f null -

ffmpeg2 -i input.mp4 -vf vidstabtransform=input=transform_vectors.trf:zoom=1:smoothing=50,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -preset slow -tune film -crf 18 -an output_stabilized.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment