(output, overlay, file_path,
worker_nodes,
gpu_batchsize,
model_name,
frame_limit=-1,
prefetched_batches=4,
framerate=-1,
alpha_codec="auto",
alpha_pix_fmt=None)
| 370 | |
| 371 | |
| 372 | def transparentvideooverimage(output, overlay, file_path, |
| 373 | worker_nodes, |
| 374 | gpu_batchsize, |
| 375 | model_name, |
| 376 | frame_limit=-1, |
| 377 | prefetched_batches=4, |
| 378 | framerate=-1, |
| 379 | alpha_codec="auto", |
| 380 | alpha_pix_fmt=None): |
| 381 | temp_dir = tempfile.TemporaryDirectory() |
| 382 | tmpdirname = Path(temp_dir.name) |
| 383 | temp_file = os.path.abspath(os.path.join(tmpdirname, "matte.mp4")) |
| 384 | matte_key(temp_file, file_path, |
| 385 | worker_nodes, |
| 386 | gpu_batchsize, |
| 387 | model_name, |
| 388 | frame_limit, |
| 389 | prefetched_batches, |
| 390 | framerate) |
| 391 | print("Scale image") |
| 392 | temp_image = os.path.abspath("%s/new.jpg" % tmpdirname) |
| 393 | cmd = [ |
| 394 | 'ffmpeg', '-y', '-i', overlay, '-i', file_path, '-filter_complex', |
| 395 | 'scale2ref[img][vid];[img]setsar=1;[vid]nullsink', '-q:v', '2', temp_image |
| 396 | ] |
| 397 | sp.run(cmd) |
| 398 | print("Starting alphamerge") |
| 399 | encoding_args = _alpha_encoding_args(output, alpha_codec, alpha_pix_fmt) |
| 400 | cmd = [ |
| 401 | 'ffmpeg', '-y', '-i', temp_image, '-i', file_path, '-i', temp_file, '-filter_complex', |
| 402 | '[2][1]scale2ref[mask][main];[main][mask]alphamerge[fg];[0:v]scale2ref[bg][fg];[bg][fg]overlay=(W-w)/2:(H-h)/2:shortest=1[out]', |
| 403 | '-map', '[out]', '-map', '1:a?', '-shortest' |
| 404 | ] |
| 405 | cmd += encoding_args + [output] |
| 406 | sp.run(cmd) |
| 407 | print("Process finished") |
| 408 | try: |
| 409 | temp_dir.cleanup() |
| 410 | except PermissionError: |
| 411 | pass |
| 412 | return |
nothing calls this directly
no test coverage detected