Kiran Chitari

Kiran Chitari

  • NA
  • 50
  • 2.4k

Passing input to an exe file using C# console application

Aug 1 2018 2:12 AM
I want to convert my video file from mp4 to webm, using ffmpeg.exe got from ffmpeg.org.
I need to pass the input through a C# console application to ffmpeg.exe. so that it converts that file. Following is the code that I have tried:
 
using System;
using System.Diagnostics;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string input = @"C:\Users\bkiran\Downloads\Compressed\ffmpeg-4.0.2-win64-static\bin\mymp4.mp4";
string output = @"C:\Users\bkiran\Downloads\Compressed\ffmpeg-4.0.2-win64-static\bin\testwebmFromc.webm";
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = @"C:\Users\bkiran\Downloads\Compressed\ffmpeg-4.0.2-win64-static\bin\ffmpeg.exe";
processStartInfo.Arguments = "\"ffmpeg -i " + input + " " + output + "\"";
Process.Start(processStartInfo);
}
}
}
 
I tried this code but it is not working. I think the reason is ffmpeg is created using C and I am accessing this through C# console application. Is this is due to the compatibility issue?

Answers (1)