This commit is contained in:
german 2026-03-17 19:03:35 +04:00
commit eeff4699ff
2 changed files with 41 additions and 0 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# AudioCutter
Это скрипт на bash для деления аудио на заданное кол-во частей.

39
cutter.bash Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
zenity --info --text="Этот скрипт нужен для разделения аудиофайла на части. Нажмите ОК для продолжения..."
audiofile=$(zenity --file-selection --title="Выберите файл для нарезки на части")
count=$(zenity --entry --title="Нарезка аудио..." --text="Введите кол-во частей:")
if ffmpeg -i "$audiofile" &> /dev/null; then
zenity --warning --text="Ошибка!"
exit 1
fi
filelen=$(ffmpeg -i "$audiofile" 2>&1 | grep -oE "[0-9]{1}:[0-9]{2}:[0-9]{2}" | tail -n 1)
IFS=':' read -ra filelen <<< "$filelen"
lenseconds=${filelen[2]}
lenminutes=${filelen[1]}
lenhours=${filelen[0]}
filelen=$((lenseconds+(lenminutes*60)+(lenhours*60*60)))
outfile=${audiofile%.*}
segmentsize=$((filelen/count))
echo File length at seconds: $filelen
percent=0
i=0
mkdir -p "$(dirname "$outfile")/ffmpeg-out"
(
while [ $i -le $((count-1)) ]; do
starttime=$((segmentsize*i))
stoptime=$(((segmentsize*(i+1))+1))
outfiledir="$(dirname "$outfile")/ffmpeg-out/$(basename "$outfile")"
outname="$outfiledir-$i-ffmpeg.mp3"
# echo File of script: $outname $starttime-$stoptime sec
ffmpeg -y -i "$audiofile" -vn -acodec copy -ss $starttime -to $stoptime "$outname" &> /dev/null
i=$((i+1))
percent=$(( (i+1)*(100/count) ))
echo $percent
done
exit 0
) |
zenity --progress \
--title="Кодирование..." \
--text="Кодировано из 100%" \
--percentage=0