Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
902 B
3
Indexable
Never
import cv2

# Path to your MPEG-TS video file
mpegts_video_path = '/mnt/share/nas-2/arik_newdata040724/rapat_drone_data/dronedata#1/mavic_experiment_13.12/mavic_horizontal_attack_10-80_13.12/2023-08-29_11-54-08.668340464/2023-08-29_11-54-08.668340464_vis1.mpegts'

# Step 1: Open video file
cap = cv2.VideoCapture(mpegts_video_path)                      

if not cap.isOpened():
    print("Error: Could not open video file.")
    exit()

# Step 2: Visualize frames and advance with spacebar
while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break

    cv2.imshow('Frame', frame)
    while True:
        key = cv2.waitKey(1) & 0xFF
        if key == ord(' '):  # Spacebar to go to the next frame
            break
        elif key == ord('q'):  # 'q' to quit
            cap.release()
            cv2.destroyAllWindows()
            exit()

cap.release()
cv2.destroyAllWindows()
Leave a Comment