awacke1 commited on
Commit
da5b3c1
·
1 Parent(s): 7e43dc0

Upload 2 files

Browse files
MP42AnimatedGif/app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from moviepy.editor import VideoFileClip
3
+ import os
4
+
5
+ st.title('Video to GIF converter')
6
+
7
+ uploaded_file = st.file_uploader("Choose a video...", type=["mp4", "mov", "avi", "mkv"])
8
+
9
+ if uploaded_file is not None:
10
+ with open("temp_video.mp4", "wb") as f:
11
+ f.write(uploaded_file.getbuffer())
12
+
13
+ st.success('Video uploaded successfully!')
14
+
15
+ start_time = st.number_input('Enter the start time (in seconds)', min_value=0, value=0, step=1)
16
+ duration = st.number_input('Enter the duration of the clip (in seconds)', min_value=1, value=5, step=1)
17
+ resolution = st.number_input('Enter the height resolution (in pixels)', min_value=1, value=480, step=1)
18
+
19
+ if st.button('Create GIF'):
20
+ video = VideoFileClip("temp_video.mp4")
21
+ clip = video.subclip(start_time, start_time + duration)
22
+ clip_resized = clip.resize(height=resolution)
23
+ clip_resized.write_gif("output.gif", fps=clip.fps)
24
+
25
+ st.success('GIF created successfully! Check your directory for a file named "output.gif".')
26
+ os.remove("temp_video.mp4") # remove the temporary video file
MP42AnimatedGif/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ moviepy