So I want to extract every frame of video every half minute. Here is how I do with C#.
Define function to call FFmepg
public static void Ffmpeg(string fileName) { string outFile = fileName.Substring(0, fileName.Length - 5); string cmdParams = String.Format("-hide_banner -i {0} -vf fps=1/30 {1}%03d.jpg", fileName, outFile); //fps=1/30 means every 30 seconds extract a frame string exePath = @"C:\Users\rockymay\OneDrive\RipAlbumUrl\ffmpeg.exe"; using (Process p = new Process()) { p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = exePath; p.StartInfo.Arguments = cmdParams; p.Start(); p.WaitForExit(); } }
Then call out function in Main
class Program { static void Main(string[] args) { Console.WriteLine(DateTime.Now);//Now time Console.WriteLine("Select your video file full path"); string path = Console.ReadLine(); Ffmpeg(path); } }
Thanks to :
https://www.codeproject.com/Articles/774093/Another-FFmpeg-exe-Csharp-Wrapper
No comments:
Post a Comment