MCPcopy
hub / github.com/Rudrabha/Wav2Lip / process_video_file

Function process_video_file

preprocess.py:38–67  ·  view source on GitHub ↗
(vfile, args, gpu_id)

Source from the content-addressed store, hash-verified

36# template2 = 'ffmpeg -hide_banner -loglevel panic -threads 1 -y -i {} -async 1 -ac 1 -vn -acodec pcm_s16le -ar 16000 {}'
37
38def 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
69def process_audio_file(vfile, args):
70 vidname = os.path.basename(vfile).split('.')[0]

Callers 1

mp_handlerFunction · 0.85

Calls 1

Tested by

no test coverage detected