예제 #1
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;
         }
     }
 }
예제 #2
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();
        }
예제 #3
0
        public void CreatePictures(string output)
        {
            if (_cancelFlag)
            {
                return;
            }

            string tn  = output.Substring(0, output.LastIndexOf(".")) + "-tn.png";
            string cde = "-ss 00:00:01 -i \"" + FileFullPath + "\"" + ParamI + " -vframes 1 -an" + ParamFilter + ParamOW + " \"" + output + "\"";

            SendLog("\r\nffmpeg " + cde);
            SendLog("------------------------------------------------------------");
            ProcessStartInfo psi = new ProcessStartInfo(Common.ffmpeg, cde);

            psi.UseShellExecute       = false;
            psi.CreateNoWindow        = true;
            psi.RedirectStandardError = true;
            using (Process p = new Process()) {
                p.StartInfo = psi;
                p.Start();
                string line;
                while ((line = p.StandardError.ReadLine()) != null)
                {
                    SendLog(line);
                    Application.DoEvents();
                }
                p.WaitForExit();
            }

            if (Thumbnail)
            {
                using (Image org = Image.FromFile(output)) {
                    Bitmap   bmp = new Bitmap(TnWidth, TnHeight);
                    Graphics g   = Graphics.FromImage(bmp);
                    g.DrawImage(org, new Rectangle(0, 0, TnWidth, TnHeight));

                    if (LengthOnTn)
                    {
                        try {
                            MediaInfo mi = MediaInfo.Query(string.IsNullOrWhiteSpace(_outputForLength) ? FileFullPath : _outputForLength);
                            g.FillRectangle(Brushes.MidnightBlue, new Rectangle(5, 5, 45, 20));
                            g.DrawRectangle(Pens.Black, new Rectangle(5, 5, 45, 20));
                            using (Font f = new Font("Arial", 8, FontStyle.Bold))
                                g.DrawString(
                                    string.Format("{0:g}", new TimeSpan(0, 0, (int)Math.Round(mi.FormatInfo.duration))),
                                    f, new SolidBrush(Color.White),
                                    8,
                                    8
                                    );
                        } catch (Exception ex) {
                            SendLog(ex.Message);
                            SendLog(ex.StackTrace);
                        }
                    }
                    bmp.Save(tn, ImageFormat.Png);
                }
            }
            if (!Poster)
            {
                File.Delete(output);
            }
        }