Platform :

Popular Solution Go   Back

ASP.NET - How to convert M2TS video to FLV video in ASP.net

Step 1: Download Video Edit Mobile SDK ActiveX setup disk and installed it.

Step 2: Create New Web Site in Microsoft Visual Studio 2005.

Step 3: Input the project location and press OK button.

Step 4: In solution explorer, select the root directory, right click the mouse and Add Reference...

Step 5: Select COM tab, select VideoEdit Mobile ActiveX Control and press OK button.

Step 6: Add following code and change the strVideoFile variable point to correct path of your media file in Default.aspx.cs.

using VIDEOEDITLib;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        VIDEOEDITLib.VideoEdit obj = new VIDEOEDITLib.VideoEdit();
        obj.InitSingleServerLicense("demo");

        //please change correct path of your media file
        string strVideoFile = "c:\\movie\\yourvideo.m2ts";

        double iDur = obj.GetFileDuration(strVideoFile);

        if (iDur > 0)
        {
            obj.OutputType = (VIDEOEDITLib.MYOUTPUT)7;
            obj.OutputFileWidth = 320;
            obj.OutputFileHeight = 240;
            obj.FrameRate = 25;
            obj.OutputType = (VIDEOEDITLib.MYOUTPUT)4;
            obj.FLVAudioBitrate = 128000;
            obj.FLVAudioChannels = 2;
            obj.FLVAudioSampleRate = 44100;
            obj.FLVVideoBitrate = 512000;

            obj.VideoSampleSize = 24;
            obj.InitControl();
            obj.AddVideo(strVideoFile, 0, iDur, 0);
            obj.AddAudio(strVideoFile, 0, iDur);

            string strOutputFile = Server.MapPath("test1.flv");

            bool result = obj.Save(strOutputFile);

            if (result)
                Response.Write("Save to " strOutputFile " Completed");
            else
                Response.Write("Failed");

        }
        else
            Response.Write("Failed! " strVideoFile " file not found,  make sure the path of strVideoFile variable is correct.");


    }
}