Automated Streaming Video
by Jacob Gsoedl
Listing One
Upload and Encode your Video Files
Listing Two:
<%@ Language=VBScript %>
<%
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