#!/bin/bash #B. Vandeportaele #script to concatenate video files from the GOPRO using ffmpeg #if the filenames are not in sequence as generated by the script, a list of file can be used. The file containing the list should be #made of lines such as: file 'GOPR0650.MP4' #ffmpeg -f concat -safe 0 -i file-list_to_concatenate.txt -ss 1:16 -t 30:00 -c copy GOPR0650_complete_cut.MP4 NUMBER=0711 START_TIME="0:19" DURATION="2:0:00" #construct a string that contains all the necessary file names #LIST="\"concat:GOPR$NUMBER.MP4|GP01$NUMBER.MP4\"" #LIST="GOPR$NUMBER.MP4|GP01$NUMBER.MP4|GP02$NUMBER.MP4|GP03$NUMBER.MP4|GP04$NUMBER.MP4|GP05$NUMBER.MP4|GP06$NUMBER.MP4|GP07$NUMBER.MP4|GP08$NUMBER.MP4|GP09$NUMBER.MP4" #begin with a list of 1 file LIST="\"concat:GOPR$NUMBER.MP4" echo $LIST #loop for 10 next files and try to detect if the file exists then add it to the list for I in `seq -w 1 10`; do file="GP$I$NUMBER.MP4" if [ -f "$file" ] then echo "$file found." LIST="$LIST|$file" else echo "$file not found." fi done #close the list LIST="$LIST\"" echo $LIST #on peut aussi éviter de passer par une liste de fichier et utiliser # -i "concat:input1.mpg|input2.mpg|input3.mpg" #generate an output file name OUTFILE="GOPR${NUMBER}_completecut.MP4" #generate the command COMMAND="ffmpeg -i $LIST -ss $START_TIME -t $DURATION -c copy $OUTFILE" echo "Do you want to execute the following command (y/n):" echo $COMMAND read line if [ "$line" == "y" ]; then #execute the command in the variable eval "$COMMAND" fi