mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
work on cdg
This commit is contained in:
parent
4353ba4a4c
commit
84e12b350e
@ -50,6 +50,13 @@ namespace Nikse.SubtitleEdit.Core.CDG
|
||||
p = new Paragraph(string.Empty, timeMs, timeMs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p != null)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = timeMs;
|
||||
}
|
||||
}
|
||||
lastNBmp = nBmp;
|
||||
}
|
||||
}
|
||||
|
@ -249,6 +249,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public int ExportBluRayBottomMarginPixels { get; set; }
|
||||
public int ExportBluRayShadow { get; set; }
|
||||
public bool ExportBluRayRemoveSmallGaps { get; set; }
|
||||
public string ExportCdgBackgroundImage { get; set; }
|
||||
public int Export3DType { get; set; }
|
||||
public int Export3DDepth { get; set; }
|
||||
public int ExportLastShadowTransparency { get; set; }
|
||||
@ -4262,6 +4263,12 @@ $HorzAlign = Center
|
||||
settings.Tools.ExportBluRayRemoveSmallGaps = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("ExportCdgBackgroundImage");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.ExportCdgBackgroundImage = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("Export3DType");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -7758,6 +7765,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("ExportBluRayBottomMarginPixels", settings.Tools.ExportBluRayBottomMarginPixels.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ExportBluRayShadow", settings.Tools.ExportBluRayShadow.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ExportBluRayRemoveSmallGaps", settings.Tools.ExportBluRayRemoveSmallGaps.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ExportCdgBackgroundImage", settings.Tools.ExportCdgBackgroundImage);
|
||||
textWriter.WriteElementString("Export3DType", settings.Tools.Export3DType.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("Export3DDepth", settings.Tools.Export3DDepth.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ExportLastShadowTransparency", settings.Tools.ExportLastShadowTransparency.ToString(CultureInfo.InvariantCulture));
|
||||
|
35
src/Forms/ImportCdg.Designer.cs
generated
35
src/Forms/ImportCdg.Designer.cs
generated
@ -40,6 +40,8 @@
|
||||
this.labelBackgroundImage = new System.Windows.Forms.Label();
|
||||
this.pictureBoxBackgroundImage = new System.Windows.Forms.PictureBox();
|
||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
this.labelAudioFileName = new System.Windows.Forms.Label();
|
||||
this.buttonAudioFileBrowse = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBackgroundImage)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -54,7 +56,7 @@
|
||||
//
|
||||
// buttonStart
|
||||
//
|
||||
this.buttonStart.Location = new System.Drawing.Point(15, 135);
|
||||
this.buttonStart.Location = new System.Drawing.Point(15, 146);
|
||||
this.buttonStart.Name = "buttonStart";
|
||||
this.buttonStart.Size = new System.Drawing.Size(154, 32);
|
||||
this.buttonStart.TabIndex = 4;
|
||||
@ -85,7 +87,7 @@
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 76);
|
||||
this.label1.Location = new System.Drawing.Point(12, 87);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(70, 13);
|
||||
this.label1.TabIndex = 9;
|
||||
@ -94,7 +96,7 @@
|
||||
// labelProgress
|
||||
//
|
||||
this.labelProgress.AutoSize = true;
|
||||
this.labelProgress.Location = new System.Drawing.Point(15, 170);
|
||||
this.labelProgress.Location = new System.Drawing.Point(15, 181);
|
||||
this.labelProgress.Name = "labelProgress";
|
||||
this.labelProgress.Size = new System.Drawing.Size(70, 13);
|
||||
this.labelProgress.TabIndex = 11;
|
||||
@ -104,7 +106,7 @@
|
||||
//
|
||||
this.radioButtonBluRaySup.AutoSize = true;
|
||||
this.radioButtonBluRaySup.Checked = true;
|
||||
this.radioButtonBluRaySup.Location = new System.Drawing.Point(29, 99);
|
||||
this.radioButtonBluRaySup.Location = new System.Drawing.Point(29, 110);
|
||||
this.radioButtonBluRaySup.Name = "radioButtonBluRaySup";
|
||||
this.radioButtonBluRaySup.Size = new System.Drawing.Size(200, 17);
|
||||
this.radioButtonBluRaySup.TabIndex = 13;
|
||||
@ -115,7 +117,7 @@
|
||||
// labelProgress2
|
||||
//
|
||||
this.labelProgress2.AutoSize = true;
|
||||
this.labelProgress2.Location = new System.Drawing.Point(15, 188);
|
||||
this.labelProgress2.Location = new System.Drawing.Point(15, 199);
|
||||
this.labelProgress2.Name = "labelProgress2";
|
||||
this.labelProgress2.Size = new System.Drawing.Size(76, 13);
|
||||
this.labelProgress2.TabIndex = 14;
|
||||
@ -157,11 +159,32 @@
|
||||
//
|
||||
this.openFileDialog1.FileName = "openFileDialog1";
|
||||
//
|
||||
// labelAudioFileName
|
||||
//
|
||||
this.labelAudioFileName.AutoSize = true;
|
||||
this.labelAudioFileName.Location = new System.Drawing.Point(305, 15);
|
||||
this.labelAudioFileName.Name = "labelAudioFileName";
|
||||
this.labelAudioFileName.Size = new System.Drawing.Size(82, 13);
|
||||
this.labelAudioFileName.TabIndex = 18;
|
||||
this.labelAudioFileName.Text = "Audio file name:";
|
||||
//
|
||||
// buttonAudioFileBrowse
|
||||
//
|
||||
this.buttonAudioFileBrowse.Location = new System.Drawing.Point(308, 32);
|
||||
this.buttonAudioFileBrowse.Name = "buttonAudioFileBrowse";
|
||||
this.buttonAudioFileBrowse.Size = new System.Drawing.Size(25, 23);
|
||||
this.buttonAudioFileBrowse.TabIndex = 19;
|
||||
this.buttonAudioFileBrowse.Text = "...";
|
||||
this.buttonAudioFileBrowse.UseVisualStyleBackColor = true;
|
||||
this.buttonAudioFileBrowse.Click += new System.EventHandler(this.buttonAudioFileBrowse_Click);
|
||||
//
|
||||
// ImportCdg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(973, 474);
|
||||
this.Controls.Add(this.buttonAudioFileBrowse);
|
||||
this.Controls.Add(this.labelAudioFileName);
|
||||
this.Controls.Add(this.pictureBoxBackgroundImage);
|
||||
this.Controls.Add(this.labelBackgroundImage);
|
||||
this.Controls.Add(this.buttonChooseBackgroundImage);
|
||||
@ -199,5 +222,7 @@
|
||||
private System.Windows.Forms.Label labelBackgroundImage;
|
||||
private System.Windows.Forms.PictureBox pictureBoxBackgroundImage;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog1;
|
||||
private System.Windows.Forms.Label labelAudioFileName;
|
||||
private System.Windows.Forms.Button buttonAudioFileBrowse;
|
||||
}
|
||||
}
|
@ -8,18 +8,21 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public partial class ImportCdg : Form, IBinaryParagraphList
|
||||
{
|
||||
{
|
||||
//300x216
|
||||
private readonly CdgGraphics _cdgGraphics;
|
||||
private readonly Subtitle _subtitle;
|
||||
private List<NikseBitmap> _imageList;
|
||||
private string _audioFileName;
|
||||
private Bitmap _originalBackgroundImage;
|
||||
private Bitmap _resizedBackgroundImage;
|
||||
private int _durationSeconds;
|
||||
|
||||
public string FileName { get; }
|
||||
|
||||
@ -34,8 +37,30 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelProgress.Text = string.Empty;
|
||||
labelProgress2.Text = string.Empty;
|
||||
labelFileName.Text = string.Format("File name: {0}", Path.GetFileName(fileName));
|
||||
_durationSeconds = (int) (_cdgGraphics.DurationInMilliseconds / 1000.0 + 0.5);
|
||||
labelDuration.Text = string.Format("Duration: {0}", TimeCode.FromSeconds(_cdgGraphics.DurationInMilliseconds / 1000.0).ToDisplayString());
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Ok;
|
||||
|
||||
if (fileName != null && fileName.Length > 3)
|
||||
{
|
||||
var audioFileName = fileName.Substring(0, fileName.Length - 3) + "mp3";
|
||||
if (!File.Exists(audioFileName))
|
||||
{
|
||||
audioFileName = fileName.Substring(0, fileName.Length - 3) + "ogg";
|
||||
}
|
||||
if (File.Exists(audioFileName))
|
||||
{
|
||||
_audioFileName = audioFileName;
|
||||
labelAudioFileName.Text = "Audio file name: " + Path.GetFileName(audioFileName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Configuration.Settings.Tools.ExportCdgBackgroundImage) &&
|
||||
File.Exists(Configuration.Settings.Tools.ExportCdgBackgroundImage))
|
||||
{
|
||||
pictureBoxBackgroundImage.Image = new Bitmap(Configuration.Settings.Tools.ExportCdgBackgroundImage);
|
||||
labelBackgroundImage.Text = Configuration.Settings.Tools.ExportCdgBackgroundImage;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
@ -67,8 +92,15 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
|
||||
var tempFolder = Path.GetTempPath();
|
||||
var audioFileName = @"C:\Users\WinX\Desktop\auto-br\CDG\samples\FOR HE'S A JOLLY GOOD FELLOW.mp3";
|
||||
var processMakeVideo = GetFFmpegProcess(labelBackgroundImage.Text,)
|
||||
var tempMkv = Path.Combine(tempFolder, Guid.NewGuid() + ".mkv");
|
||||
var processMakeVideo = GetFFmpegProcess(labelBackgroundImage.Text, _audioFileName, tempMkv);
|
||||
processMakeVideo.Start();
|
||||
processMakeVideo.WaitForExit();
|
||||
|
||||
var finalMkv = Path.Combine(Path.GetDirectoryName(FileName), Guid.NewGuid() + ".mkv");
|
||||
var processAddSubtitles = GetMkvMergeProcess(tempMkv, supFileName, finalMkv);
|
||||
processAddSubtitles.Start();
|
||||
processAddSubtitles.WaitForExit();
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
@ -103,6 +135,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
pictureBoxBackgroundImage.Image = new Bitmap(openFileDialog1.FileName);
|
||||
labelBackgroundImage.Text = openFileDialog1.FileName;
|
||||
Configuration.Settings.Tools.ExportCdgBackgroundImage = openFileDialog1.FileName;
|
||||
}
|
||||
|
||||
public Process GetFFmpegProcess(string imageFileName, string audioFileName, string outputFileName)
|
||||
@ -119,10 +152,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
FileName = ffmpegLocation,
|
||||
Arguments = $"-loop 1 -i \"{imageFileName}\" -i \"{audioFileName}\" -c:v libx264 -tune stillimage -shortest \"{outputFileName}\"",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true
|
||||
//UseShellExecute = false,
|
||||
//RedirectStandardOutput = true,
|
||||
//RedirectStandardError = true,
|
||||
//CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
return process;
|
||||
@ -141,11 +174,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
StartInfo =
|
||||
{
|
||||
FileName = location,
|
||||
Arguments = $"-o \"{videoFileName}\" \"{outputFileName}\" \"{subtitleFileName}\"",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true
|
||||
Arguments = $"-o \"{outputFileName}\" \"{videoFileName}\" \"{subtitleFileName}\"",
|
||||
//UseShellExecute = false,
|
||||
//RedirectStandardOutput = true,
|
||||
//RedirectStandardError = true,
|
||||
//CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
|
||||
@ -157,5 +190,16 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
private void buttonAudioFileBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog1.ShowDialog(this) != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_audioFileName = openFileDialog1.FileName;
|
||||
labelAudioFileName.Text = "Audio file name: " + Path.GetFileName(_audioFileName);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user