Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
🔥 Add: MOV to JPG
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerohertz committed Apr 4, 2023
1 parent 9d132ee commit 1e4249e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mov2jpg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import cv2
import os

def sample_images(video_file, output_folder, interval=1000):
cap = cv2.VideoCapture(video_file)
if not cap.isOpened():
print("Error: failed to open video file.")
return
if not os.path.exists(output_folder):
os.makedirs(output_folder)
count = 0
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
if count % interval == 0:
image_file = os.path.join(output_folder, f"{count}.jpg")
cv2.imwrite(image_file, frame)
count += 1
cap.release()

if __name__ == "__main__":
sample_images("tar.MOV", "output_folder", 100)

0 comments on commit 1e4249e

Please sign in to comment.