Spaces:
Sleeping
Sleeping
GilangAlRusliadi
commited on
Commit
·
49384d8
1
Parent(s):
3fe7530
Sakit
Browse files
app.py
CHANGED
@@ -32,8 +32,9 @@ if selected:
|
|
32 |
else:
|
33 |
video_link = st.text_input("Link Video")
|
34 |
|
35 |
-
|
36 |
-
|
|
|
37 |
start_time = st.text_input("Start Time", value='00:07:12.000')
|
38 |
end_time = st.text_input("End Time", value='00:07:31.000')
|
39 |
|
@@ -46,7 +47,22 @@ if selected:
|
|
46 |
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
47 |
video_file = cut_video(video_file, judul_video, start_time, end_time)
|
48 |
file_size = os.path.getsize(video_file)
|
49 |
-
session(video_info, video_file, thumbnail_file,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
51 |
|
52 |
else:
|
@@ -58,5 +74,5 @@ if selected:
|
|
58 |
else:
|
59 |
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
60 |
file_size = os.path.getsize(video_file)
|
61 |
-
session(video_info, video_file, thumbnail_file,
|
62 |
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
|
|
32 |
else:
|
33 |
video_link = st.text_input("Link Video")
|
34 |
|
35 |
+
choice = st.radio('Pilih salah satu:', ['Potong Video', 'Compress Video', 'Cuma Download'], 2)
|
36 |
+
|
37 |
+
if choice == 'Potong Video':
|
38 |
start_time = st.text_input("Start Time", value='00:07:12.000')
|
39 |
end_time = st.text_input("End Time", value='00:07:31.000')
|
40 |
|
|
|
47 |
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
48 |
video_file = cut_video(video_file, judul_video, start_time, end_time)
|
49 |
file_size = os.path.getsize(video_file)
|
50 |
+
session(video_info, video_file, thumbnail_file, choice)
|
51 |
+
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
52 |
+
|
53 |
+
elif choice == 'Compress Video':
|
54 |
+
compress = st.selectbox("Pilih Resolusi Compress", (360, 480, 720), 2)
|
55 |
+
|
56 |
+
if st.button(f"Download and Cut {selected}"):
|
57 |
+
if selected == 'Youtube' or selected == 'Pornhub':
|
58 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, resolution)
|
59 |
+
elif selected == 'Iwara' or selected == 'Mega':
|
60 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link, name)
|
61 |
+
else:
|
62 |
+
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
63 |
+
video_file = convert_videos(compress, video_file)
|
64 |
+
file_size = os.path.getsize(video_file)
|
65 |
+
session(video_info, video_file, thumbnail_file, choice)
|
66 |
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
67 |
|
68 |
else:
|
|
|
74 |
else:
|
75 |
video_file, judul_video, video_info, thumbnail_file = fungsi(video_link)
|
76 |
file_size = os.path.getsize(video_file)
|
77 |
+
session(video_info, video_file, thumbnail_file, choice)
|
78 |
st.text_input(f"Video '{judul_video}' setelah diproses:", convert_size(file_size))
|
others.py
CHANGED
@@ -51,12 +51,14 @@ def cut_video(filename, judul_video, start_time, end_time):
|
|
51 |
|
52 |
return output_file_path
|
53 |
|
54 |
-
def session(video_info, video_file, thumbnail_file,
|
55 |
st.session_state.video_info = video_info
|
56 |
st.session_state.video_file = video_file
|
57 |
st.session_state.thumbnail_file = thumbnail_file
|
58 |
-
if
|
59 |
-
hasil = "Hasil Potongan
|
|
|
|
|
60 |
else:
|
61 |
hasil = ""
|
62 |
if 'video_info' in st.session_state:
|
@@ -215,8 +217,9 @@ def get_video_resolution(input_file):
|
|
215 |
print(f'Error getting video resolution: {result.stderr}')
|
216 |
return None
|
217 |
|
218 |
-
def convert_videos(height,
|
219 |
-
|
|
|
220 |
if not os.path.exists(konversi_folder):
|
221 |
os.makedirs(konversi_folder)
|
222 |
|
@@ -240,8 +243,8 @@ def convert_videos(height, download_folder):
|
|
240 |
|
241 |
# Convert video using ffmpeg
|
242 |
if height == 720:
|
243 |
-
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 "{output_file}"'
|
244 |
-
|
245 |
elif height == 480:
|
246 |
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 600k -bufsize 700k -r 24 -b:a 95k -ar 44100 -ac 2 "{output_file}"'
|
247 |
elif height == 360:
|
@@ -255,8 +258,8 @@ def convert_videos(height, download_folder):
|
|
255 |
|
256 |
# Convert video using ffmpeg
|
257 |
if width == 720:
|
258 |
-
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 "{output_file}"'
|
259 |
-
|
260 |
elif width == 480:
|
261 |
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 600k -bufsize 700k -r 24 -b:a 95k -ar 44100 -ac 2 "{output_file}"'
|
262 |
|
|
|
51 |
|
52 |
return output_file_path
|
53 |
|
54 |
+
def session(video_info, video_file, thumbnail_file, choice):
|
55 |
st.session_state.video_info = video_info
|
56 |
st.session_state.video_file = video_file
|
57 |
st.session_state.thumbnail_file = thumbnail_file
|
58 |
+
if choice:
|
59 |
+
hasil = "Hasil Potongan"
|
60 |
+
elif choice:
|
61 |
+
hasil = "Hasil Compress"
|
62 |
else:
|
63 |
hasil = ""
|
64 |
if 'video_info' in st.session_state:
|
|
|
217 |
print(f'Error getting video resolution: {result.stderr}')
|
218 |
return None
|
219 |
|
220 |
+
def convert_videos(height, filename):
|
221 |
+
download_folder = os.path.dirname(filename)
|
222 |
+
konversi_folder = f'{download_folder}/Hasil Konversi'
|
223 |
if not os.path.exists(konversi_folder):
|
224 |
os.makedirs(konversi_folder)
|
225 |
|
|
|
243 |
|
244 |
# Convert video using ffmpeg
|
245 |
if height == 720:
|
246 |
+
# command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 "{output_file}"'
|
247 |
+
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 1350k -bufsize 1500k -r 30 -b:a 160k -ar 48000 -ac 2 "{output_file}"'
|
248 |
elif height == 480:
|
249 |
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 600k -bufsize 700k -r 24 -b:a 95k -ar 44100 -ac 2 "{output_file}"'
|
250 |
elif height == 360:
|
|
|
258 |
|
259 |
# Convert video using ffmpeg
|
260 |
if width == 720:
|
261 |
+
# command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 850k -bufsize 1000k -r 30 -b:a 160k -ar 44100 -ac 2 "{output_file}"'
|
262 |
+
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 1350k -bufsize 1500k -r 30 -b:a 160k -ar 48000 -ac 2 "{output_file}"'
|
263 |
elif width == 480:
|
264 |
command = f'ffmpeg -i "{input_file}" -s {width}x{height} -b:v 600k -bufsize 700k -r 24 -b:a 95k -ar 44100 -ac 2 "{output_file}"'
|
265 |
|