Skip to content

Instantly share code, notes, and snippets.

@vaibhaw
Last active January 3, 2017 16:41
Show Gist options
  • Select an option

  • Save vaibhaw/2961ab3656984ca88105cbfd86ae2085 to your computer and use it in GitHub Desktop.

Select an option

Save vaibhaw/2961ab3656984ca88105cbfd86ae2085 to your computer and use it in GitHub Desktop.
## get total number of frames in a video
# source: http://stackoverflow.com/q/2017843/925216
ffprobe -v error -count_frames -select_streams v:0 \
-show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 \
input.mkv
## split files into 5 seconds
# source: http://superuser.com/q/377343/307710
ffmpeg -ss 00:00:00 -t 00:00:05 -i input.mp4 -acodec copy -vcodec copy output.mp4
# bash script - http://grapsus.net/blog/post/A-script-for-splitting-videos-using-ffmpeg
# one liner - http://unix.stackexchange.com/q/22585/62741
# python script - http://icephoenix.us/notes-for-myself/auto-splitting-video-file-in-equal-chunks-with-ffmpeg-and-python/
ffmpeg -i in.mp4 -ss [start] -t [duration] -c copy out.mp4
## print duration of a video
# source: http://stackoverflow.com/q/6239350/925216, http://stackoverflow.com/a/6239379/925216
ffmpeg -i file.mp4 2>&1 | grep Duration | awk '{print $2}' | tr -d ,
ffmpeg -i file.mp4 2>&1 | grep Duration | sed 's/Duration: \(.*\), start/\1/g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment