mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
added IsTextSubtitleStream
This commit is contained in:
parent
dd7825f6c8
commit
a18f4e37ac
@ -15,8 +15,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.Library
|
||||
{
|
||||
[Route("/Videos/{Id}/Subtitles/{Index}", "GET", Summary = "Gets an external subtitle file")]
|
||||
[Route("/Videos/{Id}/Subtitles/{Index}/Stream.{Format}", "GET", Summary = "Gets subtitles in a specified format (vtt).")]
|
||||
[Route("/Videos/{Id}/{MediaSourceId}/Subtitles/{Index}/Stream.{Format}", "GET", Summary = "Gets subtitles in a specified format (vtt).")]
|
||||
public class GetSubtitle
|
||||
{
|
||||
/// <summary>
|
||||
@ -26,7 +25,7 @@ namespace MediaBrowser.Api.Library
|
||||
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[ApiMember(Name = "MediaSourceId", Description = "MediaSourceId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
[ApiMember(Name = "MediaSourceId", Description = "MediaSourceId", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string MediaSourceId { get; set; }
|
||||
|
||||
[ApiMember(Name = "Index", Description = "The subtitle stream index", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")]
|
||||
|
@ -451,7 +451,7 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
var pts = string.Empty;
|
||||
|
||||
if (state.SubtitleStream != null && !state.SubtitleStream.IsGraphicalSubtitleStream)
|
||||
if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream)
|
||||
{
|
||||
var seconds = TimeSpan.FromTicks(state.Request.StartTimeTicks ?? 0).TotalSeconds;
|
||||
|
||||
@ -486,7 +486,7 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
var request = state.VideoRequest;
|
||||
|
||||
if (state.SubtitleStream != null && !state.SubtitleStream.IsGraphicalSubtitleStream)
|
||||
if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream)
|
||||
{
|
||||
assSubtitleParam = GetTextSubtitleParam(state, cancellationToken);
|
||||
copyTsParam = " -copyts";
|
||||
@ -590,7 +590,6 @@ namespace MediaBrowser.Api.Playback
|
||||
}
|
||||
|
||||
// TODO: Perhaps also use original_size=1920x800
|
||||
|
||||
return string.Format(",subtitles=filename='{0}'{1},setpts=PTS -{2}/TB",
|
||||
subtitlePath.Replace('\\', '/').Replace(":/", "\\:/"),
|
||||
charsetParam,
|
||||
|
@ -276,7 +276,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,.1),gte(t,prev_forced_t+5))";
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && state.SubtitleStream.IsGraphicalSubtitleStream;
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, "libx264", true) + keyFrameArg;
|
||||
|
||||
|
@ -170,7 +170,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
" -force_key_frames expr:if(isnan(prev_forced_t),gte(t,.1),gte(t,prev_forced_t+1))" :
|
||||
" -force_key_frames expr:if(isnan(prev_forced_t),gte(t,.1),gte(t,prev_forced_t+5))";
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && state.SubtitleStream.IsGraphicalSubtitleStream;
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, "libx264", true) + keyFrameArg;
|
||||
|
||||
|
@ -147,7 +147,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
args += keyFrameArg;
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && state.SubtitleStream.IsGraphicalSubtitleStream;
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
var request = state.VideoRequest;
|
||||
|
||||
|
@ -59,6 +59,7 @@
|
||||
<Compile Include="Subtitles\ISubtitleParser.cs" />
|
||||
<Compile Include="Subtitles\ISubtitleWriter.cs" />
|
||||
<Compile Include="Subtitles\SrtParser.cs" />
|
||||
<Compile Include="Subtitles\SrtWriter.cs" />
|
||||
<Compile Include="Subtitles\SsaParser.cs" />
|
||||
<Compile Include="Subtitles\SubtitleEncoder.cs" />
|
||||
<Compile Include="Subtitles\SubtitleTrackInfo.cs" />
|
||||
|
14
MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs
Normal file
14
MediaBrowser.MediaEncoding/Subtitles/SrtWriter.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
{
|
||||
public class SrtWriter : ISubtitleWriter
|
||||
{
|
||||
public void Write(SubtitleTrackInfo info, Stream stream, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -253,6 +253,10 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
throw new ArgumentNullException("format");
|
||||
}
|
||||
|
||||
if (string.Equals(format, SubtitleFormat.SRT, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new SrtWriter();
|
||||
}
|
||||
if (string.Equals(format, SubtitleFormat.VTT, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new VttWriter();
|
||||
|
@ -130,19 +130,20 @@ namespace MediaBrowser.Model.Entities
|
||||
/// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
|
||||
public bool IsExternal { get; set; }
|
||||
|
||||
public bool IsGraphicalSubtitleStream
|
||||
public bool IsTextSubtitleStream
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsExternal) return false;
|
||||
if (Type != MediaStreamType.Subtitle) return false;
|
||||
|
||||
var codec = Codec ?? string.Empty;
|
||||
|
||||
return StringHelper.IndexOfIgnoreCase(codec, "pgs") != -1 ||
|
||||
StringHelper.IndexOfIgnoreCase(codec, "dvd") != -1;
|
||||
return StringHelper.IndexOfIgnoreCase(codec, "pgs") == -1 &&
|
||||
StringHelper.IndexOfIgnoreCase(codec, "dvd") == -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the filename.
|
||||
/// </summary>
|
||||
|
@ -110,7 +110,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
|
||||
// There's an internal subtitle stream for this language
|
||||
if (skipIfGraphicalSubtitlesPresent &&
|
||||
internalMediaStreams.Any(i => i.Type == MediaStreamType.Subtitle && i.IsGraphicalSubtitleStream && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase)))
|
||||
internalMediaStreams.Any(i => i.Type == MediaStreamType.Subtitle && !i.IsTextSubtitleStream && string.Equals(i.Language, language, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
return index == -1 ? 100 : index;
|
||||
})
|
||||
.ThenBy(i => i.IsDefault)
|
||||
.ThenBy(i => !i.IsGraphicalSubtitleStream)
|
||||
.ThenBy(i => i.IsTextSubtitleStream)
|
||||
.ThenBy(i => i.IsExternal)
|
||||
.ThenBy(i => i.Index)
|
||||
.ToList();
|
||||
|
Loading…
Reference in New Issue
Block a user