ByteScout SWF To Video SDK - C# - SWF to WMV with Live Preview - ByteScout

ByteScout SWF To Video SDK – C# – SWF to WMV with Live Preview

  • Home
  • /
  • Articles
  • /
  • ByteScout SWF To Video SDK – C# – SWF to WMV with Live Preview

SWF to WMV with live preview in C# using ByteScout SWF To Video SDK

Write code in C# to make SWF to WMV with live preview with this How-To tutorial

Today we will explain the steps and algorithm of implementing SWF to WMV with live preview and how to make it work in your application. ByteScout SWF To Video SDK was made to help with SWF to WMV with live preview in C#. ByteScout SWF To Video SDK is the SDK that is capable of converting SWF macromedia files into WMV and AVI video. Supports dynamic flash movies, can transmit variable values. Options to change output video size, framerate, quality are available.

This rich sample source code in C# for ByteScout SWF To Video SDK includes the number of functions and options you should do calling the API to implement SWF to WMV with live preview. In order to implement this functionality, you should copy and paste code below into your app using code editor. Then compile and run your application. C# application implementation typically includes multiple stages of the software development so even if the functionality works please test it with your data and the production environment.

Trial version can be downloaded from our website. Source code samples for C# and documentation are included.

Try ByteScout SWF To Video SDK today: Get 60 Day Free Trial or sign up for Web API

namespace PreviewContext { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.buttonConvert = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // buttonConvert // this.buttonConvert.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.buttonConvert.Location = new System.Drawing.Point(18, 227); this.buttonConvert.Name = "buttonConvert"; this.buttonConvert.Size = new System.Drawing.Size(254, 23); this.buttonConvert.TabIndex = 0; this.buttonConvert.Text = "Convert test.swf with conversion preview"; this.buttonConvert.UseVisualStyleBackColor = true; this.buttonConvert.Click += new System.EventHandler(this.buttonConvert_Click); // // pictureBox1 // this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.pictureBox1.Location = new System.Drawing.Point(18, 31); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(254, 180); this.pictureBox1.TabIndex = 1; this.pictureBox1.TabStop = false; // // label1 // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.label1.Location = new System.Drawing.Point(15, 9); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(122, 13); this.label1.TabIndex = 2; this.label1.Text = "Conversion preview:"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 262); this.Controls.Add(this.label1); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.buttonConvert); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form1"; this.Shown += new System.EventHandler(this.Form1_Shown); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button buttonConvert; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Label label1; } }

Try ByteScout SWF To Video SDK today: 60 Day Free Trial (on-premise version) or sign up for Web API (on demand version)

using System; using System.Drawing; using System.Windows.Forms; using BytescoutSWFToVideo; namespace PreviewContext { public partial class Form1 : Form { Graphics m_g; IntPtr m_hdc; SWFToVideoClass swf = new SWFToVideoClass(); public Form1() { InitializeComponent(); } private void buttonConvert_Click(object sender, EventArgs e) { if (!swf.IsRunning) { swf.SWFConversionMode = SWFConversionModeType.SWFWithLiveData; swf.ConversionTimeOut = 15000; swf.InputSWFFileName = "test.swf"; // 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): // swf.ConversionTimeout = 1000 * (swf.FrameCount / swf.MovieFPS) swf.OutputVideoFileName = "test.wmv"; swf.OutputWidth = 640; swf.OutputHeight = 480; swf.SetPreviewContext(m_hdc.ToInt32(), 0, 0, pictureBox1.Width, pictureBox1.Height, 30); swf.Run(); } } private void Form1_Shown(object sender, EventArgs e) { m_g = pictureBox1.CreateGraphics(); m_hdc = m_g.GetHdc(); } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { m_g.ReleaseHdc(m_hdc); m_g.Dispose(); // release resources System.Runtime.InteropServices.Marshal.ReleaseComObject(swf); swf = null; } } }

Try ByteScout SWF To Video SDK today: 60 Day Free Trial (on-premise version) or sign up for Web API (on demand version)

// x64 IMPORTANT NOTE: set CPU to x86 to build in x86 mode. WHY? Because flash is not supported on x64 platform currently at all using System; using System.Collections.Generic; using System.Windows.Forms; namespace PreviewContext { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }

Try ByteScout SWF To Video SDK today: 60 Day Free Trial (on-premise version) or sign up for Web API (on demand version)



Get 60 Day Free Trial or Visit ByteScout SWF To Video SDK page

Explore ByteScout SWF To Video SDK documentation


Sign Up for free Web API key

Explore Web API Documentation