This article explains, for .Net programmers, how to convert video formats (for example Flv, MKV, Mp4, and the format of the other). In addition, I will also include code snippets.So let us start with a basic introduction.In this article I will explain to you how can use FFMPEG exe for converting video file from one format to another can also convert any audio file from one format to another format.

In this post, I will also provide you with an FFMPEG command for html5 supportive mp4 video.
Now I have added a website and one .aspx page on the website and also added a folder Video.

I have Downloaded FFMPEG exe from the internet and placed this in the video folder and also added an mkv video in this folder.Now I want to convert this MKV video into mp4.


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Converter : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

        ConvertVideoFileFormat("Video/TestMkv.mkv", ".mp4");

    public static string ConvertVideoFileFormat(string file, string convertedExtension)
        string result = string.Empty;
        string input = string.Empty;
        string output = string.Empty;
            string ffmpegFilePath = HttpContext.Current.Server.MapPath("Video/ffmpeg.exe");// path of ffmpeg.exe -replace it for your options.
            FileInfo fi = new FileInfo(HttpContext.Current.Server.MapPath(file));
            string filename = Path.GetFileNameWithoutExtension(fi.Name) + "output";//output video name
            string extension = Path.GetExtension(fi.Name);
            input = HttpContext.Current.Server.MapPath(file);
            output = HttpContext.Current.Server.MapPath("Video/" + filename + convertedExtension); //path where you want to save your video
            string cmd = " -i " + input + " -acodec aac -strict experimental -ac 2 -ab 128k -vcodec libx264 -f mp4 -crf 22 -s 640x360 " + output;
            var processInfo = new ProcessStartInfo(ffmpegFilePath, cmd)
                UseShellExecute = false,
                CreateNoWindow = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true

                Process process = System.Diagnostics.Process.Start(processInfo);
                result = process.StandardError.ReadToEnd();

            catch (Exception)
                result = string.Empty;
        catch (Exception ex)
            string error = ex.Message;
        return result;

The post [Sloved]-Converting Video with FFMPEG With ASP.Net appeared first on Software Development | Programming Tutorials.

Read More Articles