-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvideobreaker.py
39 lines (33 loc) · 1.42 KB
/
videobreaker.py
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
import subprocess
# This script takes an input video and compresses it with the worst quality setting available.
# It then takes that output and compresses it again and again. As often as it is specified in n_repeats
print("This Script compresses your video over and over again with the worst quality setting possible")
input_file = input("Input File: ")
n_repeats = input("Number of iterations: ")
# For this to work the first iteration has to be done by a separate function that runs only once at the beginning
def generateFirstOutput():
commands_list = [
"ffmpeg",
"-i",
input_file,
"-crf",
"63",
input_file+"-out-0.mp4"
]
return commands_list
# this function creates a ffmpeg prompt in which the input file is replaced with the previously generated output file. this is loopable
def generateNextOutput(count):
commands_list = [
"ffmpeg",
"-i",
input_file+"-out-"+str(count)+".mp4",
"-crf",
"63",
input_file+"-out-"+str(count+1)+".mp4"
]
return commands_list
# Main loop. Run the first Call once to generate the filename pattern that is loopable and then run the for loop for the number of iterations
subprocess.run(generateFirstOutput())
for i in range(int(n_repeats)-1):
subprocess.run(generateNextOutput(i))
input("Finished. Have fun with your broken videos! Press Enter to Exit.")