PaddlePaddle / PaddleVideo

Awesome video understanding toolkits based on PaddlePaddle. It supports video data annotation tools, lightweight RGB and skeleton based action recognition model, practical applications for video tagging and sport action detection.
Apache License 2.0
1.46k stars 374 forks source link

Do you have any conversion code? Thanks a lot #667

Open zhaoyanjoin opened 6 months ago

zhaoyanjoin commented 6 months ago
          .pkl file is composed of frames, so you can decode video to frames, then save frames to .pkl file

Originally posted by @huangjun12 in https://github.com/PaddlePaddle/PaddleVideo/issues/571#issuecomment-1411413154

westfish commented 5 months ago
import cv2
import pickle

cap = cv2.VideoCapture('your_video.mp4')

frames = []
while True:
    ret, frame = cap.read()

    if ret:
        frames.append(frame)
    else:
        break

with open('frames.pkl', 'wb') as f:
    pickle.dump(frames, f)

have a try