I am using 3 types of video which have the following hight and width.
1)480 x 854
2)1080 x 1920.
3)270 x 480
We are using the following code for the watermark filter.
private Task CreateTextFilter()
{
var textFilter = new TextFilter()
{
Text = Constants.watermarkString,
X = Convert.ToString(Constants.X),
Y = Convert.ToString(Constants.Y)
};
textFilter.FontColor = “white”;
textFilter.FontSize = 18;
textFilter.Font = TextFilterFont.ROBOTO;
return _bitmovinApi.Encoding.Filters.Text.CreateAsync(textFilter);
}
I am getting the X and Y Positions by below method.
public static void GetOverlayPosition(int curWidth, int curHeight)
{
var yPercent = 0.02; // Same for all
var xPercent = 0.0;
var imagePercent = 0.0;
// These values are derived by trial and error to get the image to display on right top of the video
switch (curWidth)
{
case 3840:
xPercent = 0.80;
imagePercent = 0.5;
break;
case 1920:
xPercent = 0.80;
imagePercent = 0.5;
break;
case 1280:
xPercent = 0.77;
imagePercent = 0.4;
break;
case 960:
case 854:
xPercent = 0.77;
imagePercent = 0.3;
break;
case 640:
xPercent = 0.77;
imagePercent = 0.2;
break;
case 360:
xPercent = 0.60;
imagePercent = 0.15;
break;
}
// image placement position calculation:
var x = $"{Math.Round(xPercent * curWidth)}";
var y = $"{Math.Round(yPercent * curHeight)}";
Constants.X = Convert.ToInt32(x) - 28;
Constants.Y = Convert.ToInt32(y);
// image width and height calculation: Actual image resolution: 610x75
// Need reduction in this for displaying this in different resolutions, decrease by a certain percentage:
var imageWidth = $"{Math.Round(610 * imagePercent)}"; // videoWidth 854, 960: 183, 1280: 244, 1920: 354, 640: 122, 360: 91.5
var imageHeight = $"{Math.Round(75 * imagePercent)}"; // videoHeight 854, 960: 22.5, 1280: 30, 1920: 37.5, 640: 15, 360: 11.25
// var overlayPosition = new Rectangle() { Left = x, Top = y, Width = imageWidth, Height = imageHeight };
// return overlayPosition;
}
WaterMark Posotions and Font is different for different resolutions.
-
- 480 x 854
2)1080 x 1920.
Here font becomes very small
- 270 x 480
Here complete position has changed its coming Top Right instead of Top Left.
Urgent reply will be appreciated as this is production issue