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 format.you 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;
try
{
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
};
try
{
Process process = System.Diagnostics.Process.Start(processInfo);
result = process.StandardError.ReadToEnd();
process.WaitForExit();
process.Close();
}
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
- Write a value which contain comma to a CSV file in c#?
- Reading CSV File with cells containing commas c#
- Split CSV with columns may contain ‘,’ Comma C#
- [Simple Way]-Cascading DropDownList in Asp.Net Mvc Using Jquery Ajax
- [Simple Way]-How to get data from database using JQuery Ajax in asp net MVC
- [Simple Way]-ASP.NET Core Upload Multiple File Web API model
- [Simple Way]- Image Upload in .NET Core Web API
- [Easy Way]-Receive File and other form data together in ASP.NET Core Web API
- Replace image in word document using C#
- How to add new rows to an existing word document table in C#
- ASP NET 4 How can I use Data Annotations with DataType Password with a MinLength property?
- IF ELSE condition asp net with SQL Server
- How to connect ASP NET web app client with NET framework console app server
- ASP Net Core decimal input with period turns into a whole number
- Generic repository pattern ASP NET CORE Web Api: using include with async
- Is this a bug with the asp net core ActionLink Html helper?
- ASP NET Core MVC action returns bad request when trying to upload files with ajax
- Fill textbox with multiple email address from dropdownlist and seperate by comma in asp net
- HTTP ERROR (404) with uploadify and custom uploader for asp net [ASP NET MVC 4]
- Converting vb.net to c# with Object
- Converting number in string with negative sign at the end
- Converting C# to VB - Trouble with Events and Lambda Expression
- ASP controls with inline C#
- Converting PDF to PDFA1-A with iTextSharp
- programming a video player with C# (mono) for linux
- Search engine friendly urls in ASP dot NET
- Problems with converting the DateTime input
- asp net label break line after x characters
- how to develop android app with asp c#
- Register/Login with Linkedin in ASP .NET Core 3.1
- Inserting a DateTime with SQL (while converting to string)
- Converting string amount value with parenthesis to double
- Whats the best way to deal with pages loaded via browser history in asp .net?
- Generate one pdf document with multiple pages converting from html using IText 7
- Regex parse Youtube url with CSV Video ID
- The data source for GridView with id 'GridView1' did not have any properties or attributes in asp .net
- C# Converting string with accents
- How do I create a unique list of dates in a drop down in ASP MVC with C#?
- SQL Connection String C# ASP NET
- How ASP MVC return json with variable name
- New instance from a manually loaded assembly
- how to convert datetime to a particular format
- Auto-size text on button
- C# - I can't find mxparser dll
- why is my page passing a blank value for my textBox
- Centralised/shared COM DLL, possible?
- Does the <asp:Textbox> have a onFocusLost event?
- Why my program lags upon selecting strip
- How do I initialize an array to avoid a NullReferenceException error in this case
- How do I check on the properties of WPF elements whilst in a different class?
- Adding emoticons to C# .net UTF-8
- How to set a GUID field from C# code
- Convert UTF-8 string to sbyte array and back?
- What's best performance way to constantly change image on WP7?
- Selenium.UnhandledAlertException: C#
- C# Simulating Excel pivot feature with T-Sql Group by
- Handling large amount of an event handlers
- Why C++ msgpack-c adds number 13 (0x0D) before number 10 (0x0A), but C# MessagePack-CSharp does not?
- Project compiles but doesnt seem to build
- Java vs C# algorithm execution