jbilcke-hf HF staff commited on
Commit
76d7206
1 Parent(s): 82a3d77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -200,7 +200,14 @@ def export_to_video_file(video_frames, output_video_path=None, fps=hardcoded_fps
200
  #
201
  # Scene change detection threshold. Default is 5.0.
202
 
203
- def interpolate_video_frames(input_file_path, output_file_path, output_fps=hardcoded_fps, desired_duration=hardcoded_duration_sec, original_duration=hardcoded_duration_sec, verbose=False):
 
 
 
 
 
 
 
204
  scale_factor = desired_duration / original_duration
205
  # note: from all fact, it looks like using a small macroblock is important for us,
206
  # since the video resolution is very small (usually 512x288px)
@@ -217,11 +224,17 @@ def interpolate_video_frames(input_file_path, output_file_path, output_fps=hardc
217
  cmd = [
218
  'ffmpeg',
219
  '-i', input_file_path,
 
 
 
 
 
 
220
  '-filter:v', interpolation_filter,
221
  '-r', str(output_fps),
222
  output_file_path
223
- ]
224
-
225
  # Adjust the log level based on the verbosity input
226
  if not verbose:
227
  cmd.insert(1, '-loglevel')
 
200
  #
201
  # Scene change detection threshold. Default is 5.0.
202
 
203
+ def interpolate_video_frames(
204
+ input_file_path,
205
+ output_file_path,
206
+ output_fps=hardcoded_fps,
207
+ desired_duration=hardcoded_duration_sec,
208
+ original_duration=hardcoded_duration_sec,
209
+ use_cuda=True, # this requires FFmpeg to have been compiled with CUDA support (to try - I'm not sure the Hugging Face image has that by default)
210
+ verbose=False):
211
  scale_factor = desired_duration / original_duration
212
  # note: from all fact, it looks like using a small macroblock is important for us,
213
  # since the video resolution is very small (usually 512x288px)
 
224
  cmd = [
225
  'ffmpeg',
226
  '-i', input_file_path,
227
+ ]
228
+
229
+ if use_cuda:
230
+ cmd.extend(['-hwaccel', 'cuda', '-hwaccel_output_format', 'cuda'])
231
+
232
+ cmd.extend([
233
  '-filter:v', interpolation_filter,
234
  '-r', str(output_fps),
235
  output_file_path
236
+ ])
237
+
238
  # Adjust the log level based on the verbosity input
239
  if not verbose:
240
  cmd.insert(1, '-loglevel')