aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.MediaEncoding')
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs7
-rw-r--r--MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj2
-rw-r--r--MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.nuget.targets6
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/AssParser.cs16
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs6
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs10
6 files changed, 27 insertions, 20 deletions
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index b1da9c712d..fbd08a97c7 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -603,16 +603,19 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
// Use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back just in case.
+ // mpegts need larger batch size otherwise the corrupted thumbnail will be created. Larger batch size will lower the processing speed.
var enableThumbnail = useIFrame && !string.Equals("wtv", container, StringComparison.OrdinalIgnoreCase);
if (enableThumbnail)
{
+ var useLargerBatchSize = string.Equals("mpegts", container, StringComparison.OrdinalIgnoreCase);
+ var batchSize = useLargerBatchSize ? "50" : "24";
if (string.IsNullOrEmpty(vf))
{
- vf = "-vf thumbnail=24";
+ vf = "-vf thumbnail=" + batchSize;
}
else
{
- vf += ",thumbnail=24";
+ vf += ",thumbnail=" + batchSize;
}
}
diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
index 7bb2a7d03f..f8af499e4c 100644
--- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
+++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
@@ -24,7 +24,7 @@
<ItemGroup>
<PackageReference Include="BDInfo" Version="0.7.6.1" />
- <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.6" />
+ <PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
<PackageReference Include="UTF.Unknown" Version="2.3.0" />
</ItemGroup>
diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.nuget.targets b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.nuget.targets
deleted file mode 100644
index f793e09bcb..0000000000
--- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.nuget.targets
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="no"?>
-<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Target Name="EmitMSBuildWarning" BeforeTargets="Build">
- <Warning Text="Packages containing MSBuild targets and props files cannot be fully installed in projects targeting multiple frameworks. The MSBuild targets and props files have been ignored." />
- </Target>
-</Project> \ No newline at end of file
diff --git a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
index 86b87fddd8..bb48bed270 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/AssParser.cs
@@ -24,7 +24,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
using (var reader = new StreamReader(stream))
{
string line;
- while (reader.ReadLine() != "[Events]")
+ while (!string.Equals(reader.ReadLine(), "[Events]", StringComparison.Ordinal))
{
}
@@ -46,23 +46,24 @@ namespace MediaBrowser.MediaEncoding.Subtitles
var subEvent = new SubtitleTrackEvent { Id = eventIndex.ToString(_usCulture) };
eventIndex++;
- var sections = line.Substring(10).Split(',');
+ const string Dialogue = "Dialogue: ";
+ var sections = line.Substring(Dialogue.Length).Split(',');
subEvent.StartPositionTicks = GetTicks(sections[headers["Start"]]);
subEvent.EndPositionTicks = GetTicks(sections[headers["End"]]);
- subEvent.Text = string.Join(",", sections.Skip(headers["Text"]));
+ subEvent.Text = string.Join(',', sections[headers["Text"]..]);
RemoteNativeFormatting(subEvent);
subEvent.Text = subEvent.Text.Replace("\\n", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
- subEvent.Text = Regex.Replace(subEvent.Text, @"\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}", string.Empty, RegexOptions.IgnoreCase);
+ subEvent.Text = Regex.Replace(subEvent.Text, @"\{(\\[\w]+\(?([\w0-9]+,?)+\)?)+\}", string.Empty, RegexOptions.IgnoreCase);
trackEvents.Add(subEvent);
}
}
- trackInfo.TrackEvents = trackEvents.ToArray();
+ trackInfo.TrackEvents = trackEvents;
return trackInfo;
}
@@ -72,9 +73,10 @@ namespace MediaBrowser.MediaEncoding.Subtitles
? span.Ticks : 0;
}
- private Dictionary<string, int> ParseFieldHeaders(string line)
+ internal static Dictionary<string, int> ParseFieldHeaders(string line)
{
- var fields = line.Substring(8).Split(',').Select(x => x.Trim()).ToList();
+ const string Format = "Format: ";
+ var fields = line.Substring(Format.Length).Split(',').Select(x => x.Trim()).ToList();
return new Dictionary<string, int>
{
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs
index cc35efb3f0..ccef7eeeae 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs
@@ -69,7 +69,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
var multiline = new List<string>();
while ((line = reader.ReadLine()) != null)
{
- if (string.IsNullOrEmpty(line))
+ if (line.Length == 0)
{
break;
}
@@ -79,7 +79,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
subEvent.Text = string.Join(ParserValues.NewLine, multiline);
subEvent.Text = subEvent.Text.Replace(@"\N", ParserValues.NewLine, StringComparison.OrdinalIgnoreCase);
- subEvent.Text = Regex.Replace(subEvent.Text, @"\{(?:\\\d?[\w.-]+(?:\([^\)]*\)|&H?[0-9A-Fa-f]+&|))+\}", string.Empty, RegexOptions.IgnoreCase);
+ subEvent.Text = Regex.Replace(subEvent.Text, @"\{(?:\\[0-9]?[\w.-]+(?:\([^\)]*\)|&H?[0-9A-Fa-f]+&|))+\}", string.Empty, RegexOptions.IgnoreCase);
subEvent.Text = Regex.Replace(subEvent.Text, "<", "&lt;", RegexOptions.IgnoreCase);
subEvent.Text = Regex.Replace(subEvent.Text, ">", "&gt;", RegexOptions.IgnoreCase);
subEvent.Text = Regex.Replace(subEvent.Text, "&lt;(\\/?(font|b|u|i|s))((\\s+(\\w|\\w[\\w\\-]*\\w)(\\s*=\\s*(?:\\\".*?\\\"|'.*?'|[^'\\\">\\s]+))?)+\\s*|\\s*)(\\/?)&gt;", "<$1$3$7>", RegexOptions.IgnoreCase);
@@ -87,7 +87,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
}
}
- trackInfo.TrackEvents = trackEvents.ToArray();
+ trackInfo.TrackEvents = trackEvents;
return trackInfo;
}
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs b/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs
index db6b475830..bc84c5074d 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SsaParser.cs
@@ -325,7 +325,15 @@ namespace MediaBrowser.MediaEncoding.Subtitles
text = text.Insert(start, "<font color=\"" + color + "\"" + extraTags + ">");
}
- text += "</font>";
+ int indexOfEndTag = text.IndexOf("{\\1c}", start, StringComparison.Ordinal);
+ if (indexOfEndTag > 0)
+ {
+ text = text.Remove(indexOfEndTag, "{\\1c}".Length).Insert(indexOfEndTag, "</font>");
+ }
+ else
+ {
+ text += "</font>";
+ }
}
}
}