TheWebGuy38
asked on
Video Overlay
Im messing around with some code I found online.
what it does is play a video file, and creates an overlay image when the video loads and plays it with the overlay.
Couldn't figure out a couple of things.
ist, the video player doesn't seem to be loading.
2nd, having an error thrown on this line:
MediaItem.OverlayRect = New Rectangle(New Point(30, 10), New Size(MediaItem.VideoSize.W idth, 30), MediaItem.VideoSize.Height , 10)
getting an error system.drawing.point cannot be converted to integer
This is a download link to the code
http://www.sendspace.com/file/eyil48
what it does is play a video file, and creates an overlay image when the video loads and plays it with the overlay.
Couldn't figure out a couple of things.
ist, the video player doesn't seem to be loading.
2nd, having an error thrown on this line:
MediaItem.OverlayRect = New Rectangle(New Point(30, 10), New Size(MediaItem.VideoSize.W
getting an error system.drawing.point cannot be converted to integer
This is a download link to the code
http://www.sendspace.com/file/eyil48
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Microsoft.Expression.Encoder
'Imports System.Windows.Media
Imports System.Drawing
Imports System.Drawing.Imaging
Partial Class VideoOverlayVB
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Dim Point As Point
' sets file name to media item
Dim MediaItem As New MediaItem(Server.MapPath("Users/Testuser/Video/Fishies2.wmv"))
' create the overlay image and return the path
Dim overlayFileName As String = createOverlayImage("Thank you for encoding this video!", Environment.CurrentDirectory, MediaItem.VideoSize.Width, MediaItem.VideoSize.Height)
' create the overlay on the media item
MediaItem.OverlayFileName = overlayFileName
MediaItem.OverlayLayoutMode = OverlayLayoutMode.WholeSequence
MediaItem.OverlayRect = New Rectangle(New Point(30, 10), New Size(MediaItem.VideoSize.Width, 30), MediaItem.VideoSize.Height, 10)
End Sub
Function createOverlayImage(ByVal overlayText As String, ByVal rootPath As String, ByVal width As Integer, ByVal height As Integer) As String
' full path for a temporary bitmap
Dim overlayFileName As String = (Server.MapPath("temp/" + (Guid.NewGuid.ToString + ".bmp")))
'Dim overlayFileName As String = (rootPath + ("\\" + (Guid.NewGuid.ToString + ".bmp")))
'Response.write("sd" & overlayFileName)
'Response.end()
' create a bitmap
Dim bitmap As Bitmap = New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(bitmap)
' define the font
Dim font As Font = New Font("Arial", CType(14, Single))
' define the area to draw on
Dim area As Rectangle = New Rectangle(New Point(0, 0), New Size(width, height))
' draw the new image
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias
g.DrawString(overlayText, font, Brushes.Red, area)
' save the picture with the text overlay
bitmap.Save(overlayFileName)
' return the path to the overlay image
Return overlayFileName
End Function
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.