Update app.py
Browse files
app.py
CHANGED
@@ -200,17 +200,16 @@ 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):
|
204 |
scale_factor = desired_duration / original_duration
|
205 |
-
#
|
206 |
-
#
|
207 |
-
# new value:
|
208 |
interpolation_filter = f'minterpolate=mi_mode=mci:mc_mode=obmc:me=hexbs:vsbmc=1:mb_size=4:fps={output_fps}:scd=none,setpts={scale_factor}*PTS'
|
209 |
#- `mi_mode=mci`: Specifies motion compensated interpolation.
|
210 |
#- `mc_mode=obmc`: Overlapped block motion compensation is used.
|
211 |
#- `me=hexbs`: Hexagon-based search (motion estimation method).
|
212 |
#- `vsbmc=1`: Variable-size block motion compensation is enabled.
|
213 |
-
#- `mb_size=
|
214 |
#- `fps={output_fps}`: Defines the output frame rate.
|
215 |
#- `scd=none`: Disables scene change detection entirely.
|
216 |
#- `setpts={scale_factor}*PTS`: Adjusts for the stretching of the video duration.
|
@@ -223,11 +222,17 @@ def interpolate_video_frames(input_file_path, output_file_path, output_fps=hardc
|
|
223 |
output_file_path
|
224 |
]
|
225 |
|
226 |
-
#
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
try:
|
233 |
subprocess.run(cmd, check=True)
|
|
|
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)
|
|
|
207 |
interpolation_filter = f'minterpolate=mi_mode=mci:mc_mode=obmc:me=hexbs:vsbmc=1:mb_size=4:fps={output_fps}:scd=none,setpts={scale_factor}*PTS'
|
208 |
#- `mi_mode=mci`: Specifies motion compensated interpolation.
|
209 |
#- `mc_mode=obmc`: Overlapped block motion compensation is used.
|
210 |
#- `me=hexbs`: Hexagon-based search (motion estimation method).
|
211 |
#- `vsbmc=1`: Variable-size block motion compensation is enabled.
|
212 |
+
#- `mb_size=4`: Sets the macroblock size.
|
213 |
#- `fps={output_fps}`: Defines the output frame rate.
|
214 |
#- `scd=none`: Disables scene change detection entirely.
|
215 |
#- `setpts={scale_factor}*PTS`: Adjusts for the stretching of the video duration.
|
|
|
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')
|
228 |
+
cmd.insert(2, 'error')
|
229 |
+
|
230 |
+
# Logging for debugging if verbose
|
231 |
+
if verbose:
|
232 |
+
print("output_fps:", output_fps)
|
233 |
+
print("desired_duration:", desired_duration)
|
234 |
+
print("original_duration:", original_duration)
|
235 |
+
print("cmd:", cmd)
|
236 |
|
237 |
try:
|
238 |
subprocess.run(cmd, check=True)
|