MCPcopy
hub / github.com/nadermx/backgroundremover / transparentvideo

Function transparentvideo

backgroundremover/utilities.py:299–333  ·  view source on GitHub ↗
(output, file_path,
                     worker_nodes,
                     gpu_batchsize,
                     model_name,
                     frame_limit=-1,
                     prefetched_batches=4,
                     framerate=-1,
                     alpha_codec="auto",
                     alpha_pix_fmt=None)

Source from the content-addressed store, hash-verified

297
298
299def transparentvideo(output, file_path,
300 worker_nodes,
301 gpu_batchsize,
302 model_name,
303 frame_limit=-1,
304 prefetched_batches=4,
305 framerate=-1,
306 alpha_codec="auto",
307 alpha_pix_fmt=None):
308 temp_dir = tempfile.TemporaryDirectory()
309 tmpdirname = Path(temp_dir.name)
310 temp_file = os.path.abspath(os.path.join(tmpdirname, "matte.mp4"))
311 matte_key(temp_file, file_path,
312 worker_nodes,
313 gpu_batchsize,
314 model_name,
315 frame_limit,
316 prefetched_batches,
317 framerate)
318 print("Starting alphamerge")
319 encoding_args = _alpha_encoding_args(output, alpha_codec, alpha_pix_fmt)
320 cmd = [
321 'ffmpeg', '-y', '-i', file_path, '-i', temp_file, '-filter_complex',
322 '[1][0]scale2ref[mask][main];[main][mask]alphamerge[v]',
323 '-map', '[v]', '-map', '0:a?', '-shortest'
324 ]
325 cmd += encoding_args + [output]
326
327 sp.run(cmd)
328 print("Process finished")
329 try:
330 temp_dir.cleanup()
331 except PermissionError:
332 pass
333 return
334
335
336def transparentvideoovervideo(output, overlay, file_path,

Callers

nothing calls this directly

Calls 2

matte_keyFunction · 0.85
_alpha_encoding_argsFunction · 0.85

Tested by

no test coverage detected