Omnibus commited on
Commit
9b332c3
·
1 Parent(s): 2043290

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -133,18 +133,19 @@ def dl(inp):
133
  out = None
134
  return out,out,out,out,out
135
 
136
- def trim_vid(vid,start_time,end_time):
137
  print (vid)
138
  start_hr=int(start_time.split(":",2)[0])*360
139
  start_min=int(start_time.split(":",2)[1])*60
140
- start_sec=int(start_time.split(":",2)[2])
141
  end_hr=int(end_time.split(":",2)[0])*360
142
  end_min=int(end_time.split(":",2)[1])*60
143
- end_sec=int(end_time.split(":",2)[2])
144
  start=start_hr+start_min+start_sec
145
  end=end_hr+end_min+end_sec
146
  #vid = f"{inp_out}.mp4"
147
  ffmpeg_extract_subclip(vid, start, end, targetname=f"{uid}-clip.mp4")
 
148
  out= f"{uid}-clip.mp4"
149
  capture = cv2.VideoCapture(out)
150
  frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
@@ -193,6 +194,7 @@ with gr.Blocks() as app:
193
  start_f = gr.Textbox(label = "Start", value = "0:00:00", placeholder = "0:00:23",interactive = True)
194
  end_f = gr.Textbox(label = "End", value = "0:00:05", placeholder = "0:00:54",interactive = True)
195
  trim_count = gr.Textbox(label="Trimmed Frames")
 
196
  trim_btn=gr.Button("Trim")
197
  out_trim=gr.Video(format="mp4")
198
  hid_box = gr.Textbox(visible=True)
@@ -238,7 +240,7 @@ with gr.Blocks() as app:
238
  return inp
239
  #outp_vid.change(echo_fn,outp_vid,[out_trim])
240
  gif_btn.click(make_gif,None,[gif_show,gif_file])
241
- trim_btn.click(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
242
  outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f]).then(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
243
  frame_btn.click(capture_function,[out_trim],[frame_gal,frame_file,frame_stat])
244
  rem_btn.click(rem_bg,[out_trim],[rem_vid,frame_num,rem_bg_vid])
 
133
  out = None
134
  return out,out,out,out,out
135
 
136
+ def trim_vid(vid,start_time,end_time,clip_speed):
137
  print (vid)
138
  start_hr=int(start_time.split(":",2)[0])*360
139
  start_min=int(start_time.split(":",2)[1])*60
140
+ start_sec=float(start_time.split(":",2)[2])
141
  end_hr=int(end_time.split(":",2)[0])*360
142
  end_min=int(end_time.split(":",2)[1])*60
143
+ end_sec=float(end_time.split(":",2)[2])
144
  start=start_hr+start_min+start_sec
145
  end=end_hr+end_min+end_sec
146
  #vid = f"{inp_out}.mp4"
147
  ffmpeg_extract_subclip(vid, start, end, targetname=f"{uid}-clip.mp4")
148
+ final = clip.fx( vfx.speedx, float(clip_speed))
149
  out= f"{uid}-clip.mp4"
150
  capture = cv2.VideoCapture(out)
151
  frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
 
194
  start_f = gr.Textbox(label = "Start", value = "0:00:00", placeholder = "0:00:23",interactive = True)
195
  end_f = gr.Textbox(label = "End", value = "0:00:05", placeholder = "0:00:54",interactive = True)
196
  trim_count = gr.Textbox(label="Trimmed Frames")
197
+ clip_speed = gr.Slider(label="Speed", min=0.1, max=2, value=1, step=0.1)
198
  trim_btn=gr.Button("Trim")
199
  out_trim=gr.Video(format="mp4")
200
  hid_box = gr.Textbox(visible=True)
 
240
  return inp
241
  #outp_vid.change(echo_fn,outp_vid,[out_trim])
242
  gif_btn.click(make_gif,None,[gif_show,gif_file])
243
+ trim_btn.click(trim_vid,[hid_box,start_f,end_f,clip_speed],[out_trim,in_vid,trim_count])
244
  outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f]).then(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
245
  frame_btn.click(capture_function,[out_trim],[frame_gal,frame_file,frame_stat])
246
  rem_btn.click(rem_bg,[out_trim],[rem_vid,frame_num,rem_bg_vid])