summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore9
-rw-r--r--mkvlib/ass.go16
-rw-r--r--mkvlib/c/exports.go4
-rw-r--r--mkvlib/mkv.go6
-rw-r--r--mkvlib/shared.go2
-rw-r--r--mkvtool-gui/MainWindow.axaml62
-rw-r--r--mkvtool-gui/MainWindow.axaml.cs136
-rw-r--r--mkvtool-gui/Properties/PublishProfiles/FolderProfile.pubxml18
-rw-r--r--mkvtool-gui/mkvtool.csproj26
-rw-r--r--mkvtool-gui/mkvtool.sln25
-rw-r--r--mkvtool-gui/sdk.cs132
-rw-r--r--mkvtool/go.mod2
-rw-r--r--mkvtool/main.go6
13 files changed, 376 insertions, 68 deletions
diff --git a/.gitignore b/.gitignore
index 599e12e..4efa0f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,17 @@
### Example user template template
### Example user template
+go.sum
+
# IntelliJ project files
.idea
*.iml
out
gen
-
+# VS project files
+bin
+obj
+.vs
+*.user
+/mkvtool-gui/mkvlib.so
diff --git a/mkvlib/ass.go b/mkvlib/ass.go
index 826c484..f7c195c 100644
--- a/mkvlib/ass.go
+++ b/mkvlib/ass.go
@@ -98,8 +98,8 @@ func (self *assProcessor) parse() bool {
ec++
} else {
data, err := io.ReadAll(f)
- str := toUTF8(data)
if err == nil {
+ str := toUTF8(data)
self.subtitles[file] = str
} else {
ec++
@@ -108,6 +108,7 @@ func (self *assProcessor) parse() bool {
if ec > 0 {
printLog(self.lcb, `Failed to read the ass file: "%s"`, file)
}
+ _ = f.Close()
}
if ec == 0 {
opt := parser.SSAOptions{}
@@ -194,7 +195,7 @@ func (self *assProcessor) parse() bool {
if ___reg.MatchString(v) {
v += "0123456789"
}
- v += "\u0020\u00a0"
+ v += "a\u0020\u00a0"
self.m[k] = new(fontInfo)
self.m[k].runes = []rune(v)
self.m[k].oldName = strings.Split(k, "^")[0]
@@ -376,8 +377,12 @@ func (self *assProcessor) checkFontMissing(f *fontInfo, i int, c bool) bool {
}
}
}
+ } else {
+ return false
}
}
+ } else {
+ return false
}
h := "N"
if c {
@@ -886,7 +891,12 @@ func (self *assProcessor) matchCache(k, o string) (string, int) {
names := self.getFontName(v.File)
if len(names) > 0 {
_count++
- if !self.checkFontMissing(self.m[o], _count, true) && self.strict {
+ f := new(fontInfo)
+ f.oldName = _k[0]
+ f.file = ok
+ f.index = i
+ f.runes = self.m[o].runes
+ if !self.checkFontMissing(f, _count, true) && self.strict {
ok = ""
i = 0
continue
diff --git a/mkvlib/c/exports.go b/mkvlib/c/exports.go
index d52e6f6..b24b345 100644
--- a/mkvlib/c/exports.go
+++ b/mkvlib/c/exports.go
@@ -124,11 +124,11 @@ func MakeMKVs(dir, data, output, slang, stitle *C.char, lcb C.logCallback) bool
}
//export A2P
-func A2P(a2p, apc bool, pr, pf string) {
+func A2P(a2p, apc bool, pr, pf *C.char) {
if !checkInstance() {
return
}
- getter.GetProcessorInstance().A2P(a2p, apc, pr, pf)
+ getter.GetProcessorInstance().A2P(a2p, apc, gs(pr), gs(pf))
}
//export GetFontsList
diff --git a/mkvlib/mkv.go b/mkvlib/mkv.go
index 6ec8931..ca6a083 100644
--- a/mkvlib/mkv.go
+++ b/mkvlib/mkv.go
@@ -424,9 +424,13 @@ func (self *mkvProcessor) CreateBlankOrBurnVideo(t int64, s, enc, ass, fontdir,
t = new(assProcessor).getLength(ass).Milliseconds()
fontdir = strings.ReplaceAll(fontdir, `\`, `/`)
fontdir = strings.ReplaceAll(fontdir, `:`, `\\:`)
+ fontdir = strings.ReplaceAll(fontdir, `[`, `\[`)
+ fontdir = strings.ReplaceAll(fontdir, `]`, `\]`)
ass = strings.ReplaceAll(ass, `\`, `/`)
ass = strings.ReplaceAll(ass, `:`, `\\:`)
- args = append(args, "-vf", fmt.Sprintf("subtitles=%s:fontsdir=%s", ass, fontdir))
+ ass = strings.ReplaceAll(ass, `[`, `\[`)
+ ass = strings.ReplaceAll(ass, `]`, `\]`)
+ args = append(args, "-vf", fmt.Sprintf(`subtitles=%s:fontsdir=%s`, ass, fontdir))
}
if s == "" {
if t > 0 {
diff --git a/mkvlib/shared.go b/mkvlib/shared.go
index b76b3ac..05b964d 100644
--- a/mkvlib/shared.go
+++ b/mkvlib/shared.go
@@ -11,7 +11,7 @@ import (
)
const libName = "mkvlib"
-const libVer = "v1.9.3"
+const libVer = "v1.9.7"
const LibFName = libName + " " + libVer
diff --git a/mkvtool-gui/MainWindow.axaml b/mkvtool-gui/MainWindow.axaml
index a6d2d94..4023497 100644
--- a/mkvtool-gui/MainWindow.axaml
+++ b/mkvtool-gui/MainWindow.axaml
@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="600"
d:DesignHeight="600"
- Width="850"
+ Width="1050"
Height="670"
x:Class="mkvtool.MainWindow"
WindowStartupLocation="CenterScreen"
@@ -37,7 +37,7 @@
<StackPanel Orientation="Horizontal" Margin="5">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
- <TextBlock Text="Fonts:" />
+ <TextBlock Text="Extra fonts folder:" />
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<TextBlock Name="sa2" />
@@ -168,7 +168,7 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="Default Subtitle language:" VerticalAlignment="Center"
TextAlignment="Center" />
- <TextBox Name="ma4" />
+ <TextBox Name="ma4" Text="chi" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
@@ -211,7 +211,7 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
- <TextBlock Text="Fonts folder:" />
+ <TextBlock Text="Extra fonts folder:" />
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<TextBlock Name="ca3" />
@@ -233,7 +233,7 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="Default Subtitle language:" VerticalAlignment="Center"
TextAlignment="Center" />
- <TextBox Name="ca5" />
+ <TextBox Name="ca5" Text="chi" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
@@ -250,6 +250,58 @@
</Controlz:GroupBox>
</StackPanel>
</TabItem>
+ <TabItem Header="Cache / Settings">
+ <StackPanel>
+ <StackPanel>
+ <Controlz:GroupBox Header="Create cache" Margin="10">
+ <StackPanel Margin="5" HorizontalAlignment="Center">
+ <StackPanel Orientation="Horizontal" Margin="5">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="Fonts folder:" />
+ <ScrollViewer HorizontalScrollBarVisibility="Auto"
+ VerticalScrollBarVisibility="Auto">
+ <TextBlock Name="cca1" />
+ </ScrollViewer>
+ </StackPanel>
+ </StackPanel>
+ <Button Content="Select..." Click="CacheSelectBtns_OnClick" />
+ </StackPanel>
+ <Controls:ToggleSwitch Content="Clean old caches" IsChecked="False" Name="cca2" />
+ <Button Margin="10" Content="Go" Click="CacheBtn_OnClick"
+ HorizontalAlignment="Center" />
+ </StackPanel>
+ </Controlz:GroupBox>
+ </StackPanel>
+ <StackPanel>
+ <Controlz:GroupBox Header="Settings" Margin="10">
+ <StackPanel Margin="5" HorizontalAlignment="Center">
+ <Controls:ToggleSwitch Content="Ass to pgs" IsChecked="False" Name="ssa1" />
+ <Controls:ToggleSwitch Content="Ass and pgs coexist" IsChecked="False" Name="ssa2" />
+ <Controls:ToggleSwitch Content="Check mode" IsChecked="True" Name="ssa3" />
+ <Controls:ToggleSwitch Content="Strict for check mode" IsChecked="True" Name="ssa4" />
+ <Controls:ToggleSwitch Content="Not rename subsetted font" IsChecked="False" Name="ssa5" />
+ <StackPanel Orientation="Horizontal" Margin="5">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <TextBlock Text="PGS resolution:" VerticalAlignment="Center"
+ TextAlignment="Center" />
+ <TextBox Name="ssa6" Text="1080p" />
+ </StackPanel>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal" Margin="5">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
+ <TextBlock Text="PGS frame rate:" VerticalAlignment="Center"
+ TextAlignment="Center" />
+ <TextBox Name="ssa7" Text="23.976" />
+ </StackPanel>
+ </StackPanel>
+ <Button Margin="10" Content="Save" Click="SaveBtn_OnClick"
+ HorizontalAlignment="Center" />
+ </StackPanel>
+ </Controlz:GroupBox>
+ </StackPanel>
+ </StackPanel>
+ </TabItem>
</TabControl>
<Controls:BusyIndicator Name="busyBox" />
</Grid>
diff --git a/mkvtool-gui/MainWindow.axaml.cs b/mkvtool-gui/MainWindow.axaml.cs
index 807462e..4a17d4e 100644
--- a/mkvtool-gui/MainWindow.axaml.cs
+++ b/mkvtool-gui/MainWindow.axaml.cs
@@ -1,4 +1,8 @@
using System;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Security.Cryptography;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Controls;
@@ -24,7 +28,7 @@ namespace mkvtool
private async void CheckFileBtn_OnClick(object? sender, RoutedEventArgs e)
{
- string[] files = await ShowSelectFileDialog("MKV file", new string[] {"mkv"}, false);
+ string[] files = await ShowSelectFileDialog("MKV file", new string[] { "mkv" }, false);
if (files != null && files.Length > 0)
{
SetBusy(true);
@@ -69,7 +73,11 @@ namespace mkvtool
void lcb(string str)
{
DoUIThread(() =>
- this.FindControl<TextBox>("logBox").Text += str + Environment.NewLine);
+ {
+ TextBox box = this.FindControl<TextBox>("logBox");
+ box.Text += str + Environment.NewLine;
+ box.CaretIndex = box.Text.Length;
+ });
}
private async void TopLevel_OnOpened(object? sender, EventArgs e)
@@ -86,8 +94,13 @@ namespace mkvtool
}
else
{
- PrintResult("Init", "Init successfully.");
- DoUIThread(() => this.FindControl<Grid>("mainBox").IsEnabled = true);
+ PrintResult("Init", $"Init mkvlib {mkvlib.Version()} successfully.");
+ Cache();
+ DoUIThread(() =>
+ {
+ SaveSettings();
+ this.FindControl<Grid>("mainBox").IsEnabled = true;
+ });
}
}
catch
@@ -109,14 +122,14 @@ namespace mkvtool
private async void SubsetSelectBtns_OnClick(object? sender, RoutedEventArgs e)
{
- Button btn = (Button) sender;
+ Button btn = (Button)sender;
string dir;
switch (btn.Tag.ToString())
{
case "asses":
SubsetArg.Asses = null;
this.FindControl<TextBlock>("sa1").Text = string.Empty;
- string[] files = await ShowSelectFileDialog("ASS file(s)", new[] {"ass"}, true);
+ string[] files = await ShowSelectFileDialog("ASS file(s)", new[] { "ass" }, true);
if (files != null && files.Length > 0)
{
SubsetArg.Asses = files;
@@ -163,8 +176,7 @@ namespace mkvtool
private async void DoSubsetBtn_OnClick(object? sender, RoutedEventArgs e)
{
- if (SubsetArg.Asses != null && SubsetArg.Asses.Length > 0 && !string.IsNullOrEmpty(SubsetArg.Fonts) &&
- !string.IsNullOrEmpty(SubsetArg.Output))
+ if (SubsetArg.Asses != null && SubsetArg.Asses.Length > 0)
{
SetBusy(true);
SubsetArg.DirSafe = this.FindControl<ToggleSwitch>("sa4").IsChecked == true;
@@ -203,7 +215,7 @@ namespace mkvtool
private async void DumpSelectBtns_OnClick(object? sender, RoutedEventArgs e)
{
- Button btn = (Button) sender;
+ Button btn = (Button)sender;
string dir;
switch (btn.Tag.ToString())
{
@@ -212,7 +224,7 @@ namespace mkvtool
DumpArg.Dir = false;
this.FindControl<TextBlock>("da1").Text = string.Empty;
string[] files = await ShowSelectFileDialog("MKV file",
- new[] {"mkv"},
+ new[] { "mkv" },
false);
if (files != null && files.Length > 0)
{
@@ -291,7 +303,7 @@ namespace mkvtool
private async void MakeSelectBtns_OnClick(object? sender, RoutedEventArgs e)
{
- Button btn = (Button) sender;
+ Button btn = (Button)sender;
string dir;
switch (btn.Tag.ToString())
{
@@ -354,7 +366,7 @@ namespace mkvtool
this.FindControl<TextBlock>("ma1").Text = string.Empty;
this.FindControl<TextBlock>("ma2").Text = string.Empty;
this.FindControl<TextBlock>("ma3").Text = string.Empty;
- this.FindControl<TextBox>("ma4").Text = string.Empty;
+ this.FindControl<TextBox>("ma4").Text = "chi";
this.FindControl<TextBox>("ma5").Text = string.Empty;
});
}
@@ -379,7 +391,7 @@ namespace mkvtool
private async void CreateSelectBtns_OnClick(object? sender, RoutedEventArgs e)
{
- Button btn = (Button) sender;
+ Button btn = (Button)sender;
string dir;
switch (btn.Tag.ToString())
{
@@ -432,8 +444,7 @@ namespace mkvtool
private async void DoCreateBtn_OnClick(object? sender, RoutedEventArgs e)
{
- if (!string.IsNullOrEmpty(CreateArg.vDir) && !string.IsNullOrEmpty(CreateArg.sDir) &&
- !string.IsNullOrEmpty(CreateArg.fDir) && !string.IsNullOrEmpty(CreateArg.oDir))
+ if (!string.IsNullOrEmpty(CreateArg.vDir) && !string.IsNullOrEmpty(CreateArg.sDir) && !string.IsNullOrEmpty(CreateArg.oDir))
{
CreateArg.slang = this.FindControl<TextBox>("ca5").Text;
CreateArg.stitle = this.FindControl<TextBox>("ca6").Text;
@@ -456,7 +467,7 @@ namespace mkvtool
this.FindControl<TextBlock>("ca2").Text = string.Empty;
this.FindControl<TextBlock>("ca3").Text = string.Empty;
this.FindControl<TextBlock>("ca4").Text = string.Empty;
- this.FindControl<TextBox>("ca5").Text = string.Empty;
+ this.FindControl<TextBox>("ca5").Text = "chi";
this.FindControl<TextBox>("ca6").Text = string.Empty;
this.FindControl<ToggleSwitch>("ca7").IsChecked = false;
});
@@ -478,7 +489,7 @@ namespace mkvtool
private async void WorkflowSelectBtns_OnClick(object? sender, RoutedEventArgs e)
{
- Button btn = (Button) sender;
+ Button btn = (Button)sender;
string dir;
switch (btn.Tag.ToString())
{
@@ -548,12 +559,103 @@ namespace mkvtool
}
}
+ private async void SaveBtn_OnClick(object? sender, RoutedEventArgs e)
+ {
+ SaveSettings();
+ }
+
+ class CacheArg
+ {
+ public static string Dir { get; set; }
+ public static bool Clean { get; set; }
+ }
+
+ private async void CacheSelectBtns_OnClick(object? sender, RoutedEventArgs e)
+ {
+ WorkflowArg.Dir = string.Empty;
+ this.FindControl<TextBlock>("wa1").Text = string.Empty;
+ string dir = await new OpenFolderDialog().ShowAsync(this);
+ if (!string.IsNullOrEmpty(dir))
+ {
+ CacheArg.Dir = dir;
+ this.FindControl<TextBlock>("cca1").Text = dir;
+ }
+ }
+ private async void CacheBtn_OnClick(object? sender, RoutedEventArgs e)
+ {
+ CacheArg.Clean = this.FindControl<ToggleSwitch>("cca2").IsChecked == true;
+ if (!string.IsNullOrEmpty(CacheArg.Dir))
+ {
+ SetBusy(true);
+ new Thread(() =>
+ {
+ if (CacheArg.Clean)
+ try
+ {
+ Directory.Delete(cache, true);
+ }
+ catch { }
+ string output = $"{MD5Str(CacheArg.Dir)}.cache";
+ output = Path.Join(cache, output);
+ string[] el = mkvlib.CreateFontsCache(CacheArg.Dir, output, lcb);
+ if (el.Length > 0)
+ {
+ lcb("Not cache font list:");
+ lcb(" ----- Begin ----- ");
+ lcb(string.Join(Environment.NewLine, el));
+ lcb(" ----- End ----- ");
+ }
+ else
+ PrintResult("Create cache", "Create cache successfully.");
+ CacheArg.Dir = string.Empty;
+ CacheArg.Clean = false;
+ Cache();
+ DoUIThread(() =>
+ {
+ this.FindControl<TextBlock>("cca1").Text = string.Empty;
+ this.FindControl<ToggleSwitch>("cca2").IsChecked = false;
+ });
+ SetBusy(false);
+ }).Start();
+ }
+
+ }
+
+ string cache = Path.Join(Environment.GetEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "USERPROFILE" : "HOME"), ".mkvtool", "caches");
+ void Cache()
+ {
+ string[] ccs = Directory.GetFiles(cache, "*.cache");
+ mkvlib.Cache(ccs);
+ }
+
+ void SaveSettings()
+ {
+ bool a2p = this.FindControl<ToggleSwitch>("ssa1").IsChecked == true;
+ bool apc = this.FindControl<ToggleSwitch>("ssa2").IsChecked == true;
+ bool ck = this.FindControl<ToggleSwitch>("ssa3").IsChecked == true;
+ bool cks = this.FindControl<ToggleSwitch>("ssa4").IsChecked == true;
+ bool n = this.FindControl<ToggleSwitch>("ssa5").IsChecked == true;
+ string pr = this.FindControl<TextBox>("ssa6").Text;
+ string pf = this.FindControl<TextBox>("ssa7").Text;
+ mkvlib.A2P(a2p, apc, pr, pf);
+ mkvlib.Check(ck, cks);
+ mkvlib.NRename(n);
+ }
+
void PrintResult(string str1, string str2)
{
string str = $"##### {str1} result: \"{str2}\"";
lcb(str);
}
+ string MD5Str(string str)
+ {
+ MD5 md5 = MD5.Create();
+ byte[] byteOld = Encoding.UTF8.GetBytes(str);
+ byte[] byteNew = md5.ComputeHash(byteOld);
+ return Convert.ToHexString(byteNew).ToLower();
+ }
+
async void DoUIThread(Action action)
{
await Dispatcher.UIThread.InvokeAsync(action);
diff --git a/mkvtool-gui/Properties/PublishProfiles/FolderProfile.pubxml b/mkvtool-gui/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 0000000..15fec38
--- /dev/null
+++ b/mkvtool-gui/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+https://go.microsoft.com/fwlink/?LinkID=208121.
+-->
+<Project>
+ <PropertyGroup>
+ <Configuration>Release</Configuration>
+ <Platform>Any CPU</Platform>
+ <PublishDir>bin\Release\net6.0\publish\win-x64\</PublishDir>
+ <PublishProtocol>FileSystem</PublishProtocol>
+ <TargetFramework>net6.0</TargetFramework>
+ <RuntimeIdentifier>win-x64</RuntimeIdentifier>
+ <SelfContained>true</SelfContained>
+ <PublishSingleFile>true</PublishSingleFile>
+ <PublishReadyToRun>true</PublishReadyToRun>
+ <PublishTrimmed>false</PublishTrimmed>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/mkvtool-gui/mkvtool.csproj b/mkvtool-gui/mkvtool.csproj
index bf95164..02cc9f8 100644
--- a/mkvtool-gui/mkvtool.csproj
+++ b/mkvtool-gui/mkvtool.csproj
@@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
- <IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
- <IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
- <IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
+ <PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
- <PropertyGroup Condition="'$(IsWindows)'=='true'">
- <DefineConstants>Windows</DefineConstants>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+ <DefineConstants></DefineConstants>
</PropertyGroup>
- <PropertyGroup Condition="'$(IsOSX)'=='true'">
- <DefineConstants>OSX</DefineConstants>
- </PropertyGroup>
- <PropertyGroup Condition="'$(IsLinux)'=='true'">
- <DefineConstants>Linux</DefineConstants>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+ <DefineConstants></DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Remove=".gitignore" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Avalonia" Version="0.10.8" />
- <PackageReference Include="Avalonia.Desktop" Version="0.10.8" />
+ <PackageReference Include="Avalonia" Version="0.10.13" />
+ <PackageReference Include="Avalonia.Desktop" Version="0.10.13" />
<PackageReference Include="mameolan.Avalonia.Controlz" Version="1.0.0-CI-20211017-144151" />
<PackageReference Include="mameolan.Avalonia.ExtendedToolkit" Version="1.0.0-CI-20211017-144151" />
</ItemGroup>
+ <ItemGroup>
+ <None Update="mkvlib.so">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
</Project>
diff --git a/mkvtool-gui/mkvtool.sln b/mkvtool-gui/mkvtool.sln
new file mode 100644
index 0000000..5ef8eb1
--- /dev/null
+++ b/mkvtool-gui/mkvtool.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32421.90
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mkvtool", "mkvtool.csproj", "{9827A4AC-DBAE-4334-BE0A-D6C802BDF2EC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9827A4AC-DBAE-4334-BE0A-D6C802BDF2EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9827A4AC-DBAE-4334-BE0A-D6C802BDF2EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9827A4AC-DBAE-4334-BE0A-D6C802BDF2EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9827A4AC-DBAE-4334-BE0A-D6C802BDF2EC}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5A38EB08-B793-493C-847E-7324A3F51DA4}
+ EndGlobalSection
+EndGlobal
diff --git a/mkvtool-gui/sdk.cs b/mkvtool-gui/sdk.cs
index 2be1922..ba183a5 100644
--- a/mkvtool-gui/sdk.cs
+++ b/mkvtool-gui/sdk.cs
@@ -4,18 +4,14 @@ using System.Text.Json;
public static class mkvlib
{
-#if OSX
- const string so = "mkvlib_osx.so";
-#endif
-#if Linux
- const string so = "mkvlib_linux.so";
-#endif
-#if Windows
- const string so = "mkvlib_windows.so";
-#endif
+
+ const string so = "mkvlib.so";
#region imports
+ [DllImport(so, EntryPoint = "Version")]
+ static extern IntPtr _Version();
+
[DllImport(so)]
static extern bool InitInstance(logCallback lcb);
@@ -29,8 +25,7 @@ public static class mkvlib
static extern IntPtr CheckSubset(IntPtr file, logCallback lcb);
[DllImport(so)]
- static extern bool CreateMKV(IntPtr file, IntPtr tracks, IntPtr attachments, IntPtr output, IntPtr slang,
- IntPtr stitle, bool clean);
+ static extern bool CreateMKV(IntPtr file, IntPtr tracks, IntPtr attachments, IntPtr output, IntPtr slang, IntPtr stitle, bool clean);
[DllImport(so)]
static extern bool ASSFontSubset(IntPtr files, IntPtr fonts, IntPtr output, bool dirSafe, logCallback lcb);
@@ -42,14 +37,51 @@ public static class mkvlib
static extern bool DumpMKVs(IntPtr dir, IntPtr output, bool subset, logCallback lcb);
[DllImport(so)]
- static extern bool CreateMKVs(IntPtr vDir, IntPtr sDir, IntPtr fDir, IntPtr tDir, IntPtr oDir, IntPtr slang,
- IntPtr stitle, bool clean, logCallback lcb);
+ static extern bool CreateMKVs(IntPtr vDir, IntPtr sDir, IntPtr fDir, IntPtr tDir, IntPtr oDir, IntPtr slang, IntPtr stitle, bool clean, logCallback lcb);
[DllImport(so)]
static extern bool MakeMKVs(IntPtr dir, IntPtr data, IntPtr output, IntPtr slang, IntPtr stitle, logCallback lcb);
+ [DllImport(so)]
+ static extern bool CreateBlankOrBurnVideo(long t, IntPtr s, IntPtr enc, IntPtr ass, IntPtr fontdir, IntPtr output);
+
+ [DllImport(so)]
+ static extern bool CreateTestVideo(IntPtr asses, IntPtr s, IntPtr fontdir, IntPtr enc, bool burn, logCallback lcb);
+
+ [DllImport(so)]
+ static extern void A2P(bool a2p, bool apc, IntPtr pr, IntPtr pf);
+
+ [DllImport(so)]
+ static extern IntPtr GetFontsList(IntPtr files, logCallback lcb);
+
+ [DllImport(so)]
+ static extern void Cache(IntPtr ccs);
+
+ [DllImport(so, EntryPoint = "MKS")]
+ static extern void _MKS(bool mks);
+
+ [DllImport(so, EntryPoint = "NRename")]
+ static extern void _NRename(bool n);
+
+ [DllImport(so, EntryPoint = "Check")]
+ static extern void _Check(bool check, bool strict);
+
+ [DllImport(so)]
+ static extern IntPtr CreateFontsCache(IntPtr dir, IntPtr output, logCallback lcb);
+
+ [DllImport(so)]
+ static extern bool CopyFontsFromCache(IntPtr asses, IntPtr dist, logCallback lcb);
+
+ [DllImport(so)]
+ static extern IntPtr GetFontInfo(IntPtr p);
+
#endregion
+ public static string Version()
+ {
+ return css(_Version());
+ }
+
public static bool InitInstance(Action<string> lcb)
{
return InitInstance(_lcb(lcb));
@@ -75,17 +107,16 @@ public static class mkvlib
return result;
}
- public static bool CreateMKV(string file, string[] tracks, string[] attachments, string output, string slang,
- string stitle, bool clean)
+ public static bool CreateMKV(string file, string[] tracks, string[] attachments, string output, string slang, string stitle, bool clean)
{
- string _tracks = JsonSerializer.Serialize<string[]>(tracks);
- string _attachments = JsonSerializer.Serialize<string[]>(attachments);
+ string _tracks = JsonSerializer.Serialize(tracks);
+ string _attachments = JsonSerializer.Serialize(attachments);
return CreateMKV(cs(file), cs(_tracks), cs(_attachments), cs(output), cs(slang), cs(stitle), clean);
}
public static bool ASSFontSubset(string[] files, string fonts, string output, bool dirSafe, Action<string> lcb)
{
- string _files = JsonSerializer.Serialize<string[]>(files);
+ string _files = JsonSerializer.Serialize(files);
return ASSFontSubset(cs(_files), cs(fonts), cs(output), dirSafe, _lcb(lcb));
}
@@ -100,8 +131,7 @@ public static class mkvlib
return DumpMKVs(cs(dir), cs(output), subset, _lcb(lcb));
}
- public static bool CreateMKVs(string vDir, string sDir, string fDir, string tDir, string oDir, string slang,
- string stitle, bool clean, Action<string> lcb)
+ public static bool CreateMKVs(string vDir, string sDir, string fDir, string tDir, string oDir, string slang, string stitle, bool clean, Action<string> lcb)
{
return CreateMKVs(cs(vDir), cs(sDir), cs(fDir), cs(tDir), cs(oDir), cs(slang), cs(stitle), clean, _lcb(lcb));
}
@@ -111,9 +141,68 @@ public static class mkvlib
return MakeMKVs(cs(dir), cs(data), cs(output), cs(slang), cs(stitle), _lcb(lcb));
}
+ public static bool CreateBlankOrBurnVideo(long t, string s, string enc, string ass, string fontdir, string output)
+ {
+ return CreateBlankOrBurnVideo(t, cs(s), cs(enc), cs(ass), cs(fontdir), cs(output));
+ }
- delegate void logCallback(IntPtr ptr);
+ public static bool CreateTestVideo(string[] asses, string s, string fontdir, string enc, bool burn, Action<string> lcb)
+ {
+ string _asses = JsonSerializer.Serialize(asses);
+ return CreateTestVideo(cs(_asses), cs(s), cs(fontdir), cs(enc), burn, _lcb(lcb));
+ }
+
+ public static void A2P(bool a2p, bool apc, string pr, string pf)
+ {
+ A2P(a2p, apc, cs(pr), cs(pf));
+ }
+
+ public static string[] GetFontsList(string[] files, Action<string> lcb)
+ {
+ string _files = JsonSerializer.Serialize(files);
+ string result = css(GetFontsList(cs(_files), _lcb(lcb)));
+ return JsonSerializer.Deserialize<string[]>(result);
+ }
+
+ public static void Cache(string[] ccs)
+ {
+ string _ccs = JsonSerializer.Serialize(ccs);
+ Cache(cs(_ccs));
+ }
+
+ public static void MKS(bool mks)
+ {
+ _MKS(mks);
+ }
+
+ public static void NRename(bool n)
+ {
+ _NRename(n);
+ }
+ public static void Check(bool check, bool strict)
+ {
+ _Check(check, strict);
+ }
+
+ public static string GetFontInfo(string p)
+ {
+ return css(GetFontInfo(cs(p)));
+ }
+
+ public static string[] CreateFontsCache(string dir, string output, Action<string> lcb)
+ {
+ string result = css(CreateFontsCache(cs(dir), cs(output), _lcb(lcb)));
+ return JsonSerializer.Deserialize<string[]>(result);
+ }
+
+ public static bool CopyFontsFromCache(string[] asses, string dist, Action<string> lcb)
+ {
+ string _files = JsonSerializer.Serialize(asses);
+ return CopyFontsFromCache(cs(_files), cs(dist), _lcb(lcb));
+ }
+
+ delegate void logCallback(IntPtr ptr);
static logCallback _lcb(Action<string> lcb)
{
return (ptr) =>
@@ -132,4 +221,5 @@ public static class mkvlib
{
return Marshal.PtrToStringUTF8(ptr);
}
+
} \ No newline at end of file
diff --git a/mkvtool/go.mod b/mkvtool/go.mod
index 4d01110..07f8fda 100644
--- a/mkvtool/go.mod
+++ b/mkvtool/go.mod
@@ -2,7 +2,7 @@ module github.com/MkvAutoSubset/MkvAutoSubset/mkvtool
go 1.18
-require github.com/MkvAutoSubset/MkvAutoSubset/mkvlib v0.0.0-20220507135658-002f01026127
+require github.com/MkvAutoSubset/MkvAutoSubset/mkvlib v0.0.0-20220509073418-da63b85a97bd
require (
github.com/antchfx/xmlquery v1.3.10 // indirect
diff --git a/mkvtool/main.go b/mkvtool/main.go
index d438018..cd7f6cf 100644
--- a/mkvtool/main.go
+++ b/mkvtool/main.go
@@ -16,7 +16,7 @@ import (
)
const appName = "MKV Tool"
-const appVer = "v3.9.3"
+const appVer = "v3.9.7"
const tTitle = appName + " " + appVer
var appFN = fmt.Sprintf("%s %s %s/%s", appName, appVer, runtime.GOOS, runtime.GOARCH)
@@ -102,8 +102,8 @@ func main() {
flag.StringVar(&data, "data", "data", "Subtitles & Fonts folder (dump & make mode only)")
flag.StringVar(&dist, "dist", "dist", "Results output folder (make mode only)")
flag.StringVar(&flog, "log", "", "Log file path.")
- flag.StringVar(&pf, "pf", "23.976", "PGS or blank video frame rate:23.976, 24, 25, 30, 29.97, 50, 59.94, 60 or custom fps like 15/1. (ass2pgs only)")
- flag.StringVar(&pr, "pr", "1920*1080", "PGS or blank video resolution:720p, 1080p, 2k, or with custom resolution like 720*480. (ass2pgs only)")
+ flag.StringVar(&pf, "pf", "23.976", "PGS or blank video frame rate:23.976, 24, 25, 30, 29.97, 50, 59.94, 60 or custom fps like 15/1.")
+ flag.StringVar(&pr, "pr", "1920*1080", "PGS or blank video resolution:720p, 1080p, 2k, or with custom resolution like 720*480.")
flag.StringVar(&t, "t", "", `Create test video source path(enter "-" for blank video).`)
flag.BoolVar(&b, "b", false, `Create test video with burn subtitle.`)
flag.StringVar(&e, "e", "libx264", `Create test video use encoder.`)