Created
January 30, 2024 15:45
-
-
Save er4z0r/0c8b0e50462fa90d8288195f2b8fab1c to your computer and use it in GitHub Desktop.
Cut video from csv timestamp file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# we need a video and a csv file as args | |
INVID=$1 | |
TSFILE=$2 | |
# read csv file of format starttime;endtime;description | |
while IFS=";" read start_ts end_ts descr | |
do | |
# for each record | |
# cut video from start to end and save as description | |
echo "Cutting video from ${start_ts} to ${end_ts} and saving to ${descr}.mp4" | |
# with copying (may result in audio desync and video fragments) | |
# ffmpeg -i $INVID -ss "${start_ts}" -to "${end_ts}" -c:v copy -c:a copy "${descr}.mp4" | |
# with re-encoding. Takes longer but gives better results | |
ffmpeg -nostdin -i $INVID -ss "${start_ts}" -to "${end_ts}" -c:v libx264 -preset veryfast -crf 23 -c:a aac "${descr}.mp4" | |
done < <(tail -n +2 $TSFILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment