Automated Streaming Video
by Jacob Gsoedl

Listing One
<SCRIPT LANGUAGE="VBScript"> 
Sub Select_OnClick 
  UploadCtl.Select 
End Sub 
Sub Remove_OnClick 
  UploadCtl.RemoveHighlighted 
End Sub 
Sub Upload_OnClick
  UploadCtl.Upload 
End Sub 
Sub goUpload
    timerID = setTimeOut("UploadCtl.Upload",100)
    UploadCtl.Select 
End Sub

</SCRIPT> 
<HTML>
<HEAD>
<TITLE>Upload and Encode your Video Files</TITLE>
</HEAD>
<BODY bgcolor="White" Language="vbscript" OnLoad="goUpload">
<table width="400" border="1" cellspacing="0" cellpadding="10">
<tr bgcolor="#eeeeee"><td align="center">
<h2><font color="Black">Upload and Encode your Video Files</font></h2>
<FORM NAME="frmInfo">
<table border="1">
<tr bgcolor="Black"><td>
    <table>
    <tr>
    <td width="120"  align="center"><b><font color="White">Size</font></b></td>
    <td width="100" align="right"><b><font color="White">Bitrate</font></b></td>
    </tr>
	</table>
</td></tr>
<tr bgcolor="White"><td>
    <table>
    <tr><td width="120" align="center">160x120</td>
    <td align="right" width="100">
	    28.8 kbps<br>
	    56 kbps<br>
	    100 kbps
    </td>
	<td align="left" width="80">
	   &nbsp;<input type="checkbox" name="160x120x28"><br>
	   &nbsp;<input type="checkbox" name="160x120x56"><br>
	   &nbsp;<input type="checkbox" name="160x120x100"><br>
	</td>
    </tr>
    </table>
</td></tr>

<tr bgcolor="White"><td>
    <table>
    <tr><td width="120" align="center">240x180</td>
    <td align="right" width="100">
	    56 kbps<br>
		100 kbps<br>
		256 kbps
    </td>
    <td align="left" width="80">
	   &nbsp;<input type="checkbox" name="240x180x56"><br>
	   &nbsp;<input type="checkbox" name="240x180x100"><br>
	   &nbsp;<input type="checkbox" name="240x180x256">
	</td>
    </tr>
    </table>
</td></tr>

<tr bgcolor="White"><td>
    <table>
    <tr><td width="120" align="center">320x240</td>
    <td align="right" width="100">
	     56 kbps<br> 
	    100 kbps<br>
	    256 kbps
    </td>
	<td align="left" width="80">
	   &nbsp;<input type="checkbox" name="320x240x56"><br>
	   &nbsp;<input type="checkbox" name="320x240x100"><br>
	   &nbsp;<input type="checkbox" name="320x240x256">
	</td>
    </tr>
    </table>
</td></tr>

<tr bgcolor="White"><td>
    <table>
    <tr><td width="120" align="Right">Windows Media</td>
        <td align="Left">&nbsp;<input type="checkbox" name="WindowsMedia">
    </td>
	</tr>
    <tr><td width="120" align="Right">Real Video</td>
        <td align="Left">&nbsp;<input type="checkbox" name="RealVideo">
    </td>
	</tr>
    </table>
</td></tr>
</table>
<br>
   <font color="6666FF"><b>Short Description:</b></font><br>
   <input type=text id="sDescription" name="sDescription" size="60" value=""><br>
</FORM>
<OBJECT WIDTH=500 HEIGHT=50
	ID="UploadCtl" 
	CLASSID="CLSID:E87F6C8E-16C0-11D3-BEF7-009027438003"
	CODEBASE="XUpload.ocx">
<PARAM NAME="Server" VALUE="www.mystudionline.com">
<PARAM NAME="Script" VALUE="/qa/VidUploadSubmit.asp">
<PARAM NAME="ViewServerReply" VALUE="False">
<PARAM NAME="EnablePopupMenu" VALUE="False"> 
<PARAM NAME="ShowProgress" VALUE="True">
<PARAM NAME="MaxFileCount" VALUE="1">
<PARAM NAME="Redirect" VALUE="True"> 
<PARAM NAME="RedirectURL" VALUE="VidUpload.asp"> 
<PARAM NAME="HtmlForm" VALUE="frmInfo">
<% If strFileName <> "" Then %>
<PARAM NAME="File1" VALUE="<%=strFileName%>"> 
<% End If %>
</OBJECT>
<P> 
<INPUT TYPE=BUTTON NAME="SELECT" VALUE="Browse">&nbsp;&nbsp;
<INPUT TYPE=BUTTON NAME="REMOVE" VALUE="Remove">&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=BUTTON NAME="UPLOAD" VALUE="Upload"> 
</td></tr>
</table>
</BODY>
</HTML>


Listing Two:
<%@ Language=VBScript %>
<!--#include file="adovbs.inc"-->
<% 
Dim viMemberID, vCount, vFileName, sFileDesc, sFileSize, oConn, strSQL, rsVideo

'For this sample page, we set the Member ID to 1.
viMemberID = 1

'Determines the value of Set160x120Profile
'------------------------------------------
Function Set160x120Profile(s160x120x28, s160x120x56, s160x120x100)
   Set160x120Profile = ""
   If (s160x120x28="on") AND NOT (s160x120x56="on") AND NOT (s160x120x100="on") Then
      Set160x120Profile = "160x120x28"
	  Exit Function
   End If
   If NOT (s160x120x28="on") AND (s160x120x56="on") AND NOT (s160x120x100="on") Then
      Set160x120Profile = "160x120x56"
	  Exit Function
   End If
   If NOT (s160x120x28="on") AND NOT (s160x120x56="on") AND (s160x120x100="on") Then
      Set160x120Profile = "160x120x100"
	  Exit Function
   End If
   If (s160x120x28="on") AND (s160x120x56="on") AND NOT (s160x120x100="on") Then
      Set160x120Profile = "160x120x28_56"
	  Exit Function
   End If
   If (s160x120x28="on") AND NOT (s160x120x56="on") AND (s160x120x100="on") Then
      Set160x120Profile = "160x120x28_100"
	  Exit Function
   End If
   If NOT (s160x120x28="on") AND (s160x120x56="on") AND (s160x120x100="on") Then
      Set160x120Profile = "160x120x56_100"
	  Exit Function
   End If
   If (s160x120x28="on") AND (s160x120x56="on") AND (s160x120x100="on") Then
      Set160x120Profile = "160x120x28_56_100"
	  Exit Function
   End If
End Function

'Determines the value of Set240x180Profile
'------------------------------------------
Function Set240x180Profile(s240x180x56, s240x180x100,s240x180x256)
   Set240x180Profile = ""
   If (s240x180x56="on") AND NOT (s240x180x100="on") AND NOT (s240x180x256="on") Then
      Set240x180Profile = "240x180x56"
	  Exit Function
   End If
   If NOT (s240x180x56="on") AND (s240x180x100="on") AND NOT (s240x180x256="on") Then
      Set240x180Profile = "240x180x100"
	  Exit Function
   End If
   If NOT (s240x180x56="on") AND NOT (s240x180x100="on") AND (s240x180x256="on") Then
      Set240x180Profile = "240x180x256"
	  Exit Function
   End If
   If  (s240x180x56="on") AND (s240x180x100="on") AND NOT (s240x180x256="on") Then
      Set240x180Profile = "240x180x56_100"
	  Exit Function
   End If
   If  (s240x180x56="on") AND NOT (s240x180x100="on") AND (s240x180x256="on") Then
      Set240x180Profile = "240x180x56_256"
	  Exit Function
   End If
   If  NOT (s240x180x56="on") AND (s240x180x100="on") AND (s240x180x256="on") Then
      Set240x180Profile = "240x180x100_256"
	  Exit Function
   End If
   If  (s240x180x56="on") AND (s240x180x100="on") AND (s240x180x25="on") Then
      Set240x180Profile = "240x180x56_100_256"
	  Exit Function
   End If 
End Function

'Determines the value of Set320x240Profile
'------------------------------------------
Function Set320x240Profile(s320x240x56, s320x240x100, s320x240x256)
   Set320x240Profile = ""
   If (s320x240x56="on") AND NOT (s320x240x100="on") AND NOT (s320x240x256="on") Then
      Set320x240Profile = "320x240x56"
	  Exit Function
   End If
   If NOT (s320x240x56="on") AND (s320x240x100="on") AND NOT (s320x240x256="on") Then
      Set320x240Profile = "320x240x100"
	  Exit Function
   End If
   If NOT (s320x240x56="on") AND NOT (s320x240x100="on") AND (s320x240x256="on") Then
      Set320x240Profile = "320x240x256"
	  Exit Function
   End If
   If (s320x240x56="on") AND (s320x240x100="on") AND NOT (s320x240x256="on") Then
      Set320x240Profile = "320x240x56_100"
	  Exit Function
   End If
    If (s320x240x56="on") AND NOT (s320x240x100="on") AND (s320x240x256="on") Then
      Set320x240Profile = "320x240x56_256"
	  Exit Function
   End If  
   If NOT (s320x240x56="on") AND (s320x240x100="on") AND (s320x240x256="on") Then
      Set320x240Profile = "320x240x100_256"
	  Exit Function
   End If  
   If (s320x240x56="on") AND (s320x240x100="on") AND (s320x240x256="on") Then
      Set320x240Profile = "320x240x56_100_256"
	  Exit Function
   End If 
End Function

'Determines the requested Streaming Video formats:
'  1: WindowsMedia Only
'  2: RealVideo Only
'  3: Both WindowsMedia and RealVideo
'-------------------------------------------------
Function SetFormat(sWindowsMedia, sRealVideo)
   SetFormat = 3
   If (sWindowsMedia="on") AND NOT (sRealVideo="on") Then
      SetFormat = 1
	  Exit Function
   End If
   If NOT (sWindowsMedia="on") AND (sRealVideo="on") Then
      SetFormat = 2
	  Exit Function
   End If
   If (sWindowsMedia="on") AND (sRealVideo="on") Then
      SetFormat = 3
	  Exit Function
   End If
End Function

'Set script timeout to 3000 seconds
Server.ScriptTimeout = 3000

'ASPUpload code
'---------------
Set vUpload = Server.CreateObject("Persits.Upload.1")
vUpload.OverwriteFiles = False    ' Generate unique filenames
vUpload.SetMaxSize 10040000, True ' Reject files above 10 Megabyte
vCount = vUpload.Save( Application("UploadPath") )
For each file in vUpload.Files
	vFileName = File.ExtractFileName
	sFileSize = File.Size
Next
sFileDesc = vUpload.Form("sDescription")

'Determine requested Streaming Video file formats
'------------------------------------------------
s160x120 = Set160x120Profile(vUpload.Form("160x120x28"),vUpload.Form("160x120x56"),vUpload.Form("160x120x100"))
s240x180 = Set240x180Profile(vUpload.Form("240x180x56"),vUpload.Form("240x180x100"),vUpload.Form("240x180x256"))
s320x240 = Set320x240Profile(vUpload.Form("320x240x56"),vUpload.Form("320x240x100"),vUpload.Form("320x240x256"))
sFormat  = SetFormat(vUpload.Form("WindowsMedia"),vUpload.Form("RealVideo"))
	
'Update tblVideo
'---------------
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open(application("CONNECTIONSTRING"))
strSQL = "select * from tblVideo Where ID = -1"
Set rsVideo = oConn.execute(strSQL)
rsVideo.AddNew
rsVideo("FileName") = cstr(vFileName)
rsVideo("Description") = cstr(sFileDesc)
rsVideo("FileSize") = sFileSize
rsVideo("MemberID") = viMemberID
rsVideo("[160x120]") = s160x120
rsVideo("[240x180]") = s240x180
rsVideo("[320x240]") = s320x240
rsVideo("Format") = sFormat
rsVideo("EncodingStatus") = 0
rsVideo("Active") = 0
rsVideo.Update
rsVideo.Close
Set rsVideo = Nothing	
oConn.Close
Set oConn = Nothing
Set vUpload = Nothing
%> 







1


