Solved

Video Overlay

Posted on 2011-02-13
1
959 Views
Last Modified: 2012-05-11
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.Width, 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






 
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

Open in new window

0
Comment
Question by:TheWebGuy38
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
TomasP earned 500 total points
ID: 35353498
What comes back from the new point call isn't an integer needed for the rectangle api but a point object. It seems you want the rectangle in the upper left so just putting a zero in as the argument should work
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question