I'm working on a project, essentially a social media app for the traveler community. In this application, users can upload videos in any format, but I need to save them in MP4 format so that any browser can play them.
I've downloaded various formats of videos from a website https://www.quickpickdeal.com/tag/download-sample-videos and installed FFmpeg to convert videos to MP4 format. For the backend, I'm using ASP.NET Core. Currently, I'm using the following code to convert MKV videos to MP4.
//path where you want to save your converted 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
};
but I'm unsure how to write generic logic for the command so it can convert videos of any format to MP4 and only take the first minute of the video.
Could someone suggest how I can achieve these tasks?