forked from MaxSolar0713/480psp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprerelease-1.0dev.py
255 lines (255 loc) · 7.75 KB
/
prerelease-1.0dev.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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
def convertTuple(tup):
# initialize an empty string
str = ''
for item in tup:
str = str + item
return str
# DEFAULT VALUES FOR THE VARIABLES USED ARE STORED HERE. Y enables the Video
# bitrate option, A is the Audio Bitrate (AAC), R and S are Length:Height of
# Aspect ratio, J and K are the dimensions of the actual video.
Y = 0
A = 160
R = 16
S = 9
k = 480
j = 720
# Video bitrate change function
def vbitrate():
global Y
Y = 1
global P
P = input("What bitrate for video? (kbps): ")
# Video File command input located here.
def file_in():
global I
I = input("Please enter location of input file: ")
# Output file path command located here.
def file_out():
global O
O = input("Please enter location of output file: ")
# Audio bitrate function located here.
def bitrate():
global A
A = input("What bitrate for audio? (kbps, default 160): ")
if A == "":
A = 160
# Aspect Ratio command located here.
def aspect():
global R
R = input("Length of Aspect ratio? (default 16): ")
if R == "":
R = 16
global S
S = input("Height of Aspect Ratio? (default 9): ")
if S == "":
S = 9
# Video dimension command located here.
def viddim():
global j
j = input("What length? (default 720): ")
if j == "":
j = 720
global k
k = input("What height? (default 480): ")
if k == "":
k = 480
# Help command located here for post-generation modification.
def help():
print ("file_in(): changes file input")
print ("file_out(): changes file output")
print ("bitrate(): changes audio bitrate")
print ("aspect(): changes aspect ratio")
print ("viddim(): changes video dimensions")
print ("vbitrate(): changes video bitrate")
print ("create(): outputs the command")
# Function that creates the command.
def create():
print ("")
print ("Here is your command!")
print ("")
if Y == 1:
global Q
Q = ("ffmpeg -i ",str(I)," -vcodec libx264 -b:v ",str(P),"k -s ",str(j),"x",str(k)," -aspect ",str(R),":",str(S)," -profile:v main -level:v 2.1 -x264-params ref=3:bframes=1 -acodec aac -b:a ",str(A),"k -ac 2 -movflags +faststart ",str(O))
global qp
qp = convertTuple(Q)
print(qp)
else:
Q = ("ffmpeg -i ",str(I)," -vcodec libx264 -s ",str(j),"x",str(k)," -aspect ",str(R),":",str(S)," -profile:v main -level:v 2.1 -x264-params ref=3:bframes=1 -acodec aac -b:a ",str(A),"k -ac 2 -movflags +faststart ",str(O))
qp = convertTuple(Q)
print(qp)
# This function contains the entirety of the command generation wizard.
def run():
# Global Variables are used because Python hates constants.
# This part of the program sets all values to their defaults.
global Y
Y = 0
global A
A = 160
global R
R = 16
global S
S = 9
global k
k = 480
global j
j = 720
global e
# TITLE SEQUENCE IS HERE
print ("")
print ("PSP ffmpeg Encoder Script 1.1")
print ("By MaxSolar0713")
print ("")
# This part acquires the input and output locations of the file, so it can get the important stuff out of the way.
file_in()
file_out()
# Advanced mode for those who are more experienced.
e = input("Would you like to enter advanced mode? [y/N]: ")
if e == "y":
print ("")
print ("Press Enter at any time to go with default values.")
print ("")
bitrate()
v_bit = input("Set video bitrate? (VBR by default) [y/N]: ")
if v_bit == 'y':
vbitrate()
aspect()
viddim()
else:
Z = input("Would you like to use a preset? [y/N]: ")
if Z == "y":
# Presets here have various audio bitrates for the sake of file size.
# Various resolutions are included also to account for functional PSP
# playback. 16:9 and 4:3 ratios have been included.
print ("Preset #, Resolution, Ratio, Audio")
print ("or")
print ("Standard, Audio")
print ("")
print ("0: PSP-3000 480p, 256kbps")
print ("1: 720x480, 16:9, 192kbps")
print ("2: 720x480, 16:9, 160kbps")
print ("3: 720x480, 16:9, 128kbps")
print ("4: 4:3 for PSP-3000, 256kbps")
print ("5: 640x480, 4:3, 192kbps")
print ("6: 640x480, 4:3, 160kbps")
print ("7: 640x480, 4:3, 128kbps")
print ("8: Most Compatible with PSP, 256kbps")
print ("9: 480x272, 16:9, 192kbps")
print ("A: 480x272, 16:9, 160kbps")
print ("B: 480x272, 16:9, 128kbps")
print ("C: Most PSP-1000 Compatible, 256kbps")
print ("D: 320x240, 4:3, 192kbps")
print ("E: 320x240, 4:3, 160kbps")
print ("F: 320x240, 4:3, 128kbps")
print ("")
preset = input("Enter the number/letter of the preset you wish to use: ")
if preset == "F":
A = 128
R = 4
S = 3
k = 240
j = 320
# MOST COMMON 480p PRESET FOR PSP-3000
if preset == "0":
A = 256
R = 16
S = 9
k = 480
j = 720
if preset == "1":
A = 192
R = 16
S = 9
k = 480
j = 720
if preset == "2":
A = 160
R = 16
S = 9
k = 480
j = 720
if preset == "3":
A = 128
R = 16
S = 9
k = 480
j = 720
if preset == "4":
A = 256
R = 4
S = 3
k = 480
j = 640
if preset == "5":
A = 192
R = 4
S = 3
k = 480
j = 640
if preset == "6":
A = 160
R = 4
S = 3
k = 480
j = 640
if preset == "7":
A = 128
R = 4
S = 3
k = 480
j = 640
# MOST COMMONLY COMPATIBLE VIDEO FORMAT FOR PSP
if preset == "8":
A = 256
R = 16
S = 9
k = 272
j = 480
if preset == "9":
A = 192
R = 16
S = 9
k = 272
j = 480
if preset == "A":
A = 160
R = 16
S = 9
k = 272
j = 480
if preset == "B":
A = 128
R = 16
S = 9
k = 272
j = 480
# 320 x 240 is most likely to work on PSP-1000
if preset == "C":
A = 256
R = 4
S = 3
k = 240
j = 320
if preset == "D":
A = 192
R = 4
S = 3
k = 240
j = 320
if preset == "E":
A = 160
R = 4
S = 3
k = 240
j = 320
# THIS IS WHERE THE COMMAND IS PUT OUT.
create()
print ("")
print ("To change part of the command, type help() for a list of commands, and use the commands thereof.")
print ("Type run() to run this program again.")
print ("Thank you.")
# This "run()" function is actually where the whole code begins. This allows for
# repeated execution, and also points out errors in the code before commencing
# execution.
run()
import os
os.system(str(Q))