-
Notifications
You must be signed in to change notification settings - Fork 7
/
1_BATCH
executable file
·93 lines (71 loc) · 2.23 KB
/
1_BATCH
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
size=2000
cd PROCESSING_ZONE
rename 's/[()]//g' *
rename 's/[ :!]/_/g' *
for file in *; do
if [[ $file == *.mp4 || $file == *.mkv || $file == *.avi || \
$file == *.mov || $file == *.flv || $file == *.wmv || \
$file == *.webm || $file == *.mpg || $file == *.mpeg || \
$file == *.3gp || $file == *.ogv || $file == *.mts || \
$file == *.m2ts || $file == *.ts ]]; then
# Traitez le fichier ici
echo "Processing $file"
rm -rf "${file%.*}" && mkdir "${file%.*}"
mkdir "${file%.*}"/images
len=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $file)
echo "${file%.*}"
echo "Extracting frames"
# Fonction pour tuer tous les processus enfants
cleanup() {
echo "Interruption détectée, arrêt des processus..."
pkill -P $$
exit 1
}
# Capturer Ctrl+C
trap cleanup SIGINT
# Calculer r en utilisant bc
r=$(echo "scale=10; $len / ($size + 5)" | bc)
for ((i=0; i<=$((size + 3)); i++))
do
# Calculer stamp en utilisant bc
stamp=$(echo "scale=10; $i * $r" | bc)
# Afficher la progression
echo -ne "$i / $size\r"
ffmpeg -y -nostdin -threads 1 -hide_banner -loglevel panic -accurate_seek -ss $stamp -i $file -vf "cropdetect=24:16:0" -q:v 1 -frames:v 1 "${file%.*}"/images/$i.jpg &
done &
number_of_processed_frames=$(ls "${file%.*}"/images | wc -l)
while ((number_of_processed_frames<size))
do
((number_of_processed_frames=$(ls "${file%.*}"/images | wc -l)))
done
# créer les images potentiellement manquantes
# Créer les images potentiellement manquantes
for i in $(seq 0 $((size + 1)))
do
if [ ! -f "${file%.*}/images/${i}.jpg" ]; then
prev=$((i - 1))
if [ $prev -ge 0 ] && [ -f "${file%.*}/images/${prev}.jpg" ]; then
cp "${file%.*}/images/${prev}.jpg" "${file%.*}/images/${i}.jpg"
echo "Créé ${i}.jpg à partir de ${prev}.jpg"
else
echo "Image de départ manquante pour créer ${i}.jpg"
fi
fi
done
cp ../disk "${file%.*}"/
cd ""${file%.*}""/
num=$(ls -l images | egrep -c '^-')-$size
echo "${num}"
./disk $size
cd ..
fi
done
for file in *; do
if [ -d "$file" ]; then
cd "$file" || exit
mv "save.png" "${file}.png"
mv *.png ..
cd ..
fi
done