Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def manual_timestamps(string):
"""Type parser for argparse. Argument must be a comma-separated list of frame timestamps.
For example 1:11:11.111,2:22:22.222
"""
try:
timestamps = string.split(",")
timestamps = [x.strip() for x in timestamps if x]
# check whether timestamps are valid
for t in timestamps:
MediaInfo.pretty_to_seconds(t)
return timestamps
except Exception as e:
print(e)
error = "Manual frame timestamps must be comma-separated and of the form h:mm:ss.mmmm"
raise argparse.ArgumentTypeError(error)
media_capture,
args):
"""Make `num_samples` captures and select `num_selected` captures out of these
based on blurriness and color variety.
"""
desired_size = grid_desired_size(
args.grid,
media_info,
width=args.vcs_width,
horizontal_margin=args.grid_horizontal_spacing)
if args.manual_timestamps is None:
timestamps = timestamp_generator(media_info, args)
else:
timestamps = [(MediaInfo.pretty_to_seconds(x), x) for x in args.manual_timestamps]
def do_capture(ts_tuple, width, height, suffix, args):
fd, filename = tempfile.mkstemp(suffix=suffix)
media_capture.make_capture(ts_tuple[1], width, height, filename)
blurriness = 1
avg_color = 0
if not args.fast:
blurriness = media_capture.compute_blurriness(filename)
avg_color = media_capture.compute_avg_color(filename)
os.close(fd)
frm = Frame(
filename=filename,
if self.frame_type == "key":
select_args = [
"-vf", "select=key"
]
if self.frame_type is not None:
ffmpeg_command += select_args
ffmpeg_command += [
"-y",
out_path
]
if self.accurate:
time_seconds = MediaInfo.pretty_to_seconds(time)
skip_time_seconds = time_seconds - self.skip_delay_seconds
if skip_time_seconds < 0:
ffmpeg_command = [
"ffmpeg",
"-i", self.path,
"-ss", time,
"-vframes", "1",
"-s", "%sx%s" % (width, height),
]
if self.frame_type is not None:
ffmpeg_command += select_args
ffmpeg_command += [
"-y",