Reputation: 10648
string inputpath = strFileNamePath;
string outputpath = "C:\\Image\\";
//for (int iIndex = 0; iIndex < 1000; iIndex++)
//{
//string fileargs = "-i" + " " + inputpath + " -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv " + outputpath + "SRT.flv";
string fileargs = "-i" + " " + inputpath + " " + outputpath + "image.jpg";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "C:\\Documents and Settings\\Badr\\My Documents\\Visual Studio 2008\\Projects\\Video2image2video.\\ffmpeg\\ffmpeg.exe";
p.StartInfo.Arguments = fileargs;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
i have this code this creates only 1 image of video i apply a loop but i repeatedly generates the initial image how can i get images of all the video
thanx in advance
Upvotes: 3
Views: 3456
Reputation: 39
Hi do you want to take images in video files when you for to return in in this way;
for (int i = 0; i < iImageCount; i++)
{
string sInputVideo = Page.MapPath(...);
string sImageCapture = Page.MapPath("") + "\\Videolar\\" + ImageName+ "_" + iResim + ".jpg";
ffmpeg.StartInfo.Arguments = " -i \"" + sInputVideo + "\" -s 108*100 -ss " + iImageCapture + " -vframes 1 -f image2 -vcodec mjpeg \"" + sImageCapture + "\"";
ffmpeg.StartInfo.FileName = (Server.MapPath("Referanslar/ffmpeg.exe"));
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
iImageCapture += 1;
iResim++;
}
You can take pictures as you like by changing it ;)
Upvotes: 0
Reputation: 120917
From the documentation of ffmpeg:
You can extract images from a video, or create a video from many images:
For extracting images from a video:
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
This will extract one video frame per second from the video and will output them in files named
foo-001.jpeg',
foo-002.jpeg', etc. Images will be rescaled to fit the new WxH values.
So just change the arguments you pass to ffmpeg and you should be up and running.
Upvotes: 1