Skip to content

Instantly share code, notes, and snippets.

@kortina
Last active January 8, 2020 22:43
Show Gist options
  • Save kortina/48c51643ff05132567d1235646f0dbe7 to your computer and use it in GitHub Desktop.
Save kortina/48c51643ff05132567d1235646f0dbe7 to your computer and use it in GitHub Desktop.
ffmpeg snippets
#!/usr/bin/env bash
########################################
# extract 1m 45s of video starting at 1h 3m 0s in input.mov and save to output.mov
input="input.mov"
output="output.mov"
ffmpeg -ss 01:03:00 -i "$input" -t 00:01:45 -c:v h264 -c:a pcm_s16le "$output"
########################################
# convert an mp4 to mov for import to final cut pro x
input="input.mp4"
# get the name of the file without the extension
fn="${input%.*}"
output="$fn.mov"
ffmpeg -i "$input" -c:v h264 -c:a pcm_s16le "$output"
########################################
# extract all distinct frames from input.mkv to stills named output-001.jpg, output-002.jpg, ...
# at 640x360. Change the aspect ratio if you want larger / smaller stills
# the 0.5 specifies stills that are at least 50% different still captured
# via: https://www.bogotobogo.com/FFMpeg/ffmpeg_thumbnails_select_scene_iframe.php
input=input.mkv
ffmpeg -i "$input" -vf "select=gt(scene\,0.5), scale=640:360" -vsync vfr output-%03d.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment