Spaces:
Sleeping
Sleeping
RandomPersonRR
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,40 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
|
|
3 |
|
4 |
-
# Define
|
5 |
-
UPLOAD_DIR = '
|
|
|
6 |
|
7 |
-
# Create the
|
8 |
if not os.path.exists(UPLOAD_DIR):
|
9 |
os.makedirs(UPLOAD_DIR)
|
|
|
|
|
10 |
|
11 |
-
st.title('
|
12 |
|
13 |
# File uploader
|
14 |
uploaded_file = st.file_uploader("Choose a file")
|
15 |
|
16 |
if uploaded_file is not None:
|
17 |
# Save the uploaded file
|
18 |
-
|
|
|
19 |
f.write(uploaded_file.getbuffer())
|
20 |
st.success('File uploaded successfully!')
|
21 |
|
22 |
-
#
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
+
import subprocess
|
4 |
|
5 |
+
# Define directories for uploads and processed files
|
6 |
+
UPLOAD_DIR = 'uploads'
|
7 |
+
PROCESSED_DIR = 'processed'
|
8 |
|
9 |
+
# Create the directories if they don't exist
|
10 |
if not os.path.exists(UPLOAD_DIR):
|
11 |
os.makedirs(UPLOAD_DIR)
|
12 |
+
if not os.path.exists(PROCESSED_DIR):
|
13 |
+
os.makedirs(PROCESSED_DIR)
|
14 |
|
15 |
+
st.title('FFmpeg Command Executor')
|
16 |
|
17 |
# File uploader
|
18 |
uploaded_file = st.file_uploader("Choose a file")
|
19 |
|
20 |
if uploaded_file is not None:
|
21 |
# Save the uploaded file
|
22 |
+
file_path = os.path.join(UPLOAD_DIR, uploaded_file.name)
|
23 |
+
with open(file_path, 'wb') as f:
|
24 |
f.write(uploaded_file.getbuffer())
|
25 |
st.success('File uploaded successfully!')
|
26 |
|
27 |
+
# Input for ffmpeg command
|
28 |
+
command = st.text_area('Enter FFmpeg command', value=f'ffmpeg -i {file_path} -vf scale=1280:720 {os.path.join(PROCESSED_DIR, "output.mp4")}')
|
29 |
+
|
30 |
+
if st.button('Run Command'):
|
31 |
+
# Execute the FFmpeg command
|
32 |
+
try:
|
33 |
+
subprocess.run(command, shell=True, check=True)
|
34 |
+
st.success('Command executed successfully!')
|
35 |
+
|
36 |
+
# Display the processed video
|
37 |
+
output_file_path = os.path.join(PROCESSED_DIR, 'output.mp4')
|
38 |
+
st.video(output_file_path) # Display video in Streamlit
|
39 |
+
except subprocess.CalledProcessError as e:
|
40 |
+
st.error(f'Error executing command: {e}')
|