(vfile, args, gpu_id)
| 36 | # template2 = 'ffmpeg -hide_banner -loglevel panic -threads 1 -y -i {} -async 1 -ac 1 -vn -acodec pcm_s16le -ar 16000 {}' |
| 37 | |
| 38 | def process_video_file(vfile, args, gpu_id): |
| 39 | video_stream = cv2.VideoCapture(vfile) |
| 40 | |
| 41 | frames = [] |
| 42 | while 1: |
| 43 | still_reading, frame = video_stream.read() |
| 44 | if not still_reading: |
| 45 | video_stream.release() |
| 46 | break |
| 47 | frames.append(frame) |
| 48 | |
| 49 | vidname = os.path.basename(vfile).split('.')[0] |
| 50 | dirname = vfile.split('/')[-2] |
| 51 | |
| 52 | fulldir = path.join(args.preprocessed_root, dirname, vidname) |
| 53 | os.makedirs(fulldir, exist_ok=True) |
| 54 | |
| 55 | batches = [frames[i:i + args.batch_size] for i in range(0, len(frames), args.batch_size)] |
| 56 | |
| 57 | i = -1 |
| 58 | for fb in batches: |
| 59 | preds = fa[gpu_id].get_detections_for_batch(np.asarray(fb)) |
| 60 | |
| 61 | for j, f in enumerate(preds): |
| 62 | i += 1 |
| 63 | if f is None: |
| 64 | continue |
| 65 | |
| 66 | x1, y1, x2, y2 = f |
| 67 | cv2.imwrite(path.join(fulldir, '{}.jpg'.format(i)), fb[j][y1:y2, x1:x2]) |
| 68 | |
| 69 | def process_audio_file(vfile, args): |
| 70 | vidname = os.path.basename(vfile).split('.')[0] |
no test coverage detected