jbilcke-hf HF staff commited on
Commit
7316f37
·
verified ·
1 Parent(s): 8d4c270

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -34
app.py CHANGED
@@ -105,8 +105,6 @@ def interpolate_video_frames(input_file_path, output_file_path, output_fps=10, d
105
  Returns:
106
  str: The file path of the modified video.
107
  """
108
- # Calculate the input fps required to stretch the video to the desired duration
109
- input_fps = find_input_fps(input_file_path, desired_duration)
110
 
111
  # Construct the ffmpeg command for interpolation
112
  cmd = [
@@ -117,7 +115,6 @@ def interpolate_video_frames(input_file_path, output_file_path, output_fps=10, d
117
  output_file_path # Output file
118
  ]
119
 
120
- print("input_fps:", input_fps)
121
  print("output_fps:", output_fps)
122
  print("desired_duration:", desired_duration)
123
  print("cmd:", cmd)
@@ -130,37 +127,7 @@ def interpolate_video_frames(input_file_path, output_file_path, output_fps=10, d
130
  except subprocess.CalledProcessError as e:
131
  print("Failed to interpolate video. Error:", e)
132
  return output_file_path
133
-
134
- def find_input_fps(file_path, desired_duration):
135
- """
136
- Determine the input fps that, when stretched to the desired duration, matches the original video length.
137
-
138
- Parameters:
139
- file_path (str): Path to the video file.
140
- desired_duration (int or float): Desired duration in seconds.
141
-
142
- Returns:
143
- float: Calculated input fps.
144
- """
145
- # FFprobe command to find the duration of the video
146
- ffprobe_cmd = [
147
- 'ffprobe',
148
- '-v', 'error',
149
- '-show_entries', 'format=duration',
150
- '-of', 'default=noprint_wrappers=1:nokey=1',
151
- file_path
152
- ]
153
-
154
- try:
155
- result = subprocess.run(ffprobe_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
156
- duration = float(result.stdout.strip())
157
- input_fps = duration / desired_duration
158
- except Exception as e:
159
- print("Failed to get video duration. Error:", e)
160
- input_fps = 10 # Assume a default value if unable to fetch duration
161
-
162
- return input_fps
163
-
164
  def generate_image(secret_token, prompt, base, width, height, motion, step, desired_duration, desired_fps):
165
  if secret_token != SECRET_TOKEN:
166
  raise gr.Error(
 
105
  Returns:
106
  str: The file path of the modified video.
107
  """
 
 
108
 
109
  # Construct the ffmpeg command for interpolation
110
  cmd = [
 
115
  output_file_path # Output file
116
  ]
117
 
 
118
  print("output_fps:", output_fps)
119
  print("desired_duration:", desired_duration)
120
  print("cmd:", cmd)
 
127
  except subprocess.CalledProcessError as e:
128
  print("Failed to interpolate video. Error:", e)
129
  return output_file_path
130
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  def generate_image(secret_token, prompt, base, width, height, motion, step, desired_duration, desired_fps):
132
  if secret_token != SECRET_TOKEN:
133
  raise gr.Error(