video – ffmpeg add watermark out of memory

we want to add watermark to video using ffmpeg. When the video is relatively large, there will be out of memory. Below is our code, how can I go about eliminating this problem.
enter code here

        filter_args="[1][0]scale2ref=oh*mdar:ih*0.06[logo];[logo]overlay=0:(main_h-overlay_h)"
        cmd = [
            'ffmpeg',
            '-i', mp4_done_path,
            '-i', './watermark.png',
            '-filter_complex', filter_args,
            videoPath
        ]
        process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Read more here: Source link