SetFramesPerSecond() private method

private SetFramesPerSecond ( ) : bool
return bool
Esempio n. 1
0
        private void MainForm_DoubleClick(object sender, EventArgs e)
        {
            #if DEBUG

            using (new HourGlass())
            {
                /*
                for (var i = 1; i <= 1000; i++)
                {
                    var activationState = Protection.GetLicenseStatus(true);
                }

                MessageBox.Show("done");

                return;
                */

                var inputFileObject = new InputFileObject()
                {
                    SourceFileInfo = new FileInfo(MainModel.GetPathToSampleVideo()),
                };

                using (var scanWorker = new ScanWorker(inputFileObject))
                {
                    scanWorker.SetBitrate();
                    scanWorker.SetFramesPerSecond();
                    scanWorker.SetTotalFrames();
                    scanWorker.SetVideoDimensions();
                    scanWorker.SetVideoDuration();
                }

                MainModel.InputFileObjects.Add(inputFileObject);

                var newHighlight1 = (new HighlightObject()
                {
                    InputFileObject = inputFileObject,
                    StartTime = TimeSpan.FromSeconds(10),
                    BookmarkTime = TimeSpan.FromSeconds(27),
                    EndTime = TimeSpan.FromSeconds(25),
                });
                newHighlight1.GenerateHighlightTitle();
                MainModel.HighlightObjects.Add(newHighlight1);

                var sampleFileDir = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\..\sample-files");

                var inputFileObject2 = new InputFileObject()
                {
                    SourceFileInfo = new FileInfo(Path.Combine(sampleFileDir, @"Long videos\GO021100.MP4")),
                };

                using (var scanWorker = new ScanWorker(inputFileObject2))
                {
                    scanWorker.SetBitrate();
                    scanWorker.SetFramesPerSecond();
                    scanWorker.SetTotalFrames();
                    scanWorker.SetVideoDimensions();
                    scanWorker.SetVideoDuration();
                }

                MainModel.InputFileObjects.Add(inputFileObject2);

                var newHighlight2 = (new HighlightObject()
                {
                    InputFileObject = inputFileObject2,
                    StartTime = TimeSpan.FromSeconds(60 * 20 + 4),
                    BookmarkTime = TimeSpan.FromSeconds(60 * 20 + 19),
                    EndTime = TimeSpan.FromSeconds(60 * 20 + 17),
                });
                newHighlight2.GenerateHighlightTitle();
                MainModel.HighlightObjects.Add(newHighlight2);

                var newHighlight3 = new HighlightObject()
                {
                    InputFileObject = inputFileObject2,
                    StartTime = TimeSpan.FromSeconds(60 * 10 + 4),
                    BookmarkTime = TimeSpan.FromSeconds(60 * 10 + 19),
                    EndTime = TimeSpan.FromSeconds(60 * 10 + 17)
                };
                newHighlight3.GenerateHighlightTitle();
                MainModel.HighlightObjects.Add(newHighlight3);

                var newHighlight4 = new HighlightObject()
                {
                    InputFileObject = inputFileObject2,
                    StartTime = TimeSpan.FromSeconds(60 * 5 + 4),
                    BookmarkTime = TimeSpan.FromSeconds(60 * 5 + 19),
                    EndTime = TimeSpan.FromSeconds(60 * 5 + 17),
                };
                newHighlight4.GenerateHighlightTitle();
                MainModel.HighlightObjects.Add(newHighlight4);

                var inputFileObject3 = new InputFileObject()
                {
                    SourceFileInfo = new FileInfo(Path.Combine(sampleFileDir, "00002.MTS")),
                };

                using (var scanWorker = new ScanWorker(inputFileObject3))
                {
                    scanWorker.SetBitrate();
                    scanWorker.SetFramesPerSecond();
                    scanWorker.SetTotalFrames();
                    scanWorker.SetVideoDimensions();
                    scanWorker.SetVideoDuration();
                }

                MainModel.InputFileObjects.Add(inputFileObject3);

                var newHighlight5 = (new HighlightObject()
                {
                    InputFileObject = inputFileObject3,
                    StartTime = TimeSpan.FromSeconds(30),
                    BookmarkTime = TimeSpan.FromSeconds(47),
                    EndTime = TimeSpan.FromSeconds(45),
                });
                newHighlight5.GenerateHighlightTitle();
                MainModel.HighlightObjects.Add(newHighlight5);

                SwitchToStep(Steps.Scan);
                scanControl_ScanCompletedWithHighlights(sender, e);

            }
            #endif
        }
Esempio n. 2
0
        private void TrimButton_Click(object sender, EventArgs e)
        {
            MainModel.Initialize();

            OpenFileDialog.CheckFileExists = true;
            OpenFileDialog.FileName = "";

            string supportedExtensionsAsSingleString = "";
            foreach (string supportedExtension in MainModel.GetVideoExtensions())
            {
                supportedExtensionsAsSingleString += "*" + supportedExtension + ";";
            }
            if (supportedExtensionsAsSingleString.Length > 0)
                supportedExtensionsAsSingleString = supportedExtensionsAsSingleString.Substring(0, supportedExtensionsAsSingleString.Length - 1);

            OpenFileDialog.Multiselect = false;
            OpenFileDialog.Title = "Tell me which video you'd like to trim.";
            OpenFileDialog.Filter = "Supported Files (" + supportedExtensionsAsSingleString + ")|" + supportedExtensionsAsSingleString + "|All Files (*.*)|*.*";
            OpenFileDialog.ShowDialog();

            if (File.Exists(OpenFileDialog.FileName))
            {
                var inputFileObject = new InputFileObject(new FileInfo(OpenFileDialog.FileName));

                string ss = "0:00:00", end = "0:00:00";
                if (InputBox("Start time", "What is the starting time that you'd like to trim from? (e.g. 0:00:20)", ref ss) == DialogResult.OK)
                {
                    if (InputBox("End time", "What is the ending time that you'd like to trim to? (e.g. 0:00:35)", ref end) == DialogResult.OK)
                    {

                        var saveFileDialog = new SaveFileDialog();
                        saveFileDialog.InitialDirectory = inputFileObject.SourceFileInfo.DirectoryName;
                        saveFileDialog.FileName = inputFileObject.SourceFileInfo.Name + " - " + ss + " to " + end + inputFileObject.SourceFileInfo.Extension;
                        saveFileDialog.Title = "Where should we save the new file?";

                        if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {

                            using (var scanWorker = new ScanWorker(inputFileObject))
                            {

                                scanWorker.SetFramesPerSecond();
                                scanWorker.SetBitrate();

                                var highlightObject = new HighlightObject();
                                highlightObject.InputFileObject = inputFileObject;
                                highlightObject.StartTime = TimeSpan.Parse(ss); // ex. 0:06
                                highlightObject.EndTime = TimeSpan.Parse(end);

                                var saveWorker = new SaveWorker(highlightObject);
                                saveWorker.RunWorkerAsync(saveFileDialog.FileName);

                                while (saveWorker.PublishWorkerResult == PublishWorker.PublishWorkerResults.NotFinished)
                                    Application.DoEvents();

                                if (saveWorker.PublishWorkerResult == PublishWorker.PublishWorkerResults.Success)
                                    while (saveWorker.OutputFileInfo == null)
                                        Application.DoEvents();

                                var files = new List<FileInfo> { saveWorker.OutputFileInfo };
                                MainModel.LaunchExplorerWithFilesSelected(files);

                            }

                        }

                    }

                }
            }

            MainModel.Dispose();
        }