public List <VideoThumbnailInfo> TakeThumbnails() { List <VideoThumbnailInfo> tempThumbnails = new List <VideoThumbnailInfo>(); for (int i = 0; i < Options.ThumbnailCount; i++) { string mediaFileName = Path.GetFileNameWithoutExtension(MediaPath); int timeSliceElapsed; if (Options.RandomFrame) { timeSliceElapsed = GetRandomTimeSlice(i); } else { timeSliceElapsed = GetTimeSlice(Options.ThumbnailCount) * (i + 1); } string filename = string.Format("{0}-{1}.{2}", mediaFileName, timeSliceElapsed, Options.ImageFormat.GetDescription()); string tempThumbnailPath = Path.Combine(GetOutputDirectory(), filename); using (Process p = new Process()) { ProcessStartInfo psi = new ProcessStartInfo(FFmpegPath); psi.WindowStyle = ProcessWindowStyle.Hidden; psi.Arguments = string.Format("-ss {0} -i \"{1}\" -f image2 -vframes 1 -y \"{2}\"", timeSliceElapsed, MediaPath, tempThumbnailPath); p.StartInfo = psi; p.Start(); p.WaitForExit(1000 * 30); } if (File.Exists(tempThumbnailPath)) { VideoThumbnailInfo screenshotInfo = new VideoThumbnailInfo(tempThumbnailPath) { Timestamp = TimeSpan.FromSeconds(timeSliceElapsed) }; tempThumbnails.Add(screenshotInfo); } OnProgressChanged(i + 1, Options.ThumbnailCount); } return(Finish(tempThumbnails)); }
public List<VideoThumbnailInfo> TakeThumbnails() { List<VideoThumbnailInfo> tempThumbnails = new List<VideoThumbnailInfo>(); for (int i = 0; i < Options.ThumbnailCount; i++) { string mediaFileName = Path.GetFileNameWithoutExtension(MediaPath); int timeSliceElapsed; if (Options.RandomFrame) { timeSliceElapsed = GetRandomTimeSlice(i); } else { timeSliceElapsed = GetTimeSlice(Options.ThumbnailCount) * (i + 1); } string filename = string.Format("{0}-{1}.{2}", mediaFileName, timeSliceElapsed, Options.ImageFormat.GetDescription()); string tempThumbnailPath = Path.Combine(GetOutputDirectory(), filename); using (Process p = new Process()) { ProcessStartInfo psi = new ProcessStartInfo(FFmpegPath); psi.WindowStyle = ProcessWindowStyle.Hidden; psi.Arguments = string.Format("-ss {0} -i \"{1}\" -f image2 -vframes 1 -y \"{2}\"", timeSliceElapsed, MediaPath, tempThumbnailPath); p.StartInfo = psi; p.Start(); p.WaitForExit(1000 * 30); } if (File.Exists(tempThumbnailPath)) { VideoThumbnailInfo screenshotInfo = new VideoThumbnailInfo(tempThumbnailPath) { Timestamp = TimeSpan.FromSeconds(timeSliceElapsed) }; tempThumbnails.Add(screenshotInfo); } OnProgressChanged(i + 1, Options.ThumbnailCount); } return Finish(tempThumbnails); }