示例#1
0
    print("", "Not enough files to stitch! Quitting...", sep="\n")
    quit()

# Check file extensions, for saving
save_ext = get_save_extension(input_file_paths_list)

# ---------------------------------------------------------------------------------------------------------------------
#%% Figure out saving

# Figure out a reasonable save name and then ask the user if they want to go with something different
default_save_name = "stitched_{}_files".format(num_videos_to_stitch)

# Ask the user for a file name or user the script argument
if arg_output_name is None:
    user_outname = cli_prompt_with_defaults("Enter output file name: ",
                                            default_value=default_save_name,
                                            return_type=str)
else:
    user_outname = arg_output_name
    print("",
          "Using input argument for output file name:",
          "  {}".format(user_outname),
          sep="\n")

# Overwrite the default output path if a script argument is available
save_folder_path = parent_folder_path
if arg_output_path is not None:
    save_folder_path = os.path.expanduser(arg_output_path)
    os.makedirs(save_folder_path, exist_ok=True)
    print("",
          "Using input argument for output folder path:",
# Get video list and name of videos for selection
video_list = guiLoadMany(windowTitle = "Select video files")
video_name_list = [os.path.basename(each_file) for each_file in video_list]
number_videos = len(video_list)

# Open all videos for initial info and then close them (untl we start recording)
video_objects = get_videos(video_list)
for each_video_object in video_objects:
    each_video_object.close()

# ---------------------------------------------------------------------------------------------------------------------
#%% Get output timing

# Have the user specify the output time
runtime_minutes = cli_prompt_with_defaults(prompt_message = "Enter output video length in minutes: ",
                                           return_type = float, 
                                           response_on_newline = False)

# Have the user specify the framerate of the output video
output_fps = cli_prompt_with_defaults(prompt_message = "Enter the output framerate: ",
                                      default_value = default_fps,
                                      return_type = float, 
                                      response_on_newline = False)

# Calculate the number of frames needed for the output video
runtime_seconds = runtime_minutes * 60
number_output_frames = int(round(1 + (output_fps * runtime_seconds)))


# ---------------------------------------------------------------------------------------------------------------------
#%% Configure tiling
示例#3
0
# Error out for videos that cannot be represented with hour:minute:second timestamp alone
video_too_long_warning(fake_date_offset, video_end_dt)  # Not tested! Need some longer videos to try this


# ---------------------------------------------------------------------------------------------------------------------
#%% Have user enter start/end clip points

# Feedback about the video
print("",
      "Selected: {}".format(video_name),
      "  Total duration: {}".format(video_end_str),
      sep="\n")

# Get the user to enter a start time or use the script argument
if arg_start_time is None:
    user_start_time = cli_prompt_with_defaults("Enter starting time: ", default_value = "00:00:00", return_type = str)
else:
    user_start_time = arg_start_time
    print("", "Using input argument for start time:", "  {}".format(user_start_time), sep="\n")

# Get the user to enter an end time or use the script argument
if arg_end_time is None:
    user_end_time = cli_prompt_with_defaults("Enter ending time: ", default_value = video_end_str, return_type = str)
else:
    user_end_time = arg_end_time
    print("", "Using input argument for end time:", "  {}".format(user_end_time), sep="\n")

# Convert user entries to a common datetime format for easier manipulation
start_clip_dt, end_clip_dt = parse_user_times(fake_date_offset, video_end_dt, user_start_time, user_end_time)

# ---------------------------------------------------------------------------------------------------------------------
示例#4
0
      "*" * 48,
      "",
      "Selected videos:",
      *[
          "  {}".format(os.path.basename(each_file))
          for each_file in video_file_select_list
      ],
      "",
      "*" * 48,
      sep="\n")

# ---------------------------------------------------------------------------------------------------------------------
#%% Get user input

# Set timelapsing factor & rotation amount
rotation_n90 = cli_prompt_with_defaults(
    "Enter number of CCW 90deg rotations: ", default_rotation, return_type=int)
tl_factor = cli_prompt_with_defaults("             Enter timelapse factor: ",
                                     default_timelapse,
                                     return_type=float)
scale_factor = cli_prompt_with_defaults(
    "     Enter dimension scaling factor: ", default_scale, return_type=float)

# For readability, figure out how much rotation we're doing
rotation_angle_deg = (90 * rotation_n90) % 360
needs_rotating = abs(rotation_angle_deg) > 0
needs_resizing = abs(scale_factor - 1.0) > 0.001
needs_timelapsing = abs(tl_factor - 1.0) > 0.001
scale_function = lambda frame, scaling: cv2.resize(
    frame, dsize=None, fx=scaling, fy=scaling)

# Update selection history