#!/bin/bash # Check if a parameter is provided if [ -z "$1" ]; then echo "Usage: "$(basename $0)" " exit 1 fi TMPFILE=$(mktemp) for input in "$@"; do if [ -f "$input" ]; then if [ "$container" == "" ]; then container="${input##*.}" fi if [ "$container" != "${input##*.}" ]; then echo "Files need to be in same format to merge!" echo "Abandoning merge" if [ -f "$TMPFILE" ]; then rm $TMPFILE fi echo;read -rsn1 -p "Press any key to continue . . .";echo exit fi echo "file '$input'" >> $TMPFILE container="${input##*.}" filename=${input%.*} fi done output="$filename.mergedprogress.$container" sort -n -o $TMPFILE"_sort" $TMPFILE echo "The following files will be merged in this order:" cat $TMPFILE"_sort" echo;read -rsn1 -p "Press any key to continue . . .";echo cmd='ffmpeg -f concat -safe 0 -i "'"$TMPFILE"'_sort" -c copy "'"$output"'"' eval $cmd if [ $? -eq 0 ]; then actualheight=$(ffprobe -v error -select_streams v -show_entries stream=height -of csv=p=0:s=x "$output") #output2="${output%.*}."$actualheight"p.$container" output2="${output//.mergedprogress./.$actualheight""p.merged.}" mv "$output" "$output2" echo "Output file: $output2" rm $TMPFILE rm $TMPFILE"_sort" else echo "An error occured. File not converted properly!" echo "Full ffmpeg command:" echo "$cmd" fi echo;read -rsn1 -p "Press any key to continue . . .";echo