adding custom watermark on video stream?

Discussion in 'General Discussion' started by Homer, Sep 1, 2017.

  1. Homer

    Homer New Member

    hi ,
    Is it possible to add custom watermark on the video stream? Just like the one on the demo site player where it will show on every interval.

  2. Max

    Max Administrator Staff Member


    You can try to set
    and place mylogo.png file in WCS_HOME/conf directory.
    The mylogo.png file should be 640x480

    The watermark will not be displayed without transcoding.
    1. You have to force video transcoding, setting particular playback resolution.
    session.createStream({name:"stream1", constraints:{video:{width:640,height:480}}}).play();
    2. The transcoder may take about 1 core CPU per publishing stream.
    So if you have 16 publishing streams, 16 cores will be utilized for transcoding.
  3. Homer

    Homer New Member

    Hi again,
    Sounds like the watermark will appear on all transcoded streams. Possible to control and display only on specific streamId ? :D
  4. Max

    Max Administrator Staff Member

    Yes it is possible.
    You can intercept a transcoded stream by stream name and add watermark to your transcoded stream.
    This can be done on server-side.
    1. Create Java class.
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    public class MyDecodedFrameInterceptor implements IDecodedFrameInterceptor {
        //create one global logger
        private static final Logger log = LoggerFactory.getLogger("MyDecodedFrameInterceptor");
        public void frameDecoded(String streamName, YUVFrame frame) {"Got frame " + frame);
        //draw 100x100 rectangle in the center
        int rectSide = 100;
        byte[] greenPixel = new byte[]{0x00, 0x00, 0x00};
        if (frame.getWidth() > rectSide && frame.getHeight() > rectSide) {
            int x = frame.getWidth()/2 - rectSide/2;
            int y = frame.getHeight()/2 - rectSide/2;
            int xLimit = x + rectSide;
            int yLimit = y + rectSide;
  "Draw rect x:" + x + "-" + xLimit + " y:" + y + "-" + yLimit);
            for (; x < xLimit; x++) {
            for (int y2 = y; y2 < yLimit; y2++) {
                frame.writePixel(x, y2, greenPixel);
    and compile this class to .jar file using Flashphoner libs:
    javac -classpath .:tbs-flashphoner.jar:slf4j-api-1.6.4.jar -d .
    jar cf frame-interceptor.jar com
    2. Add to

    As you can see, we can draw green square on video frame using code above. It is bit complex, but it is the one way to insert custom watermark for particular stream, for now.

    Attached Files:

Share This Page