Example #1
0
        public static Bitmap getBitmapFromFrame(AviSynthClip avs, int clp, int frame)
        {
            Bitmap bmp;
            if (avs.PixelType == AviSynthColorspace.RGB24) bmp = new Bitmap(avs.VideoWidth, avs.VideoHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            else if (avs.PixelType == AviSynthColorspace.RGB32) bmp = new Bitmap(avs.VideoWidth, avs.VideoHeight, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            else
                bmp = new Bitmap(avs.VideoWidth, avs.VideoHeight, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

            try
            {
                Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                System.Drawing.Imaging.BitmapData bmpData =
                    bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
                    bmp.PixelFormat);
                try
                {
                    IntPtr ptr = bmpData.Scan0;
                    avs.ReadFrame(ptr, clp, bmpData.Stride, frame);
                }
                finally
                {
                    bmp.UnlockBits(bmpData);
                }
            }
            catch
            {
            }
            bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
            return bmp;
        }
Example #2
0
        public karaokeTimerW(mainW mW,AVStoDirectSound avs2ds,AviSynthClip avsaudio, IntPtr af)
        {
            InitializeComponent();
            this.mW = mW;
            this.avs2ds = avs2ds;
            this.avsaudio = avsaudio;
            this.AudioFull = af;

            //this.MaximumSize = new Size(0,this.Height);

            this.Resize += new EventHandler(karaokeTimerW_Resize);
            sliceTextBox.KeyPress += new KeyPressEventHandler(sliceTextBox_KeyPress);
            sliceTextBox.KeyDown += new KeyEventHandler(sliceTextBox_KeyDown);
            zoomKaraokeTrackBar.ValueChanged += new EventHandler(zoomKaraokeTrackBar_ValueChanged);
            KaraokeAudioBox.MouseMove += new MouseEventHandler(KaraokeAudioBox_MouseMove);
            KaraokeAudioBox.MouseDown += new MouseEventHandler(KaraokeAudioBox_MouseDown);
            KaraokeAudioBox.MouseUp += new MouseEventHandler(KaraokeAudioBox_MouseUp);
            KaraokeAudioBox.MouseClick += new MouseEventHandler(KaraokeAudioBox_MouseClick);
            KaraokeAudioBox.KeyDown += new KeyPictureBox.OnKeyPress(KaraokeAudioBox_KeyDown);
            KaraokeAudioBox.LostFocus += new EventHandler(KaraokeAudioBox_LostFocus);

            AudioActualPosition_Refresh.Tick += new EventHandler(AudioActualPosition_Refresh_Tick);

            //this.Width = 800;
        }
Example #3
0
 public AVStoDirectSound(System.Windows.Forms.Control form, AviSynthClip avs)
 {
     PreparaAudio(form);
     this.avs = avs;
     max_vol = 0;
     min_vol = 999999999;
 }
Example #4
0
 public T_LoadFullAudio(AviSynthClip a, AVStoDirectSound a2, IntPtr p, mainW m)
 {
     avs = a;
     avs2ds = a2;
     puntero = p;
     mw = m;
 }
Example #5
0
        public cropW(avsW aW, AviSynthClip clip)
        {
            InitializeComponent();
            this.aW = aW;
            this.clip = clip;

            this.Disposed += new EventHandler(cropW_Disposed);

            VideoBox.MouseDown += new MouseEventHandler(VideoBox_MouseDown);
            VideoBox.MouseUp += new MouseEventHandler(VideoBox_MouseUp);
            VideoBox.MouseMove += new MouseEventHandler(VideoBox_MouseMove);

            Izquierda.TextChanged += new EventHandler(TxtChange);
            Derecha.TextChanged += new EventHandler(TxtChange);
            Arriba.TextChanged += new EventHandler(TxtChange);
            Abajo.TextChanged += new EventHandler(TxtChange);

            FrameActual.KeyPress += new KeyPressEventHandler(FrameActual_KeyPress);
        }
Example #6
0
        public static string getVSFilterPath(AviSynthClip avs)
        {
            // opcion 1: está ya cargado

            if (avs.FuncExists(avs.GetAVS(), "TextSub")) return null;

            // opción 2: cargamos el que está en el registro
            try
            {
                RegistryKey r = RegistryKey.OpenRemoteBaseKey(RegistryHive.ClassesRoot, "");
                RegistryKey vsf = r.OpenSubKey(@"CLSID\{9852A670-F845-491B-9BE6-EBD841B8A613}\InprocServer32");
                string res = (string)vsf.GetValue("");
                if (res.ToLower().EndsWith("vsfilter.dll")) return res;
            }
            catch { }

            // opción 3: cargamos en que tenemos en nuestro directorio

            if (File.Exists(Path.Combine(Application.StartupPath,"VSFilter.dll")))
                return Path.Combine(Application.StartupPath, "VSFilter.dll");

            throw new AviSynthException("No se ha podido cargar el VSFilter.dll");
            //return null;
        }
Example #7
0
 public static void LoadAviSynthPlugin(AviSynthClip theclip,string funcname, string dllname)
 {
     if (theclip.FuncExists(theclip.GetAVS(), funcname)) return;
     if (File.Exists(dllname))
         theclip.AviSynthInvoke(theclip.GetAVS(), 0, "LoadPlugin", false, dllname);
 }
Example #8
0
        private void updateFromAviSynthClip(AviSynthClip avs)
        {
            trackBar.Visible = true;
            label3.Visible = true;
            label4.Visible = true;
            ActualFrame.Visible = true;
            TotalFrames.Visible = true;
            mas1.Visible = true;
            menos1.Visible = true;

            ActualFrame.Text = "0";
            TotalFrames.Text = avs.num_frames.ToString();
            trackBar.Value = 0;
            trackBar.Maximum = avs.num_frames;
        }
Example #9
0
        private void showPreview()
        {
            if (listBox1.SelectedIndex == -1)
            {
                mW.errorMsg("No se puede hacer preview si no hay un estilo seleccionado.");
                return;
            }

            if (!checkBox1.Checked) return;

            try
            {
                env = new AviSynthScriptEnvironment();
                string script0rz = "blankclip(color=$"+PreviewBackColor+")";
                avs = env.ParseScript(script0rz);

                string vsf_path = AviSynthFunctions.getVSFilterPath(avs);
                if (vsf_path != null)
                    avs.AviSynthInvoke(avs.GetAVS(),0, "LoadPlugin", false, vsf_path);

                makeTempFile();
                avs.AviSynthInvoke(avs.GetAVS(), 0, "Eval", false, script0rz);
                avs.AviSynthInvoke(avs.GetAVS(),0, "TextSub", true, PreviewFile);
                Bitmap b = AviSynthFunctions.getBitmapFromFrame(avs,0,0);
                b = BitmapFunctions.Crop(b, 640, 480, 0, 376);
                stylePreviewBox.Image = b;
            }
            catch {
                mW.errorMsg("Error cargando AviSynth.");
                checkBox1.Checked = false;
            }
        }
Example #10
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox1.Checked)
     {
         stylePreviewBox.Visible=true;
         showPreview();
     } else {
         stylePreviewBox.Visible=false;
         avs=null;
         env=null;
     }
 }
Example #11
0
        private void unmanagedMemoryAudioLoad(AviSynthClip avs, AVStoDirectSound avs2ds)
        {
            AudioLoad_Progress = new progress2W(this);
            AudioLoad_Progress.Show();
            AudioLoad_Progress.Focus();

            AudioBytesMax = (int)avs.SamplesCount * avs.ChannelsCount * avs.BytesPerSample;
            AudioLoad_Progress.progressBar.Maximum = AudioBytesMax;

            try
            {
                mainW.AudioLoad_isCancelled = false;
                AudioFull = Marshal.AllocHGlobal(AudioBytesMax);
                T_LoadFullAudio load = new T_LoadFullAudio(avs, avs2ds, AudioFull, this);
                AudioLoad = new Thread(new ThreadStart(load.LoadAudio));
                AudioLoad.Priority = ThreadPriority.Lowest;

                progressBarUpdater.Interval = 2000;
                progressBarUpdater.Tick += new EventHandler(progressBarUpdater_Tick);
                AudioLoad.Start();
                progressBarUpdater.Enabled = true;

            }
            catch (OutOfMemoryException)
            {
                errorMsg("No hay suficiente memoria RAM disponible. Operación cancelada.");
                mainW.AudioLoad_isCancelled = true;
            }
        }
Example #12
0
 private AviSynthClip LoadAudioWithDependencies(AviSynthClip avsc, string filename)
 {
     OpenAudioSourceType = GetAudioSourceFilter(filename);
     AviSynthScriptEnvironment env = new AviSynthScriptEnvironment();
     avsc = env.ParseScript("BlankClip");
     switch (OpenAudioSourceType)
     {
         case AudioSourceType.DirectShowSource:
             avsc.AviSynthInvoke(avsc.GetAVS(), 0, "LoadPlugin", false, System.IO.Path.Combine(Application.StartupPath, "DirectShowSource.dll"));
             break;
         case AudioSourceType.FFAudioSource:
             avsc.AviSynthInvoke(avsc.GetAVS(), 0, "LoadPlugin", false, System.IO.Path.Combine(Application.StartupPath, "ffms2.dll"));
             break;
         default:
             break;
     }
     avsc.AviSynthInvoke(avsc.GetAVS(), 0, OpenAudioSourceType.ToString(), false, filename);
     avsc.AviSynthInvoke(avsc.GetAVS(), 0, "killvideo", false, "Nulo");
     return avsc;
 }
Example #13
0
        private void LoadAudioFromFile(string fileName)
        {
            try
            {
                setStatus("Creando el entorno AviSynth para el audio. Esta operación puede tardar unos segundos dependiendo del filtro de mayor prioridad definido en las opciones.");
                avsaudio = LoadAudioWithDependencies(avsaudio, fileName);

                setStatus("Audio cargado con " + OpenAudioSourceType.ToString());

                isAudioLoaded = true;
                //panelAudioBox.Visible = true;
                loadAudio();
                updateMenuEnables();
                putRecentAUD();
                updateConcatenateConfigFile("LastAUD", fileName);
                script.GetHeader().SetHeaderValue("Audio File", fileName);
            }
            catch (Exception x)
            {
                errorMsg("Ha habido un error intentando cargar el audio '" + fileName + "'\nMensaje: " + x.Message);
                isAudioLoaded = false;
                panelAudioBox.Visible = false;
                this.Enabled = true;
            }
            //drawPositions();
        }
Example #14
0
 private void InitAviSynth(out AviSynthScriptEnvironment env, out AviSynthClip avs)
 {
     env = new AviSynthScriptEnvironment();
     avs = env.ParseScript("blankclip(color=$000000,width=" + width + ",height=" + height + ")");
     string vsf_path = AviSynthFunctions.getVSFilterPath(avs);
     if (vsf_path != null)
         avs.AviSynthInvoke(avs.GetAVS(), 0, "LoadPlugin", false, vsf_path);
 }
Example #15
0
        private int CalcularLineas(AviSynthClip avs, string PreviewFile, lineaASS actual)
        {
            int nLineas;

            //lineaASS actual = (lineaASS)lass.Clone();

            TextWriter o = new StreamWriter(PreviewFile, false, System.Text.Encoding.UTF8);
            o.WriteLine(headerMark);
            o.WriteLine(script.GetHeader().ToString());

            o.WriteLine(stylesMark);
            foreach (estiloV4 e2 in script.GetStyles())
            {
                if (e2.Name.Equals(actual.estilo))
                {
                    estiloV4 new_est = new estiloV4(e2.ToString());
                    new_est.PrimaryColor = "&H00FFFFFF";
                    new_est.SecondaryColor = "&H00FFFFFF";
                    new_est.OutlineColor = "&H00FFFFFF";
                    new_est.ShadowColor = "&H00FFFFFF";
                    o.WriteLine(new_est.ToString().Replace("\n", string.Empty));
                }
            }

            o.WriteLine(); // ---

            o.WriteLine(dialoguesMark);

            actual.t_inicial.setTiempo(0);
            actual.t_final.setTiempo(50);
            o.WriteLine(actual.ToString());

            o.Close();

            avs.AviSynthInvoke(avs.GetAVS(), 0, "Eval", false, "blankclip(color=$000000,width=" + width + ",height=" + height + ")");
            avs.AviSynthInvoke(avs.GetAVS(), 0, "TextSub", true, PreviewFile);

            Image iimg = (Image)AviSynthFunctions.getBitmapFromFrame(avs, 0, 0);

            int x,y,x2,y2;

            nLineas = ContarLineas(iimg, out x, out y, out x2, out y2);

            iimg.Dispose();

            File.Delete(PreviewFile);
            return nLineas;
        }
Example #16
0
        private void openAVS(string fname)
        {
            videoPictureBox.Visible = true;
            if (VideoBoxType == PreviewType.DirectShow)
            {
                VideoBoxType = PreviewType.AviSynth;

                videoWindow.put_Visible(DirectShowLib.OABool.False);

                setStatus("Cargando modo AviSynth. Dependiendo de los filtros, puede tardar unos segundos...");
                try
                {
                    OpenSourceType = GetVideoSourceFilter(fname);
                    OpenAudioSourceType = HasAudio(fname) ? GetAudioSourceFilter(fname) : AudioSourceType.None;

                    if (avsClip != null) avsClip.cleanup(true);
                    if (avsaudio != null) avsaudio.cleanup(true);

                }
                catch (AviSynthException x)
                {
                    errorMsg("No se puede entrar en el modo AviSynth.\nMensaje de error : " + x.Message);
                    VideoBoxType = PreviewType.DirectShow;
                    videoWindow.put_Visible(DirectShowLib.OABool.True);
                    return;
                }

                try
                {
                    avsEnv = new AviSynthScriptEnvironment();
                    avsClip = avsEnv.ParseScript("BlankClip");
                    avsaudio = avsEnv.ParseScript("BlankClip");

                    string vsf = AviSynthFunctions.getVSFilterPath(avsClip);
                    if (vsf != null)
                        avsClip.AviSynthInvoke(avsClip.GetAVS(), 0, "LoadPlugin", false, vsf);

                    switch (OpenSourceType)
                    {
                        case VideoSourceType.FFVideoSource:
                            avsClip.AviSynthInvoke(avsClip.GetAVS(), 0, "LoadPlugin", false, Path.Combine(Application.StartupPath, "ffms2.dll"));
                            break;
                        case VideoSourceType.DirectShowSource:
                            avsClip.AviSynthInvoke(avsClip.GetAVS(), 0, "LoadPlugin", false, Path.Combine(Application.StartupPath, "DirectShowSource.dll"));
                            break;
                        case VideoSourceType.DSS2:
                            avsClip.AviSynthInvoke(avsClip.GetAVS(), 0, "LoadPlugin", false, Path.Combine(Application.StartupPath, "avss.dll"));
                            break;
                    }

                    avsClip.AviSynthInvoke(avsClip.GetAVS(), 0, OpenSourceType.ToString(), false, fname);
                    avsClip.AviSynthInvoke(avsClip.GetAVS(), 0, "killaudio", false, "Nulo");
                    avsClip.AviSynthInvoke(avsClip.GetAVS(), 0, "converttorgb32", false, "Nulo");

                    avsClip.AviSynthInvoke(avsClip.GetAVS(), 1, OpenSourceType.ToString(), false, fname);
                    avsClip.AviSynthInvoke(avsClip.GetAVS(), 1, "killaudio", false, "Nulo");
                    avsClip.AviSynthInvoke(avsClip.GetAVS(), 1, "converttorgb32", false, "Nulo");

                    try
                    {
                        if (OpenAudioSourceType != AudioSourceType.None)
                        {
                            switch (OpenAudioSourceType)
                            {
                                case AudioSourceType.FFAudioSource:
                                    avsaudio.AviSynthInvoke(avsaudio.GetAVS(), 0, "LoadPlugin", false, Path.Combine(Application.StartupPath, "ffms2.dll"));
                                    break;
                                case AudioSourceType.DirectShowSource:
                                    avsaudio.AviSynthInvoke(avsaudio.GetAVS(), 0, "LoadPlugin", false, Path.Combine(Application.StartupPath, "DirectShowSource.dll"));
                                    break;
                            }

                            avsaudio.AviSynthInvoke(avsaudio.GetAVS(), 0, OpenAudioSourceType.ToString(), false, fname);
                            avsaudio.AviSynthInvoke(avsaudio.GetAVS(), 0, "killvideo", false, "Nulo");
                        }
                    }
                    catch { }

                    updatePreviewAVS();

                }
                catch (AviSynthException x)
                {
                    errorMsg("No se puede entrar en el modo AviSynth. Comprueba que tienes instalado el AviSynth, que tienes registrado el VSFilter.dll (o mételo en la carpeta \\plugins del directorio de AviSynth), y que no intentas abrir nada raro.\nMensaje de error : " + x.Message);
                    return;
                }
                isVideoLoaded = true;
                butClip.Enabled = true;

                updateMenuEnables();

                videoInfo.Resolution = new Size(avsClip.VideoWidth, avsClip.VideoHeight);
                videoInfo.FrameTotal = avsClip.num_frames;

                setStatus("Vídeo " + fname + " cargado. [AviSynth (V: " + OpenSourceType.ToString() + ", A:" + OpenAudioSourceType.ToString() + ")]");
                script.GetHeader().SetHeaderValue("Video File", fname);

                if (isKeyframeGuessNeeded())
                    KeyframeGuess(false);
            }
        }