From 38ebf64b07f99de9464905ee5f8aaee1148b6a4f Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Thu, 7 Jul 2022 15:55:54 -0500 Subject: tons of changes from when website was down --- video/ffconcat | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 video/ffconcat (limited to 'video/ffconcat') 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 -- cgit v1.2.3