cut and edit video
To upload files, please first save the app
import streamlit as st
from moviepy.editor import VideoFileClip
import tempfile
st.title('Video Cutter and Editor')
uploaded_file = st.file_uploader('Upload a video file', type=['mp4', 'mov', 'avi'])
if uploaded_file is not None:
st.video(uploaded_file)
video = VideoFileClip(uploaded_file.name)
st.write('Select start and end time for the video:')
start_time = st.number_input('Start Time (in seconds)', min_value=0.0, max_value=video.duration, value=0.0, step=0.1)
end_time = st.number_input('End Time (in seconds)', min_value=start_time, max_value=video.duration, value=video.duration, step=0.1)
if st.button('Cut Video'):
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as temp_file:
cut_video = video.subclip(start_time, end_time)
cut_video.write_videofile(temp_file.name, codec='libx264')
st.success('Video cut successfully!')
st.video(temp_file.name)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?