Ejemplo n.º 1
0
 private void Delete3(object sender, EventArgs e)
 {
     _medias[2]   = null;
     lV3.Text     = I18n.Get("ConcatNoVideoStream");
     lA3.Text     = I18n.Get("ConcatNoAudioStream");
     tbFile3.Text = string.Empty;
 }
Ejemplo n.º 2
0
 private void Select3(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog()) {
         ofd.Filter = I18n.Get("FilterAllMedia");
         if (ofd.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         SetSelection(2, ofd.FileName);
     }
 }
Ejemplo n.º 3
0
 private void SelectFile(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog()) {
         ofd.Filter = I18n.Get("FilterAllMedia");
         if (ofd.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         try {
             _media      = MediaInfo.Query(ofd.FileName);
             tbFile.Text = ofd.FileName;
             if (_media.VideoInfo != null)
             {
                 EnableVideo();
                 lV.Text = I18n.Get("ConcatVideoStreamHeadDesc") +
                           _media.VideoInfo.codec_name + " - " +
                           _media.VideoInfo.width.ToString() + "x" + _media.VideoInfo.height.ToString() + " - " +
                           _media.VideoInfo.duration.ToString() + "s" +
                           (_media.VideoInfo.bit_rateSpecified ? " - Bitrate " + _media.VideoInfo.bit_rate.ToReadableString() : string.Empty);
             }
             else
             {
                 DisableVideo();
                 lV.Text = I18n.Get("ConcatNoVideoStream");
             }
             if (_media.AudioInfo != null)
             {
                 EnableAudio();
                 lA.Text = I18n.Get("ConcatAudioStreamHeadDesc") +
                           _media.AudioInfo.codec_name + " - " +
                           _media.AudioInfo.duration.ToString() + "s" +
                           (_media.AudioInfo.bit_rateSpecified ? " - Bitrate " + _media.AudioInfo.bit_rate.ToReadableString() : string.Empty) +
                           (_media.AudioInfo.sample_rateSpecified ? " - SampleRate " + _media.AudioInfo.sample_rate.ToReadableString() : string.Empty);
             }
             else
             {
                 DisableAudio();
                 lA.Text = I18n.Get("ConcatNoAudioStream");
             }
         } catch (CoreException cex) {
             MessageBox.Show(cex.Message);
             _media      = null;
             lV.Text     = I18n.Get("ConcatNoVideoStream");
             lA.Text     = I18n.Get("ConcatNoAudioStream");
             tbFile.Text = string.Empty;
         }
     }
 }
Ejemplo n.º 4
0
 public MediaInfo(string xml)
 {
     try {
         using (TextReader ms = new StringReader(xml)) {
             XmlSerializer xs = new XmlSerializer(typeof(ffprobeType));
             ffprobeType   ff = xs.Deserialize(ms) as ffprobeType;
             if (ff == null || ff.streams == null || ff.format == null)
             {
                 throw new CoreException(I18n.Get("ErrorInvalidFormat"));
             }
             if (ff.streams.Length > 2)
             {
                 throw new CoreException(I18n.Get("ErrorNoMore2Streams"));
             }
             FormatInfo = ff.format;
             foreach (streamType st in ff.streams)
             {
                 if ("video".Equals(st.codec_type))
                 {
                     if (VideoInfo != null)
                     {
                         throw new CoreException(I18n.Get("ErrorNoMore1Video"));
                     }
                     VideoInfo = st;
                 }
                 else
                 {
                     if (AudioInfo != null)
                     {
                         throw new CoreException(I18n.Get("ErrorNoMore1Audio"));
                     }
                     AudioInfo = st;
                 }
             }
         }
     } catch (Exception ex) {
         FormatInfo = null;
         VideoInfo  = null;
         AudioInfo  = null;
         ex.PreserveStackTrace();
         throw new CoreException(ex.Message, ex);
     }
 }
Ejemplo n.º 5
0
        public static MediaInfo Query(string file)
        {
            if (!File.Exists(file))
            {
                throw new CoreException(I18n.Get("ErrorFileNotExists"));
            }
            if (!File.Exists(Common.ffprobe))
            {
                throw new CoreException(I18n.Get("ErrorFfprobeNotFound"));
            }
            StringBuilder    xml = new StringBuilder();
            ProcessStartInfo psi = new ProcessStartInfo(Common.ffprobe, "-i \"" + file + "\" -v quiet -of xml -show_format -show_streams");

            psi.UseShellExecute        = false;
            psi.CreateNoWindow         = true;
            psi.RedirectStandardError  = true;
            psi.RedirectStandardOutput = true;
            using (Process p = new Process()) {
                p.StartInfo = psi;
                p.Start();
                string line;
                while ((line = p.StandardOutput.ReadLine()) != null)
                {
                    xml.AppendLine(line);
                    Application.DoEvents();
                }
                p.WaitForExit();
            }
            MediaInfo mi = new MediaInfo(xml.ToString());

            if (mi.FormatInfo == null)
            {
                throw new CoreException(I18n.Get("ErrorInvalidFormat"));
            }
            if (mi.AudioInfo == null && mi.VideoInfo == null)
            {
                throw new CoreException(I18n.Get("ErrorNoAudioVideo"));
            }

            return(mi);
        }
Ejemplo n.º 6
0
        public void EncodeMP3(string output)
        {
            if (_cancelFlag)
            {
                return;
            }

            _outputForLength = output;
            string cde = "-i \"" + FileFullPath + "\" -c:a mp3 -b:a " + MP3_ba + " -ar " + MP3_sr + " -vn" + ParamOffset + ParamOW + " \"" + output + "\"";

            SendLog("\r\nffmpeg " + cde);
            SendLog("------------------------------------------------------------");
            if (output.Equals(FileFullPath, StringComparison.CurrentCultureIgnoreCase))
            {
                SendLog(I18n.Get("ErrorSameInputOutput"));
            }
            else
            {
                ProcessStartInfo psi = new ProcessStartInfo(Common.ffmpeg, cde);
                psi.UseShellExecute       = false;
                psi.CreateNoWindow        = true;
                psi.RedirectStandardError = true;
                using (Process p = new Process()) {
                    _currentProcess = p;
                    p.StartInfo     = psi;
                    p.Start();
                    string line;
                    while ((line = p.StandardError.ReadLine()) != null)
                    {
                        SendLog(line);
                        Application.DoEvents();
                    }
                    p.WaitForExit();
                }
                _currentProcess = null;
            }
        }
Ejemplo n.º 7
0
        private void Validate(object sender, EventArgs e)
        {
            int tmp;

            if (gbVideo.Enabled)
            {
                // Vérification CRF
                if (tbCRF.Text.Length != 0)
                {
                    if (!int.TryParse(tbCRF.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        return;
                    }
                    if (tmp < Common.CRF_MIN || tmp > Common.CRF_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_CRF, tbCRF.Text);
                }

                // Vérification Qscale
                if (tbQscale.Text.Length != 0)
                {
                    if (!int.TryParse(tbQscale.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        return;
                    }
                    if (tmp < Common.QSCALE_MIN || tmp > Common.QSCALE_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_QSCALE, tbQscale.Text);
                }

                // Vérification Qmin
                int qmin = 4;
                if (tbQmin.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmin.Text, out qmin))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        return;
                    }
                    if (qmin < Common.QMIN_MIN || qmin > Common.QMIN_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_QMIN, tbQmin.Text);
                }

                // Vérification Qmax
                if (tbQmax.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmax.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        return;
                    }
                    if (tmp < qmin || tmp > Common.QMAX_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_QMAX, tbQmax.Text);
                }

                // Vérification Bitrate
                if (tbBV.Text.Length != 0)
                {
                    bool unit = tbBV.Text.EndsWith("k", StringComparison.CurrentCultureIgnoreCase) || tbBV.Text.EndsWith("m", StringComparison.CurrentCultureIgnoreCase);
                    if (!int.TryParse(unit ? tbBV.Text.Substring(0, tbBV.Text.Length - 1) : tbBV.Text, out tmp))
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        return;
                    }
                    if (tmp <= 0)
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        return;
                    }
                    _builder.Param(Parameter.V_BITRATE, tbBV.Text);
                }

                _builder.VideoCodec((VideoEncoding)cbCV.SelectedValue);
            }

            if (gbAudio.Enabled)
            {
                _builder.AudioCodec((AudioEncoding)cbCA.SelectedValue);
                BitrateMp3 br = (BitrateMp3)Enum.Parse(typeof(BitrateMp3), cbBA.SelectedValue.ToString());
                if (br != BitrateMp3.Defaut)
                {
                    _builder.Param(Parameter.A_BITRATE, ((int)br).ToString());
                }
                SamplingRate sr = (SamplingRate)Enum.Parse(typeof(SamplingRate), cbSR.SelectedValue.ToString());
                if (sr != SamplingRate.Defaut)
                {
                    _builder.Param(Parameter.A_SAMPLE, ((int)sr).ToString());
                }
            }

            _builder.Param(Parameter.NONE, cbFormat.SelectedValue.ToString());

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 8
0
        private void Validate(object sender, EventArgs e)
        {
            if (_media == null)
            {
                MessageBox.Show("Aucun fichier valable en entrée.");
                return;
            }

            if (tbOut.Text.Length == 0)
            {
                MessageBox.Show("Choisissez un fichier de sortie.");
                return;
            }

            if (tbFile.Text.Equals(tbOut.Text))
            {
                MessageBox.Show(I18n.Get("ErrorSameInputOutput"));
                return;
            }

            _builder = new CommandLineBuilder();
            _builder.AddEntry(tbFile.Text);

            int tmp;

            if (gbVideo.Enabled)
            {
                // Vérification CRF
                if (tbCRF.Text.Length != 0)
                {
                    if (!int.TryParse(tbCRF.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        _builder = null;
                        return;
                    }
                    if (tmp < Common.CRF_MIN || tmp > Common.CRF_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_CRF, tbCRF.Text);
                }

                // Vérification Qscale
                if (tbQscale.Text.Length != 0)
                {
                    if (!int.TryParse(tbQscale.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        _builder = null;
                        return;
                    }
                    if (tmp < Common.QSCALE_MIN || tmp > Common.QSCALE_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_QSCALE, tbQscale.Text);
                }

                // Vérification Qmin
                int qmin = 4;
                if (tbQmin.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmin.Text, out qmin))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        _builder = null;
                        return;
                    }
                    if (qmin < Common.QMIN_MIN || qmin > Common.QMIN_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_QMIN, tbQmin.Text);
                }

                // Vérification Qmax
                if (tbQmax.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmax.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        _builder = null;
                        return;
                    }
                    if (tmp < qmin || tmp > Common.QMAX_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_QMAX, tbQmax.Text);
                }

                // Vérification Bitrate
                if (tbBV.Text.Length != 0)
                {
                    bool unit = tbBV.Text.EndsWith("k", StringComparison.CurrentCultureIgnoreCase) || tbBV.Text.EndsWith("m", StringComparison.CurrentCultureIgnoreCase);
                    if (!int.TryParse(unit ? tbBV.Text.Substring(0, tbBV.Text.Length - 1) : tbBV.Text, out tmp))
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        _builder = null;
                        return;
                    }
                    if (tmp <= 0)
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_BITRATE, tbBV.Text);
                }

                _builder.VideoCodec((VideoEncoding)cbCV.SelectedValue);
            }
            else
            {
                _builder.VideoCodec(VideoEncoding.NOVIDEO);
            }

            if (gbAudio.Enabled)
            {
                _builder.AudioCodec((AudioEncoding)cbCA.SelectedValue);
                BitrateMp3 br = (BitrateMp3)Enum.Parse(typeof(BitrateMp3), cbBA.SelectedValue.ToString());
                if (br != BitrateMp3.Defaut)
                {
                    _builder.Param(Parameter.A_BITRATE, ((int)br).ToString());
                }
                SamplingRate sr = (SamplingRate)Enum.Parse(typeof(SamplingRate), cbSR.SelectedValue.ToString());
                if (sr != SamplingRate.Defaut)
                {
                    _builder.Param(Parameter.A_SAMPLE, ((int)sr).ToString());
                }
            }
            else
            {
                _builder.AudioCodec(AudioEncoding.NOAUDIO);
            }

            _builder.Param(Parameter.NONE, cbFormat.SelectedValue.ToString()).Param(Parameter.MISC_OVERWRITE_YES);

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 9
0
        private void SetSelection(int index, string file, TextBox tb, Label lbAudio, Label lbVideo)
        {
            try {
                _medias[index] = MediaInfo.Query(file);
                tb.Text        = file;
                if (_medias[index].VideoInfo != null)
                {
                    lbVideo.Text = I18n.Get("ConcatVideoStreamHeadDesc") +
                                   _medias[index].VideoInfo.codec_name + " - " +
                                   _medias[index].VideoInfo.width.ToString() + "x" + _medias[index].VideoInfo.height.ToString() + " - " +
                                   _medias[index].VideoInfo.duration.ToString() + "s" +
                                   (_medias[index].VideoInfo.bit_rateSpecified ? " - Bitrate " + _medias[index].VideoInfo.bit_rate.ToReadableString() : string.Empty);
                }
                else
                {
                    lbVideo.Text = I18n.Get("ConcatNoVideoStream");
                }
                if (_medias[index].AudioInfo != null)
                {
                    lbAudio.Text = I18n.Get("ConcatAudioStreamHeadDesc") +
                                   _medias[index].AudioInfo.codec_name + " - " +
                                   _medias[index].AudioInfo.duration.ToString() + "s" +
                                   (_medias[index].AudioInfo.bit_rateSpecified ? " - Bitrate " + _medias[index].AudioInfo.bit_rate.ToReadableString() : string.Empty) +
                                   (_medias[index].AudioInfo.sample_rateSpecified ? " - SampleRate " + _medias[index].AudioInfo.sample_rate.ToReadableString() : string.Empty);
                }
                else
                {
                    lbAudio.Text = I18n.Get("ConcatNoAudioStream");
                }
            } catch (CoreException cex) {
                MessageBox.Show(cex.Message);
                _medias[index] = null;
                lbVideo.Text   = I18n.Get("ConcatNoVideoStream");
                lbAudio.Text   = I18n.Get("ConcatNoAudioStream");
                tb.Text        = string.Empty;
            }

            if (_medias[0] != null)
            {
                if (_medias[0].VideoInfo != null && _medias[0].AudioInfo != null)
                {
                    Mode = ConcatMode.Both;
                }
                else if (_medias[0].VideoInfo != null)
                {
                    Mode = ConcatMode.Video;
                }
                else
                {
                    Mode = ConcatMode.Audio;
                }
            }
            else if (_medias[1] != null)
            {
                if (_medias[1].VideoInfo != null && _medias[1].AudioInfo != null)
                {
                    Mode = ConcatMode.Both;
                }
                else if (_medias[1].VideoInfo != null)
                {
                    Mode = ConcatMode.Video;
                }
                else
                {
                    Mode = ConcatMode.Audio;
                }
            }
            else if (_medias[2] != null)
            {
                if (_medias[2].VideoInfo != null && _medias[2].AudioInfo != null)
                {
                    Mode = ConcatMode.Both;
                }
                else if (_medias[2].VideoInfo != null)
                {
                    Mode = ConcatMode.Video;
                }
                else
                {
                    Mode = ConcatMode.Audio;
                }
            }
            else
            {
                Mode = ConcatMode.Undefined;
            }
            lblMode.Text = Mode.LongName();
        }
Ejemplo n.º 10
0
        private void Validate(object sender, EventArgs e)
        {
            if (_medias.Count(new Func <MediaInfo, bool>((MediaInfo mi) => { return(mi != null); })) < 2)
            {
                MessageBox.Show(I18n.Get("ConcatSelect2FilesMin"));
                return;
            }

            int           cnt     = 0;
            List <string> entries = new List <string>();

            string s = string.Empty;

            for (int i = 0; i < _medias.Length; i++)
            {
                if (_medias[i] != null)
                {
                    if (Mode == ConcatMode.Both || Mode == ConcatMode.Video)
                    {
                        // Présence du flux vidéo
                        if (_medias[i].VideoInfo == null)
                        {
                            MessageBox.Show(string.Format(I18n.Get("ConcatFileNoVideo"), i + 1));
                            return;
                        }
                        // Vérification de la taille
                        if (s.Length == 0)
                        {
                            s = string.Format("{0}x{1}", _medias[i].VideoInfo.width, _medias[i].VideoInfo.height);
                        }
                        else if (!s.Equals(string.Format("{0}x{1}", _medias[i].VideoInfo.width, _medias[i].VideoInfo.height)))
                        {
                            MessageBox.Show("ConcatVideoSameSize");
                            return;
                        }
                    }
                    if (Mode == ConcatMode.Both || Mode == ConcatMode.Audio)
                    {
                        // Présence du flux audio
                        if (_medias[i].AudioInfo == null)
                        {
                            MessageBox.Show(string.Format(I18n.Get("ConcatFileNoAudio"), i + 1));
                            return;
                        }
                    }
                    // Uniformité des types de flux
                    if (Mode == ConcatMode.Audio && _medias[i].VideoInfo != null)
                    {
                        MessageBox.Show(string.Format(I18n.Get("ConcatFileHasVideo"), i + 1));
                        return;
                    }
                    if (Mode == ConcatMode.Video && _medias[i].AudioInfo != null)
                    {
                        MessageBox.Show(string.Format(I18n.Get("ConcatFileHasAudio"), i + 1));
                        return;
                    }

                    // Arrivé ici le fichier est valide, on ajoute aux listes
                    if (Mode == ConcatMode.Both)
                    {
                        entries.Add(string.Format("[{0}:0] [{0}:1] ", cnt++));
                    }
                    else
                    {
                        entries.Add(string.Format("[{0}:0] ", cnt++));
                    }
                }
            }

            // Ajout des entrées
            if (tbFile1.Text.Length > 0)
            {
                Builder.AddEntry(tbFile1.Text);
            }
            if (tbFile2.Text.Length > 0)
            {
                Builder.AddEntry(tbFile2.Text);
            }
            if (tbFile3.Text.Length > 0)
            {
                Builder.AddEntry(tbFile3.Text);
            }

            // Parametrage du concat
            Builder.FilterComplex.Concat(entries, Mode == ConcatMode.Both || Mode == ConcatMode.Video, Mode == ConcatMode.Both || Mode == ConcatMode.Audio, string.Empty)
            .Param(Parameter.MISC_OVERWRITE_YES);

            this.DialogResult = DialogResult.OK;
        }
Ejemplo n.º 11
0
 public static string LongName(this ConcatMode value)
 {
     return(I18n.Get("ConcatMode." + Enum.GetName(typeof(ConcatMode), value) + ".LongName"));
 }
Ejemplo n.º 12
0
        public void EncodeMP4(string output)
        {
            if (_cancelFlag)
            {
                return;
            }

            _outputForLength = output;
            CommandLineBuilder cb = new CommandLineBuilder();

            if (StartOffset != TimeSpan.Zero)
            {
                cb.Seek(string.Format("{0:c}", StartOffset));
            }

            cb.AddEntry(FileFullPath);

            for (int i = 0; i < Overlays.Length; i++)
            {
                if (Overlays[i].Item1 >= 0 && !string.IsNullOrWhiteSpace(Overlays[i].Item2))
                {
                    cb.AddEntry(Overlays[i].Item2);
                }
            }
            if (EndOffset != TimeSpan.Zero)
            {
                cb.To(string.Format("{0:c}", EndOffset - StartOffset));
            }

            if (!string.IsNullOrWhiteSpace(ResizeHeight) || !string.IsNullOrWhiteSpace(ResizeWidth))
            {
                cb.FilterComplex.Resize(ResizeWidth, ResizeHeight);
            }
            if (Rotate < 4)
            {
                cb.FilterComplex.Transpose((Transpose)Rotate);
            }
            int j = 1;

            for (int i = 0; i < Overlays.Length; i++)
            {
                if (Overlays[i].Item1 >= 0 && !string.IsNullOrWhiteSpace(Overlays[i].Item2))
                {
                    cb.FilterComplex.Overlay((Overlay)Overlays[i].Item1, string.Format("[{0}]", j++));
                }
            }

            cb.VideoCodec(VideoEncoding.X264).Param(Parameter.V_BITRATE, MP4_bv);

            if (NoSound)
            {
                cb.AudioCodec(AudioEncoding.NOAUDIO);
            }
            else
            {
                cb.AudioCodec(AudioEncoding.AAC).Param(Parameter.A_BITRATE, MP4_ba);
            }

            if (Overwrite)
            {
                cb.Param(Parameter.MISC_OVERWRITE_YES);
            }
            else
            {
                cb.Param(Parameter.MISC_OVERWRITE_NO);
            }

            string cde = cb.Output(output);

            SendLog("\r\nffmpeg " + cde);
            SendLog("------------------------------------------------------------");
            if (output.Equals(FileFullPath, StringComparison.CurrentCultureIgnoreCase))
            {
                SendLog(I18n.Get("ErrorSameInputOutput"));
            }
            else
            {
                ProcessStartInfo psi = new ProcessStartInfo(Common.ffmpeg, cde);
                psi.UseShellExecute       = false;
                psi.CreateNoWindow        = true;
                psi.RedirectStandardError = true;
                using (Process p = new Process()) {
                    _currentProcess = p;
                    p.StartInfo     = psi;
                    p.Start();
                    string line;
                    while ((line = p.StandardError.ReadLine()) != null)
                    {
                        SendLog(line);
                        Application.DoEvents();
                    }
                    p.WaitForExit();
                }
                _currentProcess = null;
            }
        }
Ejemplo n.º 13
0
        public void Execute()
        {
            if (_cancelFlag)
            {
                return;
            }

            // Paths check
            if (string.IsNullOrWhiteSpace(FileFullPath) || !File.Exists(FileFullPath))
            {
                SendLog("NOT EXISTS " + FileFullPath);
                return;
            }
            string folder = FileFullPath.Substring(0, FileFullPath.LastIndexOf('\\'));

            if (!CanWriteDirectory(folder))
            {
                SendLog("READONLY " + folder);
                return;
            }

            if (!File.Exists(Common.ffmpeg))
            {
                SendLog(I18n.Get("ErrorFfmpegNotFound"));
                return;
            }
            if (!File.Exists(Common.ffprobe))
            {
                SendLog(I18n.Get("ErrorFfprobeNotFound"));
                return;
            }

            // Extension check
            switch (Path.GetExtension(FileFullPath))
            {
            case ".avi":
            case ".mp4":
            case ".webm":
            case ".ogv":
            case ".mp3":
            case ".flv":
            case ".3gp":
                break;

            default:
                Log("NOT VIDEO " + FileFullPath);
                return;
            }

            string cleanFileName = "_enc_" + (WebChar ? GetCleanFileName(Path.GetFileNameWithoutExtension(FileFullPath)) : Path.GetFileNameWithoutExtension(FileFullPath));

            Log("############################################################");
            Log(FileFullPath);
            Log("############################################################");

            if (MP4)
            {
                EncodeMP4(Path.Combine(folder, cleanFileName + ".mp4"));
            }

            if (FLV)
            {
                EncodeFLV(Path.Combine(folder, cleanFileName + ".flv"));
            }

            if (WEBM)
            {
                EncodeWEBM(Path.Combine(folder, cleanFileName + ".webm"));
            }

            if (MP3)
            {
                EncodeMP3(Path.Combine(folder, cleanFileName + ".mp3"));
            }

            if (Poster || Thumbnail)
            {
                CreatePictures(Path.Combine(folder, cleanFileName + ".png"));
            }

            if (Json)
            {
                CreateJSON(Path.Combine(folder, cleanFileName + ".desc"));
            }
        }