private void buttonSaveAs_Click(object sender, EventArgs e)
        {
            if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count)
            {
                SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex];
            }
            else
            {
                SelectedLanguageString = null;
            }

            var subs = new List <VobSubMergedPack>();

            foreach (var x in listBox1.Items)
            {
                subs.Add((x as SubListBoxItem).SubPack);
            }

            using (var formSubOcr = new VobSubOcr())
            {
                formSubOcr.InitializeQuick(subs, _palette, Configuration.Settings.VobSubOcr, SelectedLanguageString);
                var subtitle = formSubOcr.ReadyVobSubRip();

                using (var exportBdnXmlPng = new ExportPngXml())
                {
                    exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Core.SubtitleFormats.SubRip(), "VOBSUB", "DVD", formSubOcr, SelectedLanguageString);
                    exportBdnXmlPng.ShowDialog(this);
                }
            }
        }
        private void ExportTo(string exportType)
        {
            var subtitles = GetSelectedSubtitles();

            if (subtitles == null)
            {
                return;
            }

            using (var formSubOcr = new VobSubOcr())
            {
                formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, _fileName);
                using (var exportBdnXmlPng = new ExportPngXml())
                {
                    exportBdnXmlPng.InitializeFromVobSubOcr(formSubOcr.SubtitleFromOcr, new SubRip(), exportType, _fileName, formSubOcr, null);
                    exportBdnXmlPng.ShowDialog(this);
                }
            }
        }
        private void buttonSaveAs_Click(object sender, EventArgs e)
        {
            var subtitles = GetSelectedSubtitles();

            if (subtitles == null)
            {
                return;
            }

            using (var formSubOcr = new VobSubOcr())
            {
                formSubOcr.Initialize(subtitles, Configuration.Settings.VobSubOcr, _fileName);
                var subtitle = formSubOcr.ReadyVobSubRip();
                using (var exportBdnXmlPng = new ExportPngXml())
                {
                    exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Core.SubtitleFormats.SubRip(), ExportPngXml.ExportFormats.BluraySup, _fileName, formSubOcr, null);
                    exportBdnXmlPng.ShowDialog(this);
                }
            }
        }
Example #4
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            radioButtonBluRaySup.Enabled = false;
            buttonStart.Enabled          = false;

            var cdgToImageList = new CdgToImageList();
            int total          = (int)Math.Round(_cdgGraphics.DurationInMilliseconds / CdgGraphics.TimeMsFactor);

            var bw = new BackgroundWorker {
                WorkerReportsProgress = true
            };

            bw.DoWork += (o, args) =>
            {
                _imageList = cdgToImageList.MakeImageList(_cdgGraphics, _subtitle, (number, unique) =>
                {
                    bw.ReportProgress(number, unique);
                });
            };
            bw.RunWorkerCompleted += (o, args) =>
            {
                using (var exportBdnXmlPng = new ExportPngXml())
                {
                    var old = Configuration.Settings.Tools.ExportBluRayRemoveSmallGaps;
                    Configuration.Settings.Tools.ExportBluRayRemoveSmallGaps = false; // Hm, not really sure if a 'true' is needed here - seems to give a small blink once in a while!?
                    exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), ExportPngXml.ExportFormats.BluraySup, FileName, this, "Test123");
                    exportBdnXmlPng.ShowDialog(this);
                    Configuration.Settings.Tools.ExportBluRayRemoveSmallGaps = old;
                    DialogResult = DialogResult.OK;
                }
            };
            bw.ProgressChanged += (o, args) =>
            {
                labelProgress.Text = $"Frame {args.ProgressPercentage:#,###,##0} of {total:#,###,##0}";
                labelProgress.Refresh();
                labelProgress2.Text = $"Unique images {(int)args.UserState:#,###,##0}";
                labelProgress2.Refresh();
            };
            bw.RunWorkerAsync();
        }
        private void buttonSaveAs_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count > -1)
            {
                if (_languages != null && comboBoxLanguages.SelectedIndex >= 0 && comboBoxLanguages.SelectedIndex < _languages.Count)
                    SelectedLanguageString = _languages[comboBoxLanguages.SelectedIndex];
                else
                    SelectedLanguageString = null;

                var subs = new List<VobSubMergedPack>();
                foreach (var x in listBox1.Items)
                {
                    subs.Add((x as SubListBoxItem).SubPack);
                }

                var formSubOcr = new VobSubOcr();
                formSubOcr.InitializeQuick(subs, _palette, Configuration.Settings.VobSubOcr, SelectedLanguageString);
                var subtitle = formSubOcr.ReadyVobSubRip();
                var exportBdnXmlPng = new ExportPngXml();
                exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Nikse.SubtitleEdit.Logic.SubtitleFormats.SubRip(), "VOBSUB", "DVD", formSubOcr, SelectedLanguageString);
                exportBdnXmlPng.ShowDialog(this);
            }

        }
Example #6
0
 private void vobSubToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var exportBdnXmlPng = new ExportPngXml())
     {
         _fromMenuItem = true;
         exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "VOBSUB", FileName, this, _importLanguageString);
         exportBdnXmlPng.ShowDialog(this);
         _fromMenuItem = false;
     }
 }
Example #7
0
 private void dOSTToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var exportBdnXmlPng = new ExportPngXml();
     exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "DOST", FileName, this, _importLanguageString);
     exportBdnXmlPng.ShowDialog(this);
 }
Example #8
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            var finalMkv = string.Empty;

            if (radioButtonVideo.Checked)
            {
                if (string.IsNullOrEmpty(_audioFileName) || !File.Exists(_audioFileName))
                {
                    MessageBox.Show("Please select an audio file!");
                    return;
                }

                if (_originalBackgroundImage == null)
                {
                    MessageBox.Show("Please select a background image file!");
                    return;
                }

                if (Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(textBoxFFmpegPath.Text) || !File.Exists(textBoxFFmpegPath.Text)))
                {
                    MessageBox.Show("mkvmerge.exe not found!");
                    return;
                }

                if (Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) || !File.Exists(Configuration.Settings.General.FFmpegLocation)))
                {
                    MessageBox.Show("ffmpeg not configured!");
                    return;
                }

                saveFileDialog1.Filter   = "Matroska (*.mkv)|*.mkv";
                saveFileDialog1.FileName = FileName.Substring(0, FileName.Length - 3) + "mkv";
                if (saveFileDialog1.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                finalMkv = saveFileDialog1.FileName;
            }

            radioButtonBluRaySup.Enabled = false;
            radioButtonVideo.Enabled     = false;
            buttonStart.Enabled          = false;

            var cdgToImageList = new CdgToImageList();
            var bw             = new BackgroundWorker {
                WorkerReportsProgress = true
            };

            bw.DoWork             += (o, args) => { _imageList = cdgToImageList.MakeImageList(_cdgGraphics, _subtitle, (number, unique) => { bw.ReportProgress(number, unique); }); };
            bw.RunWorkerCompleted += (o, args) =>
            {
                if (radioButtonBluRaySup.Checked)
                {
                    using (var exportBdnXmlPng = new ExportPngXml())
                    {
                        exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), ExportPngXml.ExportFormats.BluraySup, FileName, this, "Test123");
                        exportBdnXmlPng.ShowDialog(this);
                    }
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    var tempFolder  = Path.GetTempPath();
                    var supFileName = Path.Combine(tempFolder, Guid.NewGuid() + ".sup");
                    using (var binarySubtitleFile = new FileStream(supFileName, FileMode.Create))
                    {
                        labelStatus.Text = "Generating Blu-ray sup file...";
                        labelStatus.Refresh();

                        var bottomMargin = comboBoxBottomMargin.SelectedIndex;
                        var leftMargin   = comboBoxLeftRightMargin.SelectedIndex;
                        for (var index = 0; index < _subtitle.Paragraphs.Count; index++)
                        {
                            var p     = _subtitle.Paragraphs[index];
                            var image = _imageList[index].GetBitmap();
                            var brSub = new BluRaySupPicture
                            {
                                StartTime         = (long)p.StartTime.TotalMilliseconds,
                                EndTime           = (long)p.EndTime.TotalMilliseconds,
                                Width             = VideoWidth,
                                Height            = VideoHeight,
                                CompositionNumber = p.Number * 2
                            };

                            var buffer = BluRaySupPicture.CreateSupFrame(brSub, image, 25, bottomMargin, leftMargin, ContentAlignment.BottomLeft);
                            binarySubtitleFile.Write(buffer, 0, buffer.Length);
                        }
                    }

                    if (!string.IsNullOrEmpty(supFileName) && File.Exists(supFileName))
                    {
                        labelStatus.Text = "Generating video...";
                        labelStatus.Refresh();
                        var tempImageFileName = Path.Combine(tempFolder, Guid.NewGuid() + ".png");
                        _resizedBackgroundImage.Save(tempImageFileName, ImageFormat.Png);
                        var tempMkv          = Path.Combine(tempFolder, Guid.NewGuid() + ".mkv");
                        var processMakeVideo = GetFFmpegProcess(tempImageFileName, _audioFileName, tempMkv);
                        processMakeVideo.Start();
                        processMakeVideo.WaitForExit();

                        labelStatus.Text = "Adding subtitles to video...";
                        labelStatus.Refresh();
                        var processAddSubtitles = GetMkvMergeProcess(tempMkv, supFileName, finalMkv);
                        processAddSubtitles.Start();
                        processAddSubtitles.WaitForExit();
                        labelStatus.Text = string.Empty;

                        UiUtil.OpenFolderFromFileName(finalMkv);

                        try
                        {
                            File.Delete(supFileName);
                            File.Delete(tempImageFileName);
                        }
                        catch
                        {
                            // ignore
                        }
                    }

                    DialogResult = DialogResult.OK;
                }
            };
            labelStatus.Text = "Extracting images...";
            labelStatus.Refresh();
            bw.RunWorkerAsync();
        }
Example #9
0
 private void bluraySupToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var exportBdnXmlPng = new ExportPngXml())
     {
         exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BLURAYSUP", FileName, this, _importLanguageString);
         exportBdnXmlPng.ShowDialog(this);
     }
 }
Example #10
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            radioButtonSrt.Enabled         = false;
            radioButtonSrtOnlyText.Enabled = false;
            radioButtonBluRaySup.Enabled   = false;
            radioButtonASS.Enabled         = false;

            NikseBitmap lastNBmp = null;
            int         count    = 0;
            int         total    = (int)Math.Round(_cdgGraphics.DurationInMilliseconds / CdgGraphics.TimeMsFactor);

            _imageList = new List <NikseBitmap>();
            _subtitle.Paragraphs.Clear();
            Paragraph p            = null;
            int       packetNumber = 0;
            var       max          = _cdgGraphics.NumberOfPackets;

            while (packetNumber < max)
            {
                using (var bmp = _cdgGraphics.ToBitmap(packetNumber))
                {
                    var nBmp   = new NikseBitmap(bmp);
                    var timeMs = packetNumber * CdgGraphics.TimeMsFactor;
                    if (lastNBmp == null)
                    {
                        if (nBmp.Width > 0)
                        {
                            lastNBmp = nBmp;
                            p        = new Paragraph(string.Empty, timeMs, timeMs);
                        }
                    }
                    else
                    {
                        if (!IsImagesTheSame(nBmp, lastNBmp))
                        {
                            if (lastNBmp.Width > 0)
                            {
                                p.EndTime.TotalMilliseconds = timeMs;
                                _subtitle.Paragraphs.Add(p);
                                _imageList.Add(lastNBmp);
                            }

                            if (nBmp.Width > 0)
                            {
                                p = new Paragraph(string.Empty, timeMs, timeMs);
                            }
                        }
                        lastNBmp = nBmp;
                    }
                }
                count++;
                packetNumber++;
                labelProgress.Text = $"Frame {count:#,###,##0} of {total:#,###,##0}";
                labelProgress.Refresh();
                labelProgress2.Text = $"Unique images {_imageList.Count:#,###,##0}";
                labelProgress2.Refresh();
            }

            _subtitle.Renumber();
            using (var exportBdnXmlPng = new ExportPngXml())
            {
                exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), ExportPngXml.ExportFormats.BluraySup, FileName, this, "Test123");
                //        exportBdnXmlPng.SetResolution(new Point(bmp.Width, bmp.Height));
                exportBdnXmlPng.ShowDialog(this);
            }
        }