ffmpeg

How to correctly specify the path to a file in -vf media?


Good afternoon, please, I really need help. I'm putting a watermark on the video:

with tempfile.TemporaryFile("wb", delete=False, suffix=".png") as watermark_file:
    watermark_file.write(buff.read())
(
    ffmpeg
    .input(str(path))
    .output(
        os.environ.get("TEMP")+f"\\{uuid.hex}_{path.name}",
        vf=f"movie='{watermark_file.name}' [watermark]; [in][watermark] overlay='{overlay}' [out]"
    )
    .global_args('-copyts')
    .run()
)

In a temporary folder, I create a file in which I write a watermark from io.BytesIO using the ffmpeg-python library, I do not work directly with the console.

The problem is that when running .run() to the console outputs the following:

[Parsed_movie_0 @ 0000011b21b3e300] Failed to avformat_open_input 'C'
[AVFilterGraph @ 0000011b21b4d4c0] Error initializing filters
[vost#0:0/libvpx-vp9 @ 0000011b23a07500] Error initializing a simple filtergraph
Error opening output file C:\Users\smeta\AppData\Local\Temp\5e5a695966cf4d728edbd7f39c509d0e_000.webm.
Error opening output files: No such file or directory

But if I copy a watermarked file from temp and upload it to the workspace: vf=f"movie='{'test.png'}' [watermark]; [in][watermark] overlay='{overlay}' [out]" then everything works as it should. I.e. apparently there is a problem with the path to the watermark, and I do not understand what to do. I ask for help


Solution

  • : is a control character in ffmpeg filtergraphs, so you need to escape it in paths. Also use / instead of \ in paths.