How to manipulate video in .NET using ffmpeg

In this case I’m resizing the video and converting it to FLV format. For more ffmpeg commandline options - http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html

private void ConvertVideo(string srcURL, string destURL)
{
    string ffmpegURL = "~/project/tools/ffmpeg.exe";
    DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Server.MapPath(ffmpegURL)));

    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = Server.MapPath(ffmpegURL);
    startInfo.Arguments = string.Format("-i \"{0}\" -s 368x216 -aspect 1.7777 \"{1}\"", srcURL, destURL);
    startInfo.WorkingDirectory = directoryInfo.FullName;
    startInfo.UseShellExecute = false;
    startInfo.RedirectStandardOutput = true;
    startInfo.RedirectStandardInput = true;
    startInfo.RedirectStandardError = true;

    using (Process process = new Process())
    {
        process.StartInfo = startInfo;

        try
        {
            process.Start();
            StreamReader standardOutput = process.StandardOutput;
            StreamWriter standardInput = process.StandardInput;
            StreamReader standardError = process.StandardError;
            process.WaitForExit();

            lblError.Text = standardError.ReadToEnd();
            lblOutput.Text = standardOutput.ReadToEnd();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
}
If you liked this post, 🗞 subscribe to my newsletter and follow me on 𝕏!