Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watermark #51

Open
vinnitu opened this issue Sep 16, 2020 · 3 comments
Open

watermark #51

vinnitu opened this issue Sep 16, 2020 · 3 comments

Comments

@vinnitu
Copy link

vinnitu commented Sep 16, 2020

Hi All!

I want to add watermak (really other type of processing) on each frame end encode to same codec and container.

Is it possible with beamcoder? Maybe somebody have an example?

Thanks!

@jpietek
Copy link

jpietek commented Oct 1, 2020

Works exactly as in plain libav/ffmpeg:
https://ffmpeg.org/ffmpeg-all.html#overlay-1

@vinnitu
Copy link
Author

vinnitu commented Oct 1, 2020

yes... but if I want draw something on frame?

@Rock-N-Troll
Copy link

Rock-N-Troll commented Nov 28, 2020

if you get each frame and change the pixel colors in the right spots and loop over and perform the action for all frames, you can do it (depending on colorspace. example below is for rgb pixels in a frame)

https://github.com/Streampunk/beamcoder#creating-frames
There can also be an alpha channel so just depends on the format (rgb, yuv, etc.). It will take some trial and error

pseudocode:

let frame = beamcoder.frame({
	      width: encParams.width,
	      height: encParams.height,
	      format: encParams.pix_fmt
	    }).alloc();// or whatever frame data you have, in a loop

	    let [ rgbdata ] = frame.data;//existing pixel values

	    rgbPixelCount = 3 * width* height; //3 values (r, g, and b) for every pixel of the frame from 0-255, so 0,1,2 are the 1st pixel rgb values

	    rgbdata[pixelToChange*3] = 0; //set r value
	    rgbdata[pixelToChange*3+1] = 0;//set g value
	    rgbdata[pixelToChange*3+2] = 0;//set b value

additional resource with similar approach:
#19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants