Watermark upon transcoding

Is it possible to burn a watermark onto the video file upon transcoding?

I’ve configured the Kaltura flavors and removed the original (file) flavor. I’ve set the watermark on a player. It plays with watermark, but seems that the file is not burned with the watermark because I can still download the video (from my browser toolbar) without any watermark.

I’m looking to get the video branded upon upload rather than on streaming within the player.
What are the procedures to get this accomplished?

Hello,

There is a watermarkData field in the flavorParams (customData), it accepts following json string -

  • imageEntry - (optional),an image entry that will be used as a watermark image. Supported - PNG and JPG. Transparent alpha layer
    (PNG only) is supported.
  • url - (optional), external url for the watermark image file. Formats same as above. Either ‘imageEntry’ or ‘url’ must be provided
  • margins - (optional), ‘WxH’, distance from the video frame borders. Positive numbers refer to LeftUp corner, negative to
    RightDown corner of the video frame. If omitted - LeftUp is assumed. (Example - ‘-100x10’- 100pix from right side, 10 pixs from the
    upper side)
  • opacity - (optional) - 0-1.0 range. Defines the blending level between the watermark image and the video frame. if omitted the
    watermark is presented un-blended.
  • scale - (optional), ‘WxH’ - scale the water mark image to the given size. If one of the dimensions is omitted, it is calculated
    to preserve the watermark image aspect ratio.

Limitations:
The combination of transparent watermark with opacity does not work properly.

Sample watermark setup:
{“imageEntry”:“0_yn0vivhl”,“margins”:"-100x10",“opacity”:“0.5”,“scale”:“x250”}

To create your custom flavor param, you can use our API, for example:

Another option would be to use the Kaltura CLI clientlibs for this:
http://knowledge.kaltura.com/kaltura-cli-client

Hi Jess, thank you for your prompt response. Would I be able to connect with the API through the TestMe console? I was able to connect and start a session, but I received a SERVICE_FORBIDDEN error when trying to update (or add) a flavorParam:

The access to service [flavorParams->update] is forbidden

You can do it from the test me but note the partner ID you need is 0, not your own partner.
$userId = null;
$expiry = null;
$privileges = null;
// get with:
// mysql> select admin_secret from partner where id=0\G
$secret = $argv[1];
$type = KalturaSessionType::ADMIN;
$partnerId=0;
$service_url= $argv[2];
$client=generate_ks($service_url,$partnerId,$secret,$type=KalturaSessionType::ADMIN,$userId=null,$expiry = null,$privileges = null);

I was not able to update any of the existing flavors that come with core. I can select ‘list’ all flavors and see all results, but when using the ‘ID’ of any existing flavor with ‘update’ … then I get error, ID cannot be found.

However, I was able to successfully ‘add’ a new flavor, and ‘update’ the new flavor with watermark data using it’s ID. Not really sure why the existing flavors are locked up (even using 0 as partner) but in any case, I guess what I can do is replicate each one as a new flavor with watermark, if I’m not able to ‘update’ existing.

What was the error you got when trying to update an existing flavor?
Regardless, creating your own custom flavors rather than updating defaults actually feels better to me…

FYI the error:

<xml>
 <result>
  <error>
   <code>FLAVOR_PARAMS_ID_NOT_FOUND</code>
   <message>Flavor params id "2" not found</message>
   <objectType>KalturaAPIException</objectType>
   <args>
    <item>
     <objectType>KalturaApiExceptionArg</objectType>
     <name>ID</name>
     <value>2</value>
    </item>
   </args>
  </error>
 </result>
 <executionTime>0.013353824615479</executionTime>
</xml>

 <item><objectType>KalturaFlavorParams</objectType><relatedObjects/><id>2</id><partnerId>0</partnerId><name>Basic/Small - WEB/MBL (H264/400)</name>

Probably because I wasn’t able to connect with Partner ID 0, whereas the new flavor I added was with my own Partner ID. Well, at least this way the default flavors will stay in tact.

Awesome! Thank you for your help.

To get the secret for 0 you need:
mysql> select admin_secret,secret from kaltura.partner where id=0;

but as I said before, I do see added value in leaving the default flavor set intact:)

Hi Jess,

This method works great.

One problem is different sizes for different source resolution.

If I set scale of x100, when the source video is 1920x1080 the watermark comes out very small.
when the source video is 640x360 it comes out too big.

Is it possible to set the scale using percentage?

Thanks

Hello @benny_1,

Yes, it is possible:
‘x30%’ - scale to 30% of the source height. Calc the width to match the aspect ratio

All available options:

Watermark Data

  • imageEntry (optional, either 'imageEntry or ‘url’ must be provided)
    An image entry that will be used as a watermark image.
    Supported - PNG and JPG. Transparent alpha layer (PNG only) is supported.

  • url (optional, either 'imageEntry or ‘url’ must be provided)
    External url for the watermark image file.
    Formats same as above.

  • margins (optional)
    ‘WxH’, distance from the video frame borders.
    Positive numbers refer to LeftUp corner, negative to RightDown corner of the video frame.
    ‘center’ allowed to place the WM relatively to the center of the image. Offset allowed
    If omitted - LeftUp is assumed.
    Example -

    ‘-100x10’- 100pix from right side, 10 pixs from the upper side
    ’center-10xcenter+30’ - place the WM 10pix left to the middle and 30pix bellow the middle

  • opacity (optional)
    0-1.0 range. Defines the blending level between the watermark image and the video frame.
    If omitted the watermark is presented un-blended.

  • scale (optional)
    ‘WxH’ - scale the water mark image to the given size. If one of the dimensions is omitted,
    it is calculated to preserve the watermark image aspect ratio.
    ‘n%’ to scale to n% of the source size.
    Example
    ’x30%’ - scale to 30% of the source height. Calc the width to match the aspect ratio

  • fade (optional)
    Several fade in/outs are allowed
    – type - in/out, default ‘in’
    – start_time - in sec (flaot), default 0
    – alpha - If set to 1, fade only alpha channel, if one exists on the input. default 0
    – duration - in sec, default ~1sec.

Sample Json string -

  {"imageEntry":"0_abcd1234", "margins":"centerxcenter","scale":"0x100%",
  "fade":[{"type":"in","start_time":"0.3","alpha":"1","duration":"0.5"},
    {"type":"out","start_time":"10","alpha":"1","duration":"0.6"}]}

Hi

I have tried: “scale”:"x30%"
but it does not work.
The watermark was even smaller.

I use kaltura CE 10.2.0

Any ideas?

Thanks

Hi Jess,

Any ideas why does the n% does not work?

All it does is change the watermark size in percentage relative to the original size of the watermark image.

For example: if the original width of the image is 87px then when the scale is: 30%x0 the watermark width comes out 26px which is 30% of 87px…

Suggestions…?

I think I managed to scale with % in the new kaltura version.

Is it also possible to use % in margins?