roychao19477 commited on
Commit
be494d7
·
1 Parent(s): 69a1954
Files changed (1) hide show
  1. app.py +6 -26
app.py CHANGED
@@ -135,34 +135,9 @@ def extract_resampled_audio(video_path, target_sr=16000):
135
  torchaudio.save(resampled_audio_path, waveform, sample_rate=target_sr)
136
  return resampled_audio_path
137
 
138
- import ffmpeg
139
- import os
140
-
141
- def maybe_downsample(video_path):
142
- probe = ffmpeg.probe(video_path)
143
- video_streams = [s for s in probe['streams'] if s['codec_type'] == 'video']
144
- width = int(video_streams[0]['width'])
145
- height = int(video_streams[0]['height'])
146
-
147
- if height > 720:
148
- downsampled_path = tempfile.mktemp(suffix="_720p.mp4")
149
- (
150
- ffmpeg
151
- .input(video_path)
152
- .filter('scale', -1, 720)
153
- .output(downsampled_path, vcodec='libx264', acodec='aac')
154
- .overwrite_output()
155
- .run(quiet=True)
156
- )
157
- return downsampled_path
158
- else:
159
- return video_path
160
 
161
  @spaces.GPU
162
  def extract_faces(video_file):
163
- #cap = cv2.VideoCapture(video_file)
164
- #fps = cap.get(cv2.CAP_PROP_FPS)
165
- video_file = maybe_downsample(video_file)
166
  cap = cv2.VideoCapture(video_file)
167
  fps = cap.get(cv2.CAP_PROP_FPS)
168
  frames = []
@@ -242,8 +217,13 @@ def extract_faces(video_file):
242
 
243
  enhanced_audio_path = run_avse_inference(output_path, audio_path)
244
 
 
 
 
 
245
 
246
- return output_path, enhanced_audio_path
 
247
  #return output_path, audio_path
248
 
249
  iface = gr.Interface(
 
135
  torchaudio.save(resampled_audio_path, waveform, sample_rate=target_sr)
136
  return resampled_audio_path
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  @spaces.GPU
140
  def extract_faces(video_file):
 
 
 
141
  cap = cv2.VideoCapture(video_file)
142
  fps = cap.get(cv2.CAP_PROP_FPS)
143
  frames = []
 
217
 
218
  enhanced_audio_path = run_avse_inference(output_path, audio_path)
219
 
220
+ from moviepy.video.fx import flip_vertical
221
+ flipped_output_path = os.path.join(tmpdir, "face_only_video_flipped.mp4")
222
+ flipped_clip = flip_vertical(clip)
223
+ flipped_clip.write_videofile(flipped_output_path, codec="libx264", audio=False, fps=25)
224
 
225
+ return flipped_output_path, enhanced_audio_path
226
+ #return output_path, enhanced_audio_path
227
  #return output_path, audio_path
228
 
229
  iface = gr.Interface(