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
|
namespace MediaBrowser.Api.Library
|
||||||
{
|
{
|
||||||
[Route("/Videos/{Id}/Subtitles/{Index}", "GET", Summary = "Gets an external subtitle file")]
|
[Route("/Videos/{Id}/{MediaSourceId}/Subtitles/{Index}/Stream.{Format}", "GET", Summary = "Gets subtitles in a specified format (vtt).")]
|
||||||
[Route("/Videos/{Id}/Subtitles/{Index}/Stream.{Format}", "GET", Summary = "Gets subtitles in a specified format (vtt).")]
|
|
||||||
public class GetSubtitle
|
public class GetSubtitle
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -26,7 +25,7 @@ namespace MediaBrowser.Api.Library
|
|||||||
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||||
public string Id { get; set; }
|
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; }
|
public string MediaSourceId { get; set; }
|
||||||
|
|
||||||
[ApiMember(Name = "Index", Description = "The subtitle stream index", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")]
|
[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;
|
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;
|
var seconds = TimeSpan.FromTicks(state.Request.StartTimeTicks ?? 0).TotalSeconds;
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
|
|
||||||
var request = state.VideoRequest;
|
var request = state.VideoRequest;
|
||||||
|
|
||||||
if (state.SubtitleStream != null && !state.SubtitleStream.IsGraphicalSubtitleStream)
|
if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream)
|
||||||
{
|
{
|
||||||
assSubtitleParam = GetTextSubtitleParam(state, cancellationToken);
|
assSubtitleParam = GetTextSubtitleParam(state, cancellationToken);
|
||||||
copyTsParam = " -copyts";
|
copyTsParam = " -copyts";
|
||||||
@ -590,7 +590,6 @@ namespace MediaBrowser.Api.Playback
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Perhaps also use original_size=1920x800
|
// TODO: Perhaps also use original_size=1920x800
|
||||||
|
|
||||||
return string.Format(",subtitles=filename='{0}'{1},setpts=PTS -{2}/TB",
|
return string.Format(",subtitles=filename='{0}'{1},setpts=PTS -{2}/TB",
|
||||||
subtitlePath.Replace('\\', '/').Replace(":/", "\\:/"),
|
subtitlePath.Replace('\\', '/').Replace(":/", "\\:/"),
|
||||||
charsetParam,
|
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))";
|
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;
|
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+1))" :
|
||||||
" -force_key_frames expr:if(isnan(prev_forced_t),gte(t,.1),gte(t,prev_forced_t+5))";
|
" -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;
|
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, "libx264", true) + keyFrameArg;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
|
|
||||||
args += keyFrameArg;
|
args += keyFrameArg;
|
||||||
|
|
||||||
var hasGraphicalSubs = state.SubtitleStream != null && state.SubtitleStream.IsGraphicalSubtitleStream;
|
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||||
|
|
||||||
var request = state.VideoRequest;
|
var request = state.VideoRequest;
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
<Compile Include="Subtitles\ISubtitleParser.cs" />
|
<Compile Include="Subtitles\ISubtitleParser.cs" />
|
||||||
<Compile Include="Subtitles\ISubtitleWriter.cs" />
|
<Compile Include="Subtitles\ISubtitleWriter.cs" />
|
||||||
<Compile Include="Subtitles\SrtParser.cs" />
|
<Compile Include="Subtitles\SrtParser.cs" />
|
||||||
|
<Compile Include="Subtitles\SrtWriter.cs" />
|
||||||
<Compile Include="Subtitles\SsaParser.cs" />
|
<Compile Include="Subtitles\SsaParser.cs" />
|
||||||
<Compile Include="Subtitles\SubtitleEncoder.cs" />
|
<Compile Include="Subtitles\SubtitleEncoder.cs" />
|
||||||
<Compile Include="Subtitles\SubtitleTrackInfo.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");
|
throw new ArgumentNullException("format");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.Equals(format, SubtitleFormat.SRT, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return new SrtWriter();
|
||||||
|
}
|
||||||
if (string.Equals(format, SubtitleFormat.VTT, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(format, SubtitleFormat.VTT, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return new VttWriter();
|
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>
|
/// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
|
||||||
public bool IsExternal { get; set; }
|
public bool IsExternal { get; set; }
|
||||||
|
|
||||||
public bool IsGraphicalSubtitleStream
|
public bool IsTextSubtitleStream
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (IsExternal) return false;
|
if (Type != MediaStreamType.Subtitle) return false;
|
||||||
|
|
||||||
var codec = Codec ?? string.Empty;
|
var codec = Codec ?? string.Empty;
|
||||||
|
|
||||||
return StringHelper.IndexOfIgnoreCase(codec, "pgs") != -1 ||
|
return StringHelper.IndexOfIgnoreCase(codec, "pgs") == -1 &&
|
||||||
StringHelper.IndexOfIgnoreCase(codec, "dvd") != -1;
|
StringHelper.IndexOfIgnoreCase(codec, "dvd") == -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the filename.
|
/// Gets or sets the filename.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -110,7 +110,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
|
|
||||||
// There's an internal subtitle stream for this language
|
// There's an internal subtitle stream for this language
|
||||||
if (skipIfGraphicalSubtitlesPresent &&
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||||||
return index == -1 ? 100 : index;
|
return index == -1 ? 100 : index;
|
||||||
})
|
})
|
||||||
.ThenBy(i => i.IsDefault)
|
.ThenBy(i => i.IsDefault)
|
||||||
.ThenBy(i => !i.IsGraphicalSubtitleStream)
|
.ThenBy(i => i.IsTextSubtitleStream)
|
||||||
.ThenBy(i => i.IsExternal)
|
.ThenBy(i => i.IsExternal)
|
||||||
.ThenBy(i => i.Index)
|
.ThenBy(i => i.Index)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
Loading…
Reference in New Issue
Block a user