Exemple #1
0
        // This method is experimental.
        public override void TakeScreenshots(BackgroundWorker worker)
        {
            ProcessStartInfo psi = new ProcessStartInfo(ThumbnailerPath);
            psi.WindowStyle = ProcessWindowStyle.Minimized;

            string tempScreenshotPathFormat = Path.Combine(ScreenshotDir, string.Format("{0}-%03d.png", Path.GetFileNameWithoutExtension(MediaFile.FilePath)));

            psi.Arguments = string.Format("-i \"{0}\" -f image2 -vf fps=1/{1} -vframes {2} \"{3}\"", MediaFile.FilePath, TimeSlice, Options.ScreenshotCount, tempScreenshotPathFormat);

            Process p = new Process();
            p.StartInfo = psi;
            p.Start();
            p.WaitForExit(1000 * 30);

            for (int i = 1; i <= Options.ScreenshotCount; i++)
            {
                string tempScreenshotPath = Path.Combine(ScreenshotDir, string.Format("{0}-{1:000}.png", Path.GetFileNameWithoutExtension(MediaFile.FilePath), i));

                if (File.Exists(tempScreenshotPath))
                {
                    ScreenshotInfo screenshotInfo = new ScreenshotInfo(tempScreenshotPath)
                    {
                        Args = psi.Arguments,
                        Timestamp = TimeSpan.FromSeconds(TimeSlice * i)
                    };

                    TempScreenshots.Add(screenshotInfo);
                }
            }

            Finish();
        }
Exemple #2
0
        public virtual void TakeScreenshots(ThreadWorker worker)
        {
            string MPlayerTempFp = Path.Combine(ScreenshotDir, "00000001.png"); // MPlayer creates this file by default

            switch (App.Settings.ThumbnailerType)
            {
            case ThumbnailerType.MPlayer:
                ThumbnailerPath = App.Settings.MPlayerPath;
                if (File.Exists(MPlayerTempFp))
                {
                    File.Delete(MPlayerTempFp);
                }
                break;

            case ThumbnailerType.FFmpeg:
                ThumbnailerPath = App.Settings.FFmpegPath;
                break;
            }

            if (!File.Exists(ThumbnailerPath))
            {
                return;
            }

            for (int i = 0; i < Options.ScreenshotCount; i++)
            {
                string mediaFileName = Path.GetFileNameWithoutExtension(MediaFile.FilePath);
                // worker.ReportProgress((int)ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Taking screenshot {0} of {1} for {2}", i + 1, Options.ScreenshotCount, mediaFileName));

                int    timeSliceElapsed   = Options.RandomFrame ? GetRandomTimeSlice(i) : TimeSlice * (i + 1);
                string tempScreenshotPath = Path.Combine(ScreenshotDir, string.Format("{0}-{1}.", mediaFileName, timeSliceElapsed.ToString("00000")));

                ProcessStartInfo psi = new ProcessStartInfo(ThumbnailerPath);
                psi.WindowStyle = ProcessWindowStyle.Hidden;

                switch (App.Settings.ThumbnailerType)
                {
                case ThumbnailerType.MPlayer:
                    tempScreenshotPath += "png";     // MPlayer only supports png reliably
                    psi.Arguments       = string.Format("-nosound -ss {0} -zoom -vf screenshot -frames 1 -vo png:z=9:outdir=\\\"{1}\\\" \"{2}\"",
                                                        timeSliceElapsed, ScreenshotDir, MediaFile.FilePath);
                    break;

                case ThumbnailerType.FFmpeg:
                    tempScreenshotPath += Options.FFmpegThumbnailExtension;
                    psi.Arguments       = string.Format("-ss {0} -i \"{1}\" -f image2 -vframes 1 -y \"{2}\"", timeSliceElapsed, MediaFile.FilePath, tempScreenshotPath);
                    break;
                }

                Process p = new Process();
                p.StartInfo = psi;
                p.Start();
                p.WaitForExit(1000 * 30);
                p.Close();

                switch (App.Settings.ThumbnailerType)
                {
                case ThumbnailerType.MPlayer:
                    if (File.Exists(MPlayerTempFp))
                    {
                        if (File.Exists(tempScreenshotPath))
                        {
                            File.Delete(tempScreenshotPath);
                        }
                        File.Move(MPlayerTempFp, tempScreenshotPath);
                    }
                    break;
                }

                if (File.Exists(tempScreenshotPath))
                {
                    ScreenshotInfo screenshotInfo = new ScreenshotInfo(tempScreenshotPath)
                    {
                        Args      = psi.Arguments,
                        Timestamp = TimeSpan.FromSeconds(timeSliceElapsed)
                    };

                    MediaFile.TempScreenshots.Add(screenshotInfo);
                }
            }

            Finish();
        }
Exemple #3
0
        public virtual void TakeScreenshots(BackgroundWorker worker)
        {
            string MPlayerTempFp = Path.Combine(ScreenshotDir, "00000001.png"); // MPlayer creates this file by default

            switch (App.Settings.ThumbnailerType)
            {
                case ThumbnailerType.MPlayer:
                    ThumbnailerPath = App.Settings.MPlayerPath;
                    if (File.Exists(MPlayerTempFp)) File.Delete(MPlayerTempFp);
                    break;
                case ThumbnailerType.FFmpeg:
                    ThumbnailerPath = App.Settings.FFmpegPath;
                    break;
            }

            if (!File.Exists(ThumbnailerPath)) return;

            for (int i = 0; i < Options.ScreenshotCount; i++)
            {
                string mediaFileName = Path.GetFileNameWithoutExtension(MediaFile.FilePath);
                worker.ReportProgress((int)ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Taking screenshot {0} of {1} for {2}", i + 1, Options.ScreenshotCount, mediaFileName));

                int timeSliceElapsed = Options.RandomFrame ? GetRandomTimeSlice(i) : TimeSlice * (i + 1);
                string tempScreenshotPath = Path.Combine(ScreenshotDir, string.Format("{0}-{1}.", mediaFileName, timeSliceElapsed.ToString("00000")));

                ProcessStartInfo psi = new ProcessStartInfo(ThumbnailerPath);
                psi.WindowStyle = ProcessWindowStyle.Hidden;

                switch (App.Settings.ThumbnailerType)
                {
                    case ThumbnailerType.MPlayer:
                        tempScreenshotPath += "png"; // MPlayer only supports png reliably
                        psi.Arguments = string.Format("-nosound -ss {0} -zoom -vf screenshot -frames 1 -vo png:z=9:outdir=\\\"{1}\\\" \"{2}\"",
                            timeSliceElapsed, ScreenshotDir, MediaFile.FilePath);
                        break;
                    case ThumbnailerType.FFmpeg:
                        tempScreenshotPath += Options.FFmpegThumbnailExtension;
                        psi.Arguments = string.Format("-ss {0} -i \"{1}\" -f image2 -vframes 1 -y \"{2}\"", timeSliceElapsed, MediaFile.FilePath, tempScreenshotPath);
                        break;
                }

                Process p = new Process();
                p.StartInfo = psi;
                p.Start();
                p.WaitForExit(1000 * 30);
                p.Close();

                switch (App.Settings.ThumbnailerType)
                {
                    case ThumbnailerType.MPlayer:
                        if (File.Exists(MPlayerTempFp))
                        {
                            if (File.Exists(tempScreenshotPath)) File.Delete(tempScreenshotPath);
                            File.Move(MPlayerTempFp, tempScreenshotPath);
                        }
                        break;
                }

                if (File.Exists(tempScreenshotPath))
                {
                    ScreenshotInfo screenshotInfo = new ScreenshotInfo(tempScreenshotPath)
                    {
                        Args = psi.Arguments,
                        Timestamp = TimeSpan.FromSeconds(timeSliceElapsed)
                    };

                    TempScreenshots.Add(screenshotInfo);
                }
            }

            Finish();
        }