script to split a single video into multiple shorter videos
This commit is contained in:
parent
75c031e5b2
commit
c067ed87f9
35
splitAndShrinkVideo
Executable file
35
splitAndShrinkVideo
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "USAGE: $0 FILE SPLIT_DURATION_SECONDS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fullpath="$1"
|
||||
source fileextensions
|
||||
|
||||
outprefix="$dir/$filename"
|
||||
outext=".mp4"
|
||||
|
||||
splitduration="$2"
|
||||
probecmd="ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1"
|
||||
|
||||
duration=`$probecmd $fullpath`
|
||||
n=`echo $duration $splitduration | awk '{print int($1/$2)+1}'`
|
||||
|
||||
i=0
|
||||
while [ $i -le $n ]; do
|
||||
from=$(($i*$splitduration))
|
||||
to=$(($from+$splitduration))
|
||||
outfile="$outprefix$i$outext"
|
||||
ffmpeg -y -ss "$from" -to "$to" -i "$fullpath" -s ega "$outfile"
|
||||
i=$(($i+1))
|
||||
done
|
||||
|
||||
lastduration=`$probecmd $outfile`
|
||||
|
||||
if [ "$lastduration" == "0.000000" ]; then
|
||||
rm "$outfile"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user