ysharma HF staff commited on
Commit
ef53b73
1 Parent(s): 6022707
Files changed (1) hide show
  1. app.py +24 -18
app.py CHANGED
@@ -139,7 +139,7 @@ def get_gif_word_indexes(total_words_list, gif_words_list):
139
 
140
 
141
  #getting start and end timestamps for gif transcript
142
- def get_gif_timestamps(giflist_indxs, words_timestamp):
143
  print(f"******** Inside get_gif_timestamps() **********")
144
  min_idx = min(giflist_indxs)
145
  max_idx = max(giflist_indxs)
@@ -163,23 +163,15 @@ def gen_moviepy_gif(start_seconds, end_seconds):
163
  video = mp.VideoFileClip(video_path)
164
  final_clip = video.subclip(start_seconds, end_seconds)
165
 
166
- final_clip.write_gif("./gifimage1.gif") #, program='ffmpeg', tempfiles=True, fps=15, fuzz=3)
 
167
  final_clip.close()
168
 
169
- #gif_img = mp.VideoFileClip("gifimage.gif")
170
- #print(gif_img)
171
- #gif_img.write_videofile("gifimage.mp4")
172
  #gif_vid = mp.VideoFileClip("gifimage.mp4")
173
-
174
  #im = Image.open("gifimage.gif")
175
  #vid_cap = cv2.VideoCapture('gifimage.mp4')
176
-
177
- print("At the very end")
178
- return "gifimage1.gif" #im, gif_img, gif_vid, vid_cap, #"gifimage.mp4"
179
-
180
-
181
- # showing gif
182
- #gif.ipython_display()
183
 
184
 
185
  sample_video = ['./ShiaLaBeouf.mp4']
@@ -192,15 +184,29 @@ demo = gr.Blocks()
192
  with demo:
193
  gr.Markdown("""This app is still a work in progress..""")
194
  with gr.Row():
195
- input_video = gr.Video(label="Upload a Video", visible=True) #for incoming video
196
- text_transcript = gr.Textbox(label="Transcripts", lines = 10, interactive = True ) #to generate and display transcriptions for input video
 
 
 
 
 
 
 
 
 
 
 
197
  text_words = gr.Textbox(visible=False)
198
  text_wordstimestamps = gr.Textbox(visible=False)
199
- text_gif_transcript = gr.Textbox(label="Transcripts", placeholder="Copy paste transcripts here to create GIF image" , lines = 3, interactive = True ) #to copy paste required gif transcript
200
- #out_gif = gr.HTML(label="Generated GIF from transcript selected", show_label=True)
201
 
 
 
 
 
202
  examples.render()
203
- def load_examples(video): #to load sample video into input_video upon clicking on it
 
204
  print("****** inside load_example() ******")
205
  print("in_video is : ", video[0])
206
  return video[0]
 
139
 
140
 
141
  #getting start and end timestamps for gif transcript
142
+ def get_gif_timestamps(giflist_indxs, words_timestamp):
143
  print(f"******** Inside get_gif_timestamps() **********")
144
  min_idx = min(giflist_indxs)
145
  max_idx = max(giflist_indxs)
 
163
  video = mp.VideoFileClip(video_path)
164
  final_clip = video.subclip(start_seconds, end_seconds)
165
 
166
+ final_clip.write_gif("gifimage.gif") #, program='ffmpeg', tempfiles=True, fps=15, fuzz=3)
167
+ final_clip.write_videofile("gifimage.mp4")
168
  final_clip.close()
169
 
170
+ gif_img = mp.VideoFileClip("gifimage.gif")
 
 
171
  #gif_vid = mp.VideoFileClip("gifimage.mp4")
 
172
  #im = Image.open("gifimage.gif")
173
  #vid_cap = cv2.VideoCapture('gifimage.mp4')
174
+ return "gifimage.gif" #im, gif_img, gif_vid, vid_cap, #"gifimage.mp4"
 
 
 
 
 
 
175
 
176
 
177
  sample_video = ['./ShiaLaBeouf.mp4']
 
184
  with demo:
185
  gr.Markdown("""This app is still a work in progress..""")
186
  with gr.Row():
187
+ #for incoming video
188
+ input_video = gr.Video(label="Upload a Video", visible=True)
189
+ #to generate and display transcriptions for input video
190
+ text_transcript = gr.Textbox(label="Transcripts", lines = 10, interactive = True )
191
+
192
+ def load_gif_text(text):
193
+ print("****** inside load_gif_text() ******")
194
+ print("text for gif is : ", text)
195
+ return text
196
+
197
+ text_transcript.change(load_gif_text, text_transcript, text_gif_transcript )
198
+
199
+ #Just to move dgata between function hence keeping visible false
200
  text_words = gr.Textbox(visible=False)
201
  text_wordstimestamps = gr.Textbox(visible=False)
 
 
202
 
203
+ #to copy paste required gif transcript / or to populate by itslef on pressing the button
204
+ text_gif_transcript = gr.Textbox(label="Transcripts", placeholder="Copy paste transcripts here to create GIF image" , lines = 3, interactive = True )
205
+
206
+ #to render video example on mouse hover/click
207
  examples.render()
208
+ #to load sample video into input_video upon clicking on it
209
+ def load_examples(video):
210
  print("****** inside load_example() ******")
211
  print("in_video is : ", video[0])
212
  return video[0]