Fix for generate transparent subtitle duration

This commit is contained in:
Nikolaj Olsson 2024-06-26 08:52:27 +02:00
parent c28ffceb3a
commit cbcf3f8f94
2 changed files with 7 additions and 2 deletions

View File

@ -457,12 +457,17 @@ namespace Nikse.SubtitleEdit.Forms
private Process GetFfmpegProcess(string outputVideoFileName, string assaTempFileName)
{
var totalMs = _assaSubtitle.Paragraphs.Max(p => p.EndTime.TotalMilliseconds);
var ts = TimeSpan.FromMilliseconds(totalMs + 2000);
var timeCode = string.Format($"{ts.Hours:00}\\\\:{ts.Minutes:00}\\\\:{ts.Seconds:00}");
return VideoPreviewGenerator.GenerateTransparentVideoFile(
assaTempFileName,
outputVideoFileName,
(int)numericUpDownWidth.Value,
(int)numericUpDownHeight.Value,
comboBoxFrameRate.Text,
timeCode,
OutputHandler);
}

View File

@ -683,7 +683,7 @@ namespace Nikse.SubtitleEdit.Logic
return processMakeVideo;
}
public static Process GenerateTransparentVideoFile(string assaSubtitleFileName, string outputVideoFileName, int width, int height, string frameRate, DataReceivedEventHandler dataReceivedHandler)
public static Process GenerateTransparentVideoFile(string assaSubtitleFileName, string outputVideoFileName, int width, int height, string frameRate, string timeCode, DataReceivedEventHandler dataReceivedHandler)
{
if (width % 2 == 1)
{
@ -702,7 +702,7 @@ namespace Nikse.SubtitleEdit.Logic
StartInfo =
{
FileName = GetFfmpegLocation(),
Arguments = $" -y -f lavfi -i \"color=c=black@0.0:s={width}x{height}:r={frameRate}:d=00\\\\:00\\\\:30,format=rgba,subtitles=f={Path.GetFileName(assaSubtitleFileName)}:alpha=1\" -c:v png {outputVideoFileName}".TrimStart(),
Arguments = $" -y -f lavfi -i \"color=c=black@0.0:s={width}x{height}:r={frameRate}:d={timeCode},format=rgba,subtitles=f={Path.GetFileName(assaSubtitleFileName)}:alpha=1\" -c:v png {outputVideoFileName}".TrimStart(),
UseShellExecute = false,
CreateNoWindow = true,
WorkingDirectory = Path.GetDirectoryName(assaSubtitleFileName) ?? string.Empty,