Skip to content

Commit

Permalink
Fix extension issues
Browse files Browse the repository at this point in the history
If user did not specified extension when exposrting the program would crash, now it is filled by default if not available
  • Loading branch information
X3msnake authored Jun 28, 2023
1 parent d51cc19 commit d7cda9b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions revoscan_frame_player.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# If you are running this code from the command line don't forget to install the following libraries:
# pip install opencv-python numpy

import os
import cv2
import tkinter as tk
Expand Down Expand Up @@ -50,7 +47,7 @@ def on_trackbar(pos):
# Initialize video writer
output_file = None
output_width, output_height = None, None
fps = 30.0
fps = 24.0

while cv2.getWindowProperty(window_name, cv2.WND_PROP_VISIBLE) >= 1:
# Load the current frame
Expand Down Expand Up @@ -94,6 +91,7 @@ def on_trackbar(pos):
elif key == ord('9') and current_frame < len(image_files) - 1:
current_frame += 10

# Export to video if Shift+E is pressed
# Export to video if Shift+E is pressed
if key == ord('E'):
output_file = filedialog.asksaveasfilename(
Expand All @@ -103,6 +101,12 @@ def on_trackbar(pos):
)

if output_file:
# Check if the output file has an extension
_, file_extension = os.path.splitext(output_file)
if not file_extension:
# Append a default extension, such as ".mp4"
output_file += ".mp4"

output_width, output_height = frame.shape[1], frame.shape[0]
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
output_video = cv2.VideoWriter(output_file, fourcc, fps, (output_width, output_height))
Expand Down

0 comments on commit d7cda9b

Please sign in to comment.