Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This bash script skirts the annoying FFmpeg limitation of cutting audio or video based not on start/stop timestamps, but on seconds elapsed. With the following bash script you can enter a start time to begin the cut, and an end time to terminate the cut, which removes the sometimes necessary task of performing math to determine precisely how man…
INPUT=$(yad --width=600 --height=400 --file-selection --file-filter='*.mp3 *.mkv *.mp4 *.avi *.flv')
eval $(yad --width=400 --form --field=start --field=end --field=output:SFL "00:00:00.000" "00:00:00.000" "${INPUT/%.*}-out.${INPUT##*.}" | awk -F'|' '{printf "START=%s\nEND=%s\nOUTPUT=\"%s\"\n", $1, $2, $3}')
[[ -z $START || -z $END || -z $OUTPUT ]] && exit 1
DIFF=$(($(date +%s --date="$END")-$(date +%s --date="$START")))
OFFSET=""$(($DIFF / 3600)):$(($DIFF / 60 % 60)):$(($DIFF % 60))
ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" -c:v copy "$OUTPUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.