jgh- / VideoCore-Inactive

*No longer in development* Please see https://github.com/unpause-live/SwiftVideo
MIT License
1.48k stars 540 forks source link

Watermark #108

Open t2wu opened 9 years ago

t2wu commented 9 years ago

Is there watermark support in this? It's listed in the Architecture overview, but I could not find the code.

jacobmoncur commented 9 years ago

VCSimpleSession has a method on it to add an image onto the stream:

- (void) addPixelBufferSource: (UIImage*) image withRect: (CGRect) rect; 

Worked like a charm for me.

t2wu commented 9 years ago

Wow thanks, I guess the sample project pull the old version of the code and it was not in there. Let me take a look. Do you think it would be hard to modify it so that instead of a static watermark, I can have animation printed on it?

jgh- commented 9 years ago

@t2wu the best way to do this right now would be to create your own source more or less based on the static image source and add it to a graph that you have control over (could be based on the VCSimpleSession graph, but with your custom sources added)

germanSancho commented 9 years ago

Hi guys,

I'm trying to add a static watermark but I'm having trouble to understand how the sizing works. I read the comment in addPixelBufferSource, but it's not very clear to me:

/*!
 *  Note that the rect you provide should be based on your video dimensions.  The origin
 *  of the image will be the center of the image (so if you put 0,0 as its position, it will
 *  basically end up with the bottom-right quadrant of the image hanging out at the top-left corner of
 *  your video)
 */
- (void) addPixelBufferSource: (UIImage*) image withRect: (CGRect) rect;

So imagine I have a video of 960x540 and I want to add a watermark image of 100x30 pixels at the top-left corner. What values should I use for the rect parameter?

Thanks!

jgh- commented 9 years ago

Hey German

What I mean by that is that the center of your image is the origin point, (0,0) represents the top-left of the video. So if you make the image's position (0,0) the center of the image will be aligned at the top-left of the video and most of the image will not be visible.

If you make the image's position (videoWidth/2, videoHeight/2) it will be centered in the video.

t2wu commented 9 years ago

Hi James, about adding my own source to create dynamic watermarks, any source whose output is set to m_videoMixer, and is registered by m_videoMixer will get mixed in? A source that is registered later in time overlays one registered previous in time?

I didn't seem to grasp this thing until I viewed the WWDC video on AVAudioEngine which also has term like "mixer" and it seems to clarity your code for me.

germanSancho commented 9 years ago

ok @jgh- , thanks for the tip!

omarojo commented 8 years ago

try with a squared watermark image. I believe the oroblem is the dimensions of your image. 

On Wed, Mar 23, 2016 at 1:59 AM -0700, "michalsenk" notifications@github.com wrote:

— You are receiving this because you commented. Reply to this email directly or view it on GitHub

haemi commented 8 years ago

is it possible to remove the watermark at a later point?

Jasonzn commented 7 years ago

@haemi Do you find the way to remove the watermark?

Thank you.