Skip to content

Instantly share code, notes, and snippets.

View nerdCopter's full-sized avatar

nerdCopter nerdCopter

View GitHub Profile
@nerdCopter
nerdCopter / split-video.sh
Last active November 14, 2024 17:23
split (cut) video with MP4Box or ffmpeg as needed
#!/bin/bash
if [ $# -lt 3 ]
then
echo "Usage: ${0##*/} <filename> <fromtime [HH:]mm:ss> <totime [HH:]mm:ss> [suffix]"
echo " Ex: ${0##*/} INPUT.mp4 0:20 9:40 snip001"
echo " requires: gpac (MP4Box) and ffmpeg"
else
function to_sec() { echo "$1" | awk -F':' '{if (NF == 2) {print $1 * 60 + $2} else {print $1 * 60 * 60 + $2 * 60 + $3}}';}