mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Use small preview mkv for ASSA style windows
This commit is contained in:
parent
94966b9d7b
commit
e9bc0f73b3
@ -236,6 +236,9 @@ Source: ..\Dictionaries\en_US.dic; DestDir: {userappdata}\Subtit
|
|||||||
Source: ..\Ocr\Latin.db; DestDir: {userappdata}\Subtitle Edit\Ocr; Flags: ignoreversion uninsneveruninstall onlyifdoesntexist; Components: main
|
Source: ..\Ocr\Latin.db; DestDir: {userappdata}\Subtitle Edit\Ocr; Flags: ignoreversion uninsneveruninstall onlyifdoesntexist; Components: main
|
||||||
Source: ..\Ocr\Latin.nocr; DestDir: {userappdata}\Subtitle Edit\Ocr; Flags: ignoreversion uninsneveruninstall onlyifdoesntexist; Components: main
|
Source: ..\Ocr\Latin.nocr; DestDir: {userappdata}\Subtitle Edit\Ocr; Flags: ignoreversion uninsneveruninstall onlyifdoesntexist; Components: main
|
||||||
|
|
||||||
|
Source: ..\preview.mkv; DestDir: {userappdata}\Subtitle Edit; Flags: ignoreversion uninsneveruninstall onlyifdoesntexist; Components: main
|
||||||
|
|
||||||
|
|
||||||
#ifdef localize
|
#ifdef localize
|
||||||
Source: {#bindir}\Languages\ar-EG.xml; DestDir: {app}\Languages; Flags: ignoreversion; Components: translations
|
Source: {#bindir}\Languages\ar-EG.xml; DestDir: {app}\Languages; Flags: ignoreversion; Components: translations
|
||||||
Source: {#bindir}\Languages\bg-BG.xml; DestDir: {app}\Languages; Flags: ignoreversion; Components: translations
|
Source: {#bindir}\Languages\bg-BG.xml; DestDir: {app}\Languages; Flags: ignoreversion; Components: translations
|
||||||
@ -619,6 +622,7 @@ begin
|
|||||||
RemoveDir(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries'));
|
RemoveDir(ExpandConstant('{userappdata}\Subtitle Edit\Dictionaries'));
|
||||||
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Ocr\Latin.db'));
|
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Ocr\Latin.db'));
|
||||||
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Ocr\Latin.nocr'));
|
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\Ocr\Latin.nocr'));
|
||||||
|
DeleteFile(ExpandConstant('{userappdata}\Subtitle Edit\preview.mkv'));
|
||||||
DelTree(ExpandConstant('{userappdata}\Subtitle Edit\Ocr\*.*'), False, True, False);
|
DelTree(ExpandConstant('{userappdata}\Subtitle Edit\Ocr\*.*'), False, True, False);
|
||||||
RemoveDir(ExpandConstant('{userappdata}\Subtitle Edit\Ocr'));
|
RemoveDir(ExpandConstant('{userappdata}\Subtitle Edit\Ocr'));
|
||||||
DelTree(ExpandConstant('{userappdata}\Subtitle Edit\Plugins\*.*'), False, True, False);
|
DelTree(ExpandConstant('{userappdata}\Subtitle Edit\Plugins\*.*'), False, True, False);
|
||||||
|
BIN
preview.mkv
Normal file
BIN
preview.mkv
Normal file
Binary file not shown.
@ -343,23 +343,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
|
|
||||||
private bool GeneratePreviewViaMpv()
|
private bool GeneratePreviewViaMpv()
|
||||||
{
|
{
|
||||||
var fileName = Path.Combine(Configuration.DataDirectory, "preview.mp4");
|
var fileName = VideoPreviewGenerator.GetVideoPreviewFileName();
|
||||||
if (!File.Exists(fileName))
|
if (string.IsNullOrEmpty(fileName) || !LibMpvDynamic.IsInstalled)
|
||||||
{
|
|
||||||
var isFfmpegAvailable = !Configuration.IsRunningOnWindows || !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
|
||||||
if (!isFfmpegAvailable)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var p = GetFFmpegProcess(fileName))
|
|
||||||
{
|
|
||||||
p.Start();
|
|
||||||
p.WaitForExit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!LibMpvDynamic.IsInstalled)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -377,26 +362,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Process GetFFmpegProcess(string outputFileName)
|
|
||||||
{
|
|
||||||
var ffmpegLocation = Configuration.Settings.General.FFmpegLocation;
|
|
||||||
if (!Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(ffmpegLocation) || !File.Exists(ffmpegLocation)))
|
|
||||||
{
|
|
||||||
ffmpegLocation = "ffmpeg";
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Process
|
|
||||||
{
|
|
||||||
StartInfo =
|
|
||||||
{
|
|
||||||
FileName = ffmpegLocation,
|
|
||||||
Arguments = $"-t 1 -f lavfi -i color=c=blue:s=720x480 -c:v libx264 -tune stillimage -pix_fmt yuv420p \"{outputFileName}\"",
|
|
||||||
UseShellExecute = false,
|
|
||||||
CreateNoWindow = true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void VideoLoaded(object sender, EventArgs e)
|
private void VideoLoaded(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var format = new AdvancedSubStationAlpha();
|
var format = new AdvancedSubStationAlpha();
|
||||||
@ -408,7 +373,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
var p = new Paragraph(_subtitle.Paragraphs[indices[0]])
|
var p = new Paragraph(_subtitle.Paragraphs[indices[0]])
|
||||||
{
|
{
|
||||||
StartTime = { TotalMilliseconds = 0 },
|
StartTime = { TotalMilliseconds = 0 },
|
||||||
EndTime = { TotalMilliseconds = 1000 }
|
EndTime = { TotalMilliseconds = 2000 }
|
||||||
};
|
};
|
||||||
p.Text = styleToApply + p.Text;
|
p.Text = styleToApply + p.Text;
|
||||||
subtitle.Paragraphs.Add(p);
|
subtitle.Paragraphs.Add(p);
|
||||||
|
@ -216,7 +216,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
|
|||||||
|
|
||||||
private bool GeneratePreviewViaMpv()
|
private bool GeneratePreviewViaMpv()
|
||||||
{
|
{
|
||||||
var fileName = _videoFileName; // Path.Combine(Configuration.DataDirectory, "preview.mp4");
|
var fileName = _videoFileName;
|
||||||
if (!File.Exists(fileName))
|
if (!File.Exists(fileName))
|
||||||
{
|
{
|
||||||
var isFfmpegAvailable = !Configuration.IsRunningOnWindows || !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
var isFfmpegAvailable = !Configuration.IsRunningOnWindows || !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
||||||
|
@ -407,23 +407,8 @@ namespace Nikse.SubtitleEdit.Forms.Styles
|
|||||||
|
|
||||||
private bool GeneratePreviewViaMpv()
|
private bool GeneratePreviewViaMpv()
|
||||||
{
|
{
|
||||||
var fileName = Path.Combine(Configuration.DataDirectory, "preview.mp4");
|
var fileName = VideoPreviewGenerator.GetVideoPreviewFileName();
|
||||||
if (!File.Exists(fileName))
|
if (string.IsNullOrEmpty(fileName) || !LibMpvDynamic.IsInstalled)
|
||||||
{
|
|
||||||
var isFfmpegAvailable = !Configuration.IsRunningOnWindows || !string.IsNullOrEmpty(Configuration.Settings.General.FFmpegLocation) && File.Exists(Configuration.Settings.General.FFmpegLocation);
|
|
||||||
if (!isFfmpegAvailable)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var p = GetFFmpegProcess(fileName))
|
|
||||||
{
|
|
||||||
p.Start();
|
|
||||||
p.WaitForExit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!LibMpvDynamic.IsInstalled)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -441,26 +426,6 @@ namespace Nikse.SubtitleEdit.Forms.Styles
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Process GetFFmpegProcess(string outputFileName)
|
|
||||||
{
|
|
||||||
var ffmpegLocation = Configuration.Settings.General.FFmpegLocation;
|
|
||||||
if (!Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(ffmpegLocation) || !File.Exists(ffmpegLocation)))
|
|
||||||
{
|
|
||||||
ffmpegLocation = "ffmpeg";
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Process
|
|
||||||
{
|
|
||||||
StartInfo =
|
|
||||||
{
|
|
||||||
FileName = ffmpegLocation,
|
|
||||||
Arguments = $"-t 1 -f lavfi -i color=c=blue:s=720x480 -c:v libx264 -tune stillimage -pix_fmt yuv420p \"{outputFileName}\"",
|
|
||||||
UseShellExecute = false,
|
|
||||||
CreateNoWindow = true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void VideoStartLoaded(object sender, EventArgs e)
|
private void VideoStartLoaded(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var format = new AdvancedSubStationAlpha();
|
var format = new AdvancedSubStationAlpha();
|
||||||
|
57
src/ui/Logic/VideoPreviewGenerator.cs
Normal file
57
src/ui/Logic/VideoPreviewGenerator.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using Nikse.SubtitleEdit.Core.Common;
|
||||||
|
|
||||||
|
namespace Nikse.SubtitleEdit.Logic
|
||||||
|
{
|
||||||
|
public class VideoPreviewGenerator
|
||||||
|
{
|
||||||
|
public static string GetVideoPreviewFileName()
|
||||||
|
{
|
||||||
|
var previewFileName = Path.Combine(Configuration.DataDirectory, "preview.mkv");
|
||||||
|
if (File.Exists(previewFileName))
|
||||||
|
{
|
||||||
|
return previewFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const int rectangleSize = 9;
|
||||||
|
var backgroundImage = TextDesigner.MakeBackgroundImage(720, 480, rectangleSize, Configuration.Settings.General.UseDarkTheme);
|
||||||
|
var tempImageFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".png");
|
||||||
|
backgroundImage.Save(tempImageFileName, ImageFormat.Png);
|
||||||
|
var processMakeVideo = GetFFmpegProcess(tempImageFileName, previewFileName, backgroundImage.Width, backgroundImage.Height);
|
||||||
|
processMakeVideo.Start();
|
||||||
|
processMakeVideo.WaitForExit();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return File.Exists(previewFileName) ? previewFileName : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Process GetFFmpegProcess(string imageFileName, string outputFileName, int videoWidth, int videoHeight)
|
||||||
|
{
|
||||||
|
var ffmpegLocation = Configuration.Settings.General.FFmpegLocation;
|
||||||
|
if (!Configuration.IsRunningOnWindows && (string.IsNullOrEmpty(ffmpegLocation) || !File.Exists(ffmpegLocation)))
|
||||||
|
{
|
||||||
|
ffmpegLocation = "ffmpeg";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Process
|
||||||
|
{
|
||||||
|
StartInfo =
|
||||||
|
{
|
||||||
|
FileName = ffmpegLocation,
|
||||||
|
Arguments = $"-t 3 -loop 1 -i \"{imageFileName}\" -c:v libx264 -tune stillimage -shortest -s {videoWidth}x{videoHeight} \"{outputFileName}\"",
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1240,6 +1240,7 @@
|
|||||||
<Compile Include="Logic\VideoPlayers\MpcHC\NativeMethods.cs" />
|
<Compile Include="Logic\VideoPlayers\MpcHC\NativeMethods.cs" />
|
||||||
<Compile Include="Logic\VideoPlayers\QuartsPlayer.cs" />
|
<Compile Include="Logic\VideoPlayers\QuartsPlayer.cs" />
|
||||||
<Compile Include="Logic\VideoPlayers\VideoPlayer.cs" />
|
<Compile Include="Logic\VideoPlayers\VideoPlayer.cs" />
|
||||||
|
<Compile Include="Logic\VideoPreviewGenerator.cs" />
|
||||||
<Compile Include="Logic\WordSpellChecker.cs" />
|
<Compile Include="Logic\WordSpellChecker.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user