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#
- Entity framework terms used with asp net mvc app
- Show progress of a video conversion with FFMpeg
- ASP Net Text box with Google like dropdown search values
- How to test ASP NET ashx Handler With File Attached
- Build asp net core with grpc, errors: wellknowntype not found
- Setting up an ASP Net Core app with subdirectories
- Using Bootstrap tabs with ASP NET repeater
- ASP NET Sessions throw error with .ToString()
- How to escape single quote in url query string with asp net
- How can I show Currency with Negative instead of Parentheis in ASP NET MVC?
- Converting Multi-Dimensional Array to Single, with nullable Values
- Problem with converting a 32 digit hexadecimal number to long
- Using Access DB (.mdb) with ADODB in C# (ASP.MVC) like with Classic ASP
- Cannot access asp .net core app when run with docker on local machine, or to kubernetes
- Converting an object to string with a specified culture
- Converting a decimal (user string) into hex with 0x prefix
- Converting html strings in Excel file to formatted word file with .NET
- Matching a classic ASP random number with a C# random number
- ASP.NET with Video and Voice?
- Converting the Select Case with To and Is to c# problems
- ASP MVC4 await with httpclient
- Converting images to PDF with iTextSharp preserve clipping path
- Display video with VlcDotNet library
- angularjs : how to get a value from asp .net page with input type hidden?
- Axis Camera video streaming with C# 64bit
- .Using a Factory Pattern with NET Core 3.1 Dependency Injection
- asp net core Middleware that needs apiversioning version
- ASP Net Core 2.1 Session
- Converting XML to JSON with complex XML data
- Multiple replacemenst with a single RegEx in. Net
- How to create CRITICAL events for Windows Event Viewer?
- How To Implement DDD with C# .NET 4
- Create Dynamic Assembly On New App Domain
- C# - stream reader issue
- Deploying C# application with UAC
- How to endlessly check if key was pressed?
- Is the lack of "objects" in Thrift awkward?
- How to write a class that can encompass other related classes?
- C# - Get Integer Byte Array in String
- Why is my call to Runspace.Open() not returning?
- Regex to identify escaped characters issue
- Reactive Extensions - AsyncLock.Wait throws ArgumentNullException
- C# - Call a function in a parent form
- How to add source files to external libraries?
- Re submission restriction in c#
- Autofac different service resolution based on TypedParameter
- C# Math.Max type handling
- how to implement method with return type as Task<T>
- Grab Bitmap-Image (Winforms) and convert to WPF-Image fails
- When I try to load the list my values come out all the same