MCPcopy Index your code
hub / github.com/FoundationVision/ByteTrack / convert_video

Function convert_video

tools/convert_video.py:3–22  ·  view source on GitHub ↗
(video_path)

Source from the content-addressed store, hash-verified

1import cv2
2
3def convert_video(video_path):
4 cap = cv2.VideoCapture(video_path)
5 width = cap.get(cv2.CAP_PROP_FRAME_WIDTH) # float
6 height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT) # float
7 fps = cap.get(cv2.CAP_PROP_FPS)
8 video_name = video_path.split('/')[-1].split('.')[0]
9 save_name = video_name + '_converted'
10 save_path = video_path.replace(video_name, save_name)
11 vid_writer = cv2.VideoWriter(
12 save_path, cv2.VideoWriter_fourcc(*"mp4v"), fps, (int(width), int(height))
13 )
14 while True:
15 ret_val, frame = cap.read()
16 if ret_val:
17 vid_writer.write(frame)
18 ch = cv2.waitKey(1)
19 if ch == 27 or ch == ord("q") or ch == ord("Q"):
20 break
21 else:
22 break
23
24if __name__ == "__main__":
25 video_path = 'videos/palace.mp4'

Callers 1

convert_video.pyFile · 0.85

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected