Skip to content

Pila #39

Description

@ashakhatikni-droid

st.write("### Original Video:")
st.video(temp_file)

Get video duration

try:
clip = VideoFileClip(temp_file)
duration = clip.duration
st.info(f"📹 Video Duration: {duration:.2f} seconds")
clip.close()
except Exception as e:
st.error(f"Video read karte waqt error: {e}")
st.stop()

st.write("### Video ko Cut Karein")
col1, col2 = st.columns(2)
with col1:
start_time = st.number_input("Start Time (seconds mein)", min_value=0.0, value=0.0, max_value=duration)
with col2:
end_time = st.number_input("End Time (seconds mein)", min_value=1.0, value=min(5.0, duration), max_value=duration)

if st.button("Video Trim Karein ✂️"):
if end_time <= start_time:
st.error("❌ End time, start time se bada hona chahiye!")
else:
with st.spinner("Video process ho rahi hai, kripya pratiksha karein..."):
try:
clip = VideoFileClip(temp_file)
trimmed_clip = clip.subclip(start_time, end_time)

            output_file = "output_video.mp4"
            trimmed_clip.write_videofile(output_file, codec="libx264", audio_codec="aac", verbose=False, logger=None)
            
            clip.close()
            trimmed_clip.close()
            
            st.success("✅ Video successfully trim ho gayi!")
            st.write("### Trimmed Video:")
            st.video(output_file)
            
        except Exception as e:
            st.error(f"❌ Koi error aayi: {e}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions