diff --git a/kiss/ffmpeg_splitter.sh b/kiss/ffmpeg_splitter.sh index 4b848d86125b5b044433ce7d5d90fe6c36dccdf2..647c76f15c798591344137a8aca3476e53e7865c 100755 --- a/kiss/ffmpeg_splitter.sh +++ b/kiss/ffmpeg_splitter.sh @@ -1,6 +1,6 @@ #!/bin/bash -# very dirty script to split a video into 15 minutes parts with ten +# dirty little script to split a video into 15 minutes parts with ten # seconds overlap (for upload to youtube) # USAGE: read comments and adjust where necessary, then: @@ -15,10 +15,23 @@ bname=${fname%%.*} # the file basename ext=${fname#*.} # the file extension -for i in {1..5} # Naive assumption that no video is longer than - # 5*15=75min. Please adjust! -do - ffmpeg -vcodec copy -acodec copy -ss $[i*890 - 890] -t 899.999 -i $1 $bname-part0$i.$ext -done +# to avoid async a/v, re-encode with every frame as keyframe +if + test -f $bname-keyframes.$ext +then + : +else + ffmpeg -g 1 -i $1 $bname-keyframes.$ext +fi + + +# get length and calculate amount of segments +let vidlen=$(ffprobe -show_format $1 | grep duration | cut -d "." -f 1 | cut -d "=" -f 2)+1 +let segcount=$vidlen/890 +# loop until it's done +for (( i = 1; i <= $segcount; i++)) +do + ffmpeg -vcodec copy -acodec copy -ss $[i*890 - 890] -t 899.999 -i $bname-keyframes.$ext $bname-part0$i.$ext +done