Custom variables as watermark on WordPress videos

Please visit Add Text to Videos with Watermark for a detailed introduction to adding watermark to your videos. This particular blog explains what is going on under the hood of the WP plugin, and is useful only if you are adding your own custom-built variables as part of watermark. Currently name, IP and email can be shown as part of watermark.

Watermark on videos adds extra security for the video from screen capture by adding variables such as email, IP or date information to the videos. Custom variables is now supported in plugin 1.6

Default WordPress fields that can be added

Our plugin has been configured to replace the following strings in the annotation code by default:

  • {name} – Current User display name
  • {email} – Current User email
  • {username} – Current User Login
  • {id} – Current User ID

Till version 1.5 of our WordPress plugin, watermark on videos could only have a limited number of dynamic variables. With version 1.6, we have now added filter hooks on the annotation code to enable other plugins or themes to change the annotation code.

You can now add a custom filter to the hook `vdocipher_annotate_preprocess` . Example code for adding custom filter is:

function customfunc($vdo_annotate_code){
 $customVariable = "Hello world";
 $vdo_annotate_code = str_replace('{var1}', $customVariable, $vdo_annotate_code);
 return $vdo_annotate_code;

add_filter('vdocipher_annotate_preprocess', 'customfunc');

The above code enables you to replace the token {var1} with the value of $customVariable. You can then use an annotation code like:

{'type':'rtext', 'text':'Your IP : {ip}', 'alpha':'0.8', 'color':'0xFF0000','size':'12','interval':'5000'},
{'type':'text', 'text':'{var1}', 'alpha':'0.5' , 'x':'150', 'y':'100', 'color':'0xFF0000', 'size':'12'}

This code on going through the above filter will become

{'type':'rtext', 'text':'Your IP : {ip}', 'alpha':'0.8', 'color':'0xFF0000','size':'12','interval':'5000'},
{'type':'text', 'text':'Hello world', 'alpha':'0.5' , 'x':'150', 'y':'100', 'color':'0xFF0000', 'size':'12'}

This function can be placed in the functions.php file in your theme. It is recommended to create a child theme before making such edits.

Display User Fullname

An example code to display fullname is as follows:

function customvdofunc($vdo_annotate_code){
    $fullname = "";
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $firstname = $current_user->user_firstname;
        $lastname = $current_user->user_lastname;
        $fullname = $firstname . " " . $lastname;
     $vdo_annotate_code = str_replace('{fullname}', $fullname, $vdo_annotate_code);
     return $vdo_annotate_code;
add_filter('vdocipher_annotate_preprocess', 'customvdofunc');

This would replace the string ‘{fullname}’ in the watermark code to the fullname of the logged in user.

Adding video specific watermark

With this tool, you can also set custom variables for different video or wire up your own logic using any WordPress parameters.

You may also like...