问题
I would like to reduce the size of a mp4 video from a webjob on Azure. I have a queue trigger in my webjob, each time a new video is added, the VideoCompressor Webjob will reduce the size of the mp4 video file (reduce to 200px width or height depending of the orientation + crop to only 2 min).
From what I read on internet, ffmpeg is the answer. There is nuget package: FFmpeg.stable.GZCR. I would like to use a nugget package to not have to go on the ffmpeg website and verify each time if there a new version.
But I don't find any documentation about it:
- Google search for "FFmpeg.stable.GZCR" documentation
- Google search for How to use "FFmpeg.stable.GZCR"
I found some information about FFmpeg but it's for WinRT, so not usefull in my case:
- https://blogs.windows.com/buildingapps/2015/06/05/using-ffmpeg-in-windows-applications/#FWv2kTdJ4zyIrzC4.97
I found this code, it seems to be what I would like to do. The problem is from the nugget package, I dont know how to access to the ffmpeg.exe", but maybe you have other idea?
- https://gist.github.com/jakkaj/a41aa7ff3ca21426abd66905cf65da11
Do you have any idea or suggestion?
回答1:
FFMPEG has a very complex API and you may be better off calling the tool directly from a C# program. When researching how to do something in ffmpeg everyone will be discussing the tool in terms of accessing the .exe directly so you will have less confusion than attempting to use a wrapper API.
You can do this using System.Diagnostics.Process
, for example
var process = new Process
{
// Path to your ffmpeg binary
FileName = "ffmpeg.exe",
// Example ffmpeg command to get the sound from an mp4 video
Arguments = "-i input.mp4 -vn -ab 320 output.mp3",
UseShellExecute = false
}
process.Start();
If you want to automate upgrading ffmpeg you could script it to get the latest release from the GitHub repository and compile ffmpeg yourself.
来源:https://stackoverflow.com/questions/50008452/how-to-use-ffmpeg-with-c-sharp-on-azure