| 70 | |
| 71 | |
| 72 | def get_seq_frames(video_size, num_frames, clip_idx, num_clips, start_index=0, max_frame=-1): |
| 73 | seg_size = max(0., float(video_size - 1) / num_frames) |
| 74 | if max_frame == -1: |
| 75 | max_frame = int(video_size) - 1 |
| 76 | seq = [] |
| 77 | # index from 1, must add 1 |
| 78 | if clip_idx == -1: |
| 79 | for i in range(num_frames): |
| 80 | start = int(np.round(seg_size * i)) |
| 81 | end = int(np.round(seg_size * (i + 1))) |
| 82 | idx = min(random.randint(start, end) + start_index, max_frame) |
| 83 | seq.append(idx) |
| 84 | else: |
| 85 | duration = seg_size / (num_clips + 1) |
| 86 | for i in range(num_frames): |
| 87 | start = int(np.round(seg_size * i)) |
| 88 | frame_index = start + int(duration * (clip_idx + 1)) |
| 89 | idx = min(frame_index + start_index, max_frame) |
| 90 | seq.append(idx) |
| 91 | return seq |
| 92 | |
| 93 | |
| 94 | def pyav_decode_stream( |