ByteScout SWF To Video SDK – ASP.NET – SWF To WEBM (VB.NET)

  • Home
  • /
  • Articles
  • /
  • ByteScout SWF To Video SDK – ASP.NET – SWF To WEBM (VB.NET)

ByteScout SWF To Video SDK – ASP.NET – SWF To WEBM (VB.NET)


' x64 IMPORTANT NOTE: set CPU to x86 to build in x86 mode

Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Drawing
Imports System.Diagnostics
Imports System.IO

Imports BytescoutSWFToVideo

Public Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Dim inputSwfFile As String = Server.MapPath("SlideShowWithEffects.swf")
        Dim outputVideoFile As String = Path.GetTempPath() & "result.WEBM"

        ' Create an instance of SWFToVideo ActiveX object
        Dim converter As New SWFToVideo()

        ' Set debug log

        ' Register SWFToVideo
        converter.RegistrationName = "demo"
        converter.RegistrationKey = "demo"

        ' Set input SWF file
        converter.InputSWFFileName = inputSwfFile

        ' you may calculate output video duration using information about the the source swf movie
        ' WARNING #1: this method to calculate the output video duration is not working for movies with dynamic scenes 
        ' and interactive scripts as in these movies it is not possible to calculate the precise duration of the movie 
        ' WARNING #2: you should set the input swf or flv filename (or url) before this calculation

        ' So the movie duration is calculated as the following:
        ' as swf frame count (number of frames in the swf) / movieFPS (frames per second defined in swf)
        ' and then multiplied by 1000 (as we are setting the .ConverstionTimeout in milliseconds)
        ' as the following (uncomment if you want to set the length of the output video to the same as the original swf)
        ' or as the following source code (uncomment to enable):

        ' converter.ConversionTimeout = 1000 * (converter.FrameCount / converter.MovieFPS)

        ' Set output video file
        converter.OutputVideoFileName = outputVideoFile

        ' Set output movie dimensions
        converter.OutputWidth = 640
        converter.OutputHeight = 480

        ' Run conversion

        ' release resources
        converter = Nothing

        ' Show filename of result file

        Response.ContentType = "text/html"

        Response.Write("Output file:  <b>" & outputVideoFile & "</b>")


    End Sub
End Class


<?xml version="1.0"?>

            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
        <compilation debug="true" />
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        <authentication mode="Windows" />
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />


To use SWF To Video SDK on Web Server you may need to do the following adjustments to the server.

Confirmed: SDK works on virtual Windows 2003, 2008, 2012 servers with these adjustments.

1) Windows Server 2003 or later: 
If you are using WMV format then install Windows Media Player from "Desktop Experience"

2) Update flash player for Internet Explorer to the latest version. To update do the following
 - run Internet Explorer
 - open
 - click on Update Flash Player
 - follow the instruction and install the latest flash player plugin for Internet Explorer
NOTE: on x64 Windows you should run Internet Explorer for x86 (not x64 version)

3) To convert interactive flash movies you should enable "allow interact with desktop" option

IMPORTANT: this may cause security breaches so pleaase be careful!

Recommended way:
- create new IIS user 
- use it to run web application to convert swf to video only
- set it to x86 mode only
- set it to "allow desktop interaction"

4) For Windows 2008, 2012 or later: 

If you are on Windows Server 2008 or higher and you have set "allow desktop interaction" already but still having the issue please try the following solution as suggested by Microsoft specialists:

Windows Server 2008, 2012 no longer allows interactive services, by default, which makes the Interactive Services Detection service unnecessary.

if you must run a the application that installs an interactive service on Windows Server 2012, you may sacrifice server stability for compatibility by changing the following registry value from the default of "1" into "0":
"NoInteractiveServices" in "HKLM\SYSTEM\CurrentControlSet\Control\Windows"

After doing so and rebooting, the Interactive Services Detection Service will start.

5) for x64 windows: you should set IIS to run your web application in x86 mode
6) for x64 Windows: you should compile your ASP.NET web application for x86 platform instead of AnyCPU

1) Flash movie with dynamic XML data shows "Can not load XML data". 
Solution: To check this issue try to run Internet Explorer on the server machine and open that flash movie (or URL to flash movie in Internet Explorer)

2) if you suspect the issue is caused by flash movie not properly running you may need to run it in Flash Player Debug version 
Solution: You should download "Windows Flash Player 11.7 ActiveX control content debugger (for IE)" from this page
Install, follow the instruction and try to open that flash movie in Internet Explorer again and flash player will display debug error messages from flash if needed

3) If your flash movie is designed to run on machines with sound card then you may experience issues related to the lack of audio devices.
Solution: if you are able to recompile flash movie then add the additional check for sound devices presented/installed

4) If your XML or external is loaded from different domain/subdomain then data can be restricted by cross-domain policies in the latest flash versions
Solution: make and upload cross-domain policy domain XML file to the domain(s) with the source data 

5) if you are getting 503 error while converting to video then try to increase the default timeout for the conversion page like this:

If you are converting as the response to the click then try to increase the request timeout for this request by modifying the execution timeout in the config file like this:

<location path="somefile.aspx">
<httpRuntime executionTimeout="180"/>

Updated June 10, 2015


Interact with desktop permission may be required to run Screen Capturing SDK or SWF To Video SDK from service or to convert interactive ("live") flash movies with SWF To Video SDK

You may set this "Allow to interact with desktop" checkbox for the user that is used to run the service/app 
For IIS apps this user name is typically IIS_... user name

Important note for Windows Server 2008 or later

Newest Windows has disabled interactive services 

New Windows versions are no longer allowing to run interactive services by default to prevent services from accessing the desktop (to provide more security)

If you must run a Screen Capturing SDK or SWF To Video SDK from an interactive service then you may sacrifice server stability for compatibility by changing the following registry value from the default of "1" to "0".


Then reboot so Windows will pick the new value from the registry and the Interactive Services Detection Service will start.

To make this change manually please do the following 

Start the registry editor (regedit.exe) in As Administrator mode
Locate the following Registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows on the left side
double-click the NoInteractiveServices entry on the right side and change its value from 1 to 0
Then click OK and close the registry editor
Restart the computer