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()); } } }
hi all,
i worked out the above given code. its not working if the file size is large for example the file size is greater than 750kb. its not to convert flv format. plz reply me
[...] a release showing just how to do transcoding using FFMPEG in VB.Net. Another individual made this work in c# too! Filed under: [...]
What configuration to be made to make it work in online?
it is working fine in local but it is n’t working in server..urgent
sekar – Make sure you have the right permissions. The directory in which you have FFMPEG files need to have read and execute permissions (all files!) and the directory where you intend to put the converted files need to have write permissions. If that doesn’t work then try commenting out – process.WaitForExit(); – I’ve had problems with it in shared hosting environment where it just hangs the process every now and then.
The hangs are caused by your way of handling the redirected streams. while the program runs you have to read from them because if there is to much unread data in them ffmpeg cant write to them anymore. you can listen for the StandardOutputReceived event to mitigate this issue.
name – Thanks for your comment, that makes sense. I’ll give it a try.
[...] on the reader comments on my previous entry on this topic I was able to fix some of the issues that others were [...]