Skip to content

Instantly share code, notes, and snippets.

@Londeren
Last active April 17, 2022 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Londeren/ecbfa38c16848c7e09de7c3b146b4d5f to your computer and use it in GitHub Desktop.
Save Londeren/ecbfa38c16848c7e09de7c3b146b4d5f to your computer and use it in GitHub Desktop.
ffmpeg useful commands
for filename in *.mp4; do ffmpeg -ss 12 -i "$filename" -c copy out-"$filename";done; # trim first 12 seconds
for filename in *.mp4; do printf "file '%s'\n" "$filename" >> ffmpeg_concat.txt;done;ffmpeg -f concat -i ffmpeg_concat.txt -c copy output-result.mp4; rm ffmpeg_concat.txt # concat ffmpeg
for filename in *.mp4; do ffmpeg -i "$filename" 2>&1 | grep Duration | awk '{print $2}' | tr -d , >> ffmpeg_concat.txt;done; # video duration time
ffmpeg -i video.mp4 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - > out.gif # video to gif
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a copy video-out.mp4 #optimize reduce size
ffmpeg -i video.mp4 -q:a 0 -map a audio.mp3 #audio from video
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment