summaryrefslogtreecommitdiff
path: root/video/ffconcat
diff options
context:
space:
mode:
authorTimmy Keller <tjk@tjkeller.xyz>2022-07-07 15:55:54 -0500
committerTimmy Keller <tjk@tjkeller.xyz>2022-07-07 15:55:54 -0500
commit38ebf64b07f99de9464905ee5f8aaee1148b6a4f (patch)
tree1617ef65c4bd54db8f48cf70122ef7b923c623ab /video/ffconcat
parent35a2dd3734f1d31060fe28837cf0e1d947c8d6f4 (diff)
downloadscripts-38ebf64b07f99de9464905ee5f8aaee1148b6a4f.tar.xz
scripts-38ebf64b07f99de9464905ee5f8aaee1148b6a4f.zip
tons of changes from when website was down
Diffstat (limited to 'video/ffconcat')
-rwxr-xr-xvideo/ffconcat30
1 files changed, 30 insertions, 0 deletions
diff --git a/video/ffconcat b/video/ffconcat
new file mode 100755
index 0000000..34e6550
--- /dev/null
+++ b/video/ffconcat
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+trap cleanup EXIT
+
+ccf=/tmp/concatfile.
+cleanup() { rm ${ccf}*; }
+concat() {
+ outfile="output$i.mkv"
+ concatfile=$(mktemp ${ccf}XXXXXX)
+ dir="$(pwd)"
+ for video in $vidfiles; do
+ echo "file '$dir/$video'" >> $concatfile
+ done
+ cat $concatfile | sort > ${concatfile}_ # Sort concatfile so videos are ordered correctly
+ ffmpeg -v error -f concat -safe 0 -i ${concatfile}_ -c copy $outfile
+}
+
+for video in "$@"; do
+ codechash=$(ffprobe -v quiet -show_format -show_streams "$video" | \grep 'width\|height\|codec' | md5sum | cut -d' ' -f1)
+ [ -z "$prevhash" ] && prevhash=$codechash
+ if [ $prevhash = $codechash ]; then
+ vidfiles="$video${vidfiles:+ }$vidfiles"
+ else
+ [ -z "$i" ] && i=0
+ concat
+ vidfiles=""
+ i=$((i+1))
+ fi
+done
+concat