-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscenesplit.sh
39 lines (32 loc) · 1.63 KB
/
scenesplit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Use this script to identify and isolate individual shots from an .mp4 video.
start=0;
count=0;
in="$1"
bn="$(basename "$in")"
echo "=============================================================================="
echo "FILE START: $bn"
# mkdir "./$bn"
echo "Finding scene"
ffmpeg -nostdin -i "$in" -filter:v "select='gt(scene,0.1)',showinfo" -f null - 2>"./scenes/ffout.tmp.txt"
echo "Filtering timestamp"
grep showinfo "./scenes/ffout.tmp.txt" | grep pts_time:[0-9.]* -o | grep '[0-9]*\.[0-9]*' -o > "./scenes/timestamps.tmp.txt"
scenes=$(wc -l < "./scenes/timestamps.tmp.txt")
echo "Found $scenes scenes"
sleep 1
while IFS= read -r line; do
echo "---------------------------------------------------------------------------"
echo "SCENE START: $count/$scenes ($start,$line)"
ffmpeg -i "$in" -ss "$start" -to "$line" -nostdin -y -vcodec libx264 -acodec aac -g 120 -s 1280x720 -r 30 "./scenes/ran.($count of $scenes).mp4"
echo "SCENE DONE:$count/$scenes ($start,$line)"
echo "---------------------------------------------------------------------------"
start=$line
count=$(($count+1))
sleep 1
done <"./scenes/timestamps.tmp.txt"
echo "---------------------------------------------------------------------------"
echo "LAST SCENE START:$count/$scenes ($start,end)"
ffmpeg -i "$in" -ss "$start" -nostdin -y -vcodec libx264 -acodec aac -g 120 -s 1280x720 -r 30 "./scenes/ran.($count of $scenes).mp4"
echo "LAST SCENE DONE:$count/$scenes ($start,end)"
echo "---------------------------------------------------------------------------"
echo "FILE DONE"
echo "=============================================================================="