diff --git a/README.md b/README.md index 4c99cbc..e678f20 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Cutter + Utility per la compressione e ritaglio dei silenzi all'interno delle lezioni. Basato sul lavoro svolto da [Remsi](https://github.com/bambax/Remsi), prende in input il path di una cartelle ed esegue il taglio di tutti i video indicati. @@ -12,39 +13,49 @@ Per riconoscere un silenzio sono stati usati, di default, i seguenti parametri: _Nota: più è basso in modulo la tolleranza più è semplice il taglio, esempio: -40db taglia maggiormente di -50db_ -## Parametri -```text ---teams # esegue il crop del video eliminando le bande nere di teams (versione 2021) -``` ## Installazione Prerequisiti: -- **python** installato -- **ffmpeg** installato + +- aver installato **python** [(download Windows)](https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe) +- aver installato **ffmpeg** [(download Windows)](https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip) Clona questa repo in una cartella comoda: + ```bash -git clone https://github.com/Guray00/squeeze +git clone https://github.com/Guray00/cutter ``` Entra nella cartella: + ```bash cd squeeze ``` +Clona la repo di Remsi: + +```bash +git clone https://github.com/Guray00/Remsi/tree/916b6a1fbfc4fcdec2dc617f7e8fd746a0cc3281 +``` + Installa le dipendenze: + ```bash pip install -r ./requirements.txt ``` + Sei pronto per l'utilizzo! ## Utilizzo Per eseguire il programma è sufficiente: + ```bash python3 cutter.py "path-to-folder" ``` + Mentre le opzioni possiibili sono: + ```text usage: cutter.py [-h] [--teams] [-d D] [-n N] foldername diff --git a/Remsi b/Remsi index 916b6a1..271a35b 160000 --- a/Remsi +++ b/Remsi @@ -1 +1 @@ -Subproject commit 916b6a1fbfc4fcdec2dc617f7e8fd746a0cc3281 +Subproject commit 271a35bf6c7389414329a82ccfb335a82488fe4a diff --git a/cutter.py b/cutter.py index efbd296..57e92fd 100644 --- a/cutter.py +++ b/cutter.py @@ -128,7 +128,7 @@ def cut(__file__): # eseguo il comando di taglio - command = f'ffmpeg -i "{__file__}" -hide_banner -filter_script:v "./vfilter.txt" -filter_script:a "./afilter.txt" -map_chapters -1 "{output}"' + command = f'ffmpeg -ignore_chapters 1 -i "{__file__}" -hide_banner -filter_script:v "./vfilter.txt" -filter_script:a "./afilter.txt" -c:a aac "{output}"' print_line() print_centered(f"✂️ Sto \033[94mtagliando\033[0m il file ({__file__})") print("\x1B[3m"+command+"\x1B[0m") diff --git a/squeeze.py b/squeeze.py deleted file mode 100644 index 2758d7f..0000000 --- a/squeeze.py +++ /dev/null @@ -1,81 +0,0 @@ -# MARCHIO IL FILE -# ffmpeg -i input.mp4 -vcodec libx265 -crf 28 -metadata comment="compressed" output.mp4 - -# NO -# ffmpeg -i video.mkv -metadata comment="compressed" -c copy output.mp4 - - -# VERIFICO SE HA IL MARCHIO -# rm -f .ck.txt && ffmpeg -i output.mp4 -f ffmetadata .ck.txt -# rm -f /tmp/squeeze/.ck.txt && ffmpeg -i output.mp4 -f ffmetadata /tmp/squeeze/.ck.txt && a = grep "comment=compressed" - - -# RECUPERIAMO L'ELENCO DEI VIDEO -# mkdir -p /tmp/squeeze/ -# sudo find /var/www/html/nextcloud/data/Gray/files/Anno\ 2/ -regex '.*\(mkv\|mp4\)$' > /tmp/squeeze/.titles.txt - -import glob -import os -from tinytag import TinyTag -import platform - -def elaborate(type): - command = "ffmpeg -i \"{}\" -vcodec libx265 -crf 28 -metadata comment=\"compressed\" \"{}\"".format(i, "./lite/"+i.replace(type, "[lite]."+type).replace("./", "")) - print(command) - os.system(command) - os.system("mv \"{}\" \"{}\"".format(i, i.replace("./", "./fatti/"))) - -def win_elaborate(type): - command = "ffmpeg -i \"{}\" -vcodec libx265 -crf 28 -metadata comment=\"compressed\" \"{}\"".format(i, ".\\lite\\"+i.replace(type, "[lite]."+type).replace(".\\", "")) - print(command) - os.system(command) - os.system("move \"{}\" \"{}\"".format(i, i.replace(".\\", ".\\fatti\\"))) - -def elabor(path): - command = "ffmpeg -i \"{}\" -vcodec libx265 -crf 28 -metadata comment=\"compressed\" \"{}\"".format(i, "./lite/"+i.replace(type, "[lite]."+type).replace("./", "")) - - filename, file_extension = os.path.splitext(path) - - name = os.path.basename(filename) - output = os.path.abspath(path+"/lite/"+ name) - - name = os.path.basename(filename) - command = f'ffmpeg -i {filename} -vcodec libx265 -crf 30 - metadata comment="compressed" {output}[lite]{file_extension}' - - print(command) - fatti = os.path.abspath(path+"/fatti/"+ name + file_extension) - os.rename(path, fatti) - -if __name__ == "__main__": - # os.system("mkdir -p /tmp/squeeze/") - x = glob.glob("./*.mp4") - y = glob.glob("./*.mkv") - - p = platform.platform()+"" - - for i in x: - video = TinyTag.get(i) - if(video.comment != "compressed"): # se il video non è già compresso lo elabora - if "Windows" not in p: - elaborate("mp4") - else: - win_elaborate("mp4") - - - for i in y: - try: - video = TinyTag.get(i) - - if(video.comment != "compressed"): # se il video non è già compresso lo elabora - if "Windows" not in p: - elaborate("mkv") - else: - win_elaborate("mkv") - - except: - print("errore con "+ i) - if "Windows" not in p: - elaborate("mkv") - else: - win_elaborate("mkv") - diff --git a/trainer.py b/trainer.py deleted file mode 100644 index e585132..0000000 --- a/trainer.py +++ /dev/null @@ -1,66 +0,0 @@ -from playsound import playsound -import glob -import sys -import os -#playsound('myfile.wav') - -import pygame - -pygame.init() -pygame.mixer.init() - - -folder = "training_data/"+sys.argv[1] -path = os.path.abspath(folder) - -print(path) - -x = glob.glob(folder+"/*.wav") - -for i in x: - - if not os.path.exists(path+"/ehm"): - os.makedirs(path+"/ehm") - - if not os.path.exists(path+"/silent"): - os.makedirs(path+"/silent") - - if not os.path.exists(path+"/false"): - os.makedirs(path+"/false") - - #playsound(i) - sound = pygame.mixer.Sound(i) - sound.set_volume(2) # Now plays at 90% of full volume. - sound.play() - - - answer = "" - while(answer != "e" and answer != "p" and answer != "s" and answer != "f"): - if (answer == "r"): - print("RIPETO") - sound = pygame.mixer.Sound(i) - sound.set_volume(2) # Now plays at 90% of full volume. - sound.play() - - elif (answer == "SKIP"): - break - - elif (answer != ""): - print("Hai scritto male. Cosa volevi dire?\t") - - answer = input("is [e]hm / [s]ilent /[f]alse? or [r]epeat\t") - - if (answer == "e"): - pos = os.path.abspath(path + "/ehm/" + os.path.basename(i)) - os.rename(i, pos) - - elif (answer == "s"): - pos = os.path.abspath(path + "/silent/" + os.path.basename(i)) - os.rename(i, pos) - - elif (answer == "f"): - pos = os.path.abspath(path + "/false/" + os.path.basename(i)) - os.rename(i, pos) - - - \ No newline at end of file