add watermark to video and image with input and output array bytes

166 Views Asked by At

I'm trying to add watermark to images and videos using ffmpeg. My files are stored on AWS S3, so they are byte arrays ([]byte).

I need my input and output to be in a byte array and not saved to disk.

I tried something like the code and it didn't work:

    buffFile := bytes.NewBuffer(file)
    out := &bytes.Buffer{}
    overlay := ffmpeg.Input("pipe:", ffmpeg.KwArgs{}).Filter("scale", ffmpeg.Args{"64:-1"}).WithInput(buffWatermark)
    err = ffmpeg.Filter(
        []*ffmpeg.Stream{
            ffmpeg.Input("pipe:", ffmpeg.KwArgs{}).WithInput(buffFile),
            overlay,
        }, "overlay", ffmpeg.Args{"10:10"}, ffmpeg.KwArgs{"enable": "gte(t,1)"}).
        Output("pipe:", ffmpeg.KwArgs{}).WithOutput(out).OverWriteOutput().ErrorToStdOut().Run()
0

There are 0 best solutions below