0

I am using ffmpeg-python library to process video, specifically I had to add watermark to video. Code is very simple:

def set_watermark_to_video(
    video_url: str,
    directory: str,
    filename: str,
    extension: str,
):
    video_input = ffmpeg.input(video_url)
    output_path: str = f"/tmp/{filename}_watermarked.mp4"
    logo_input = ffmpeg.input(vid_mycar_logo_path)
    video_probe = ffmpeg.probe(video_url)
    video_stream = next(
        (
            stream
            for stream in video_probe["streams"]
            if stream["codec_type"] == "video"
        ),
        None,
    )

    logo_probe = ffmpeg.probe("my_logo_path")
    logo_stream = next(
        (stream for stream in logo_probe["streams"] if stream["codec_type"] == "video"),
        None,
    )
    ffmpeg.filter(
        [video_input, logo_input],
        "overlay",
        10,
        video_stream["height"] - logo_stream["height"] - 10,
    ).output(output_path).run(overwrite_output=True)

Exception occurs when .run(overwrite_output=True) function is called.
Exception looks like this: ffmpeg._run.Error: ffmpeg error (see stderr output for detail).

When I print exc.stderr the only warning I can see is "Unknown cover type: 0x1."

But this code works perfectly when I run it locally. I am using docker to build my service, so dependencies, versions, etc all the same in both environments.

The version of ffmpeg I'm using is 5.1.4-0+deb12u1

I tried to run code line by line in server and local machine to compare all parameters and values that have been generated. And still they are the same, so I don't understand why this error happens in server

2
  • Can the server properly reach video_url? You can try downloading the file separately and then passing a local path instead of an URL to ffmpeg. Commented Dec 27, 2023 at 13:06
  • video_probe = ffmpeg.probe(video_url) function doesn't fail, it would fail if file was unreachable or unreadable @Taavi Commented Dec 27, 2023 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.