Beispiel #1
0
        /// <summary>
        /// Write the AviSynth Output file
        /// </summary>
        public void WriteAvisynthOutputFile()
        {
            StreamWriter  sw       = new StreamWriter(frpf.AviSynthOutputFile, false, AcHelper.FindEncoding("1253"));
            StringBuilder sbuilder = new StringBuilder();

            //Write header comments
            sbuilder.AppendLine("#Frame restoration AviSynth File");
            sbuilder.AppendLine("#Courtesy of AC Tools");
            sbuilder.AppendLine();

            //Write open video file
            if (frpf.VideoFile.ToLowerInvariant().EndsWith(".avs"))
            {
                sbuilder.AppendLine(String.Format("original=Import(\"{0}\")", frpf.VideoFile));
                sbuilder.AppendLine();
            }
            else
            {
                AviSynthFileCreator afc = new AviSynthFileCreator();
                sbuilder.AppendLine("original=" + afc.GetAviSynthVideoSourceProvider(vidPlayer.AvisynthVideoProvider).GetOpenFileString(frpf.VideoFile));
                sbuilder.AppendLine();
            }

            //Write the delete and duplicate commands
            sbuilder.AppendLine(frpf.vfl.FrameSections[0].KienzanString());

            //Write the return command
            sbuilder.AppendLine("return Whole_Video");

            sw.Write(sbuilder.ToString());

            sw.Close();
        }
Beispiel #2
0
        private void OpenVideo()
        {
            try
            {
                fileToOpen = txtVideoFile.Text;
                if (fileToOpen.Length < 1)
                {
                    videoOpened = false;
                    return;
                }

                if (avs != null)
                {
                    avs.Dispose();
                }
                // check if file exists
                if (File.Exists(fileToOpen))
                {
                    // check if file is AviSynth Script
                    if (!AcHelper.GetFilename(fileToOpen, GetFileNameMode.ExtensionOnly, GetDirectoryNameMode.NoPath).Contains("avs"))
                    {
                        // If not Avisynth Script, prompt the user to select AviSynth Source Plugin
                        frmAviSynthVideoSource frm = new frmAviSynthVideoSource();
                        frm.StartPosition = FormStartPosition.CenterParent;
                        frm.ShowDialog();
                        frm.Activate();
                        if (!frm.OKPressed)
                        {
                            return;
                        }
                        // Create the AviSynth Script
                        AviSynthFileCreator avsfc;
                        if (frm.OverrideFramerateChecked)
                        {
                            avsfc = new AviSynthFileCreator(fileToOpen, frm.SelectedAviSynthVideoProvider, frm.OverrideFramerate);
                        }
                        else
                        {
                            avsfc = new AviSynthFileCreator(fileToOpen, frm.SelectedAviSynthVideoProvider);
                        }
                        // Set the new file to open to the newly created AviSynth Script
                        fileToOpen = avsfc.AviSynthScriptFilename;
                    }
                    // Open the Avisynth Script using Task in order to have a responsive UI

                    _FromOpeningVideo = true;
                    using (Task t = Task.Factory.StartNew(() =>
                    {
                        avs = AvsFile.OpenScriptFile(fileToOpen);
                    }))
                    {
                        while (!t.IsCompleted)
                        {
                            Application.DoEvents();
                        }
                        if (t.Exception != null)
                        {
                            Application.DoEvents();
                            if (t.Exception.InnerException != null)
                            {
                                throw t.Exception.InnerException;
                            }
                            else
                            {
                                throw t.Exception;
                            }
                        }
                    }
                    videoOpened = true;

                    this.Size = new Size(
                        avs.Clip.VideoWidth + (this.MinimumSize.Width - origPicVideoWidth)
                        , avs.Clip.VideoHeight + (this.MinimumSize.Height - origPicVideoHeight)
                        );

                    ResizePictureBox();

                    this.frameRate        = Convert.ToDecimal(avs.Clip.Raten) / Convert.ToDecimal(avs.Clip.Rated);
                    trackVideo.Maximum    = avs.Clip.NumberOfFrames - 1;
                    trackVideo.Minimum    = 0;
                    trackVideo.Value      = 0;
                    cmbSize.SelectedIndex = 5;
                    fileOpened            = fileToOpen;
                    this.Text             = frmVideoPlayer.formName + " - " + fileOpened;
                    txtVideoFile.Text     = fileOpened;
                    ChangeVideoFrame(0, false);

                    _FromOpeningVideo = false;
                }
                else
                {
                    videoOpened = false;
                }
            }
            catch (Exception)
            {
                videoOpened       = false;
                _FromOpeningVideo = false;
                throw;
            }
        }