File size: 1,365 Bytes
eefaa37
 
8df4907
eefaa37
8df4907
 
 
eefaa37
8df4907
4cf9976
 
8df4907
 
4cf9976
8df4907
eefaa37
4cf9976
 
eefaa37
4cf9976
 
8df4907
 
4cf9976
 
eefaa37
8df4907
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import os
import subprocess

# Define directories for uploads and processed files
UPLOAD_DIR = 'uploads'
PROCESSED_DIR = 'processed'

# Create the directories if they don't exist
if not os.path.exists(UPLOAD_DIR):
    os.makedirs(UPLOAD_DIR)
if not os.path.exists(PROCESSED_DIR):
    os.makedirs(PROCESSED_DIR)

st.title('FFmpeg Command Executor')

# File uploader
uploaded_file = st.file_uploader("Choose a file")

if uploaded_file is not None:
    # Save the uploaded file
    file_path = os.path.join(UPLOAD_DIR, uploaded_file.name)
    with open(file_path, 'wb') as f:
        f.write(uploaded_file.getbuffer())
    st.success('File uploaded successfully!')

    # Input for ffmpeg command
    command = st.text_area('Enter FFmpeg command', value=f'ffmpeg -i {file_path} -vf scale=1280:720 {os.path.join(PROCESSED_DIR, "output.mp4")}')

    if st.button('Run Command'):
        # Execute the FFmpeg command
        try:
            subprocess.run(command, shell=True, check=True)
            st.success('Command executed successfully!')
            
            # Display the processed video
            output_file_path = os.path.join(PROCESSED_DIR, 'output.mp4')
            st.video(output_file_path)  # Display video in Streamlit
        except subprocess.CalledProcessError as e:
            st.error(f'Error executing command: {e}')