Created
July 18, 2022 11:08
-
-
Save ctrlcctrlv/c06784b492268c13c7d8ba16b8631bf1 to your computer and use it in GitHub Desktop.
Mass video splitter (ffmpeg ; originally for Twitter threads)
This file contains hidden or 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 | |
| LINECOUNT=$(( $(wc -l timecodes.tsv | awk '{print $1}') - 1)) | |
| read -r -d '' COLUMN_HANDLER << EOF | |
| (awk '{print \$VAR}' | awk 'BEGIN {FS=":"} {print \$2*60 + \$3}') < <(tail -n $LINECOUNT < timecodes.tsv) | |
| EOF | |
| TEMP=`mktemp --suffix=.tsv` | |
| paste <(awk '{print $1}' < <(tail -n $LINECOUNT timecodes.tsv)) <(bash -c "${COLUMN_HANDLER//\$VAR/\$2}") <(bash -c "${COLUMN_HANDLER//\$VAR/\$3}") > "$TEMP" | |
| TEMP2=`mktemp --suffix=.tsv` | |
| awk '{print $1 "\t" $2 "\t" $3-$2}' < "$TEMP" > "$TEMP2" | |
| parallel --bar --jobs 1 -a "$TEMP2" --colsep '\t' ffmpeg -y -i jim.mp4 -c:v h264_nvenc -c:a aac -vf crop=w=640:h=387:x=0:y=0 -ss {2} -t {3} {1}.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment