(video_path, frame_id)
| 138 | |
| 139 | |
| 140 | def extract_specific_frames(video_path, frame_id): |
| 141 | if is_video(video_path): |
| 142 | vr = VideoReader(video_path, ctx=cpu(0)) |
| 143 | if frame_id < vr._num_frame: |
| 144 | frame = vr[frame_id].asnumpy() # RGB |
| 145 | else: |
| 146 | frame = vr[-1].asnumpy() |
| 147 | del vr |
| 148 | gc.collect() |
| 149 | frame = Image.fromarray(frame) |
| 150 | else: |
| 151 | frame = Image.open(video_path).convert("RGB") |
| 152 | return frame |
| 153 | |
| 154 | def get_video_codec(video_path): |
| 155 | result = subprocess.run( |
no test coverage detected