record IsAvc
This commit is contained in:
parent
92bdbe22b4
commit
dfa2557874
|
@ -288,9 +288,9 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
return "h264_qsv";
|
||||
|
||||
|
||||
return "h264_qsv";
|
||||
|
||||
}
|
||||
|
||||
return "libx264";
|
||||
|
@ -1804,6 +1804,15 @@ namespace MediaBrowser.Api.Playback
|
|||
}
|
||||
}
|
||||
|
||||
if (string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (videoStream.IsAVC.HasValue && !videoStream.IsAVC.Value)
|
||||
{
|
||||
Logger.Debug("Cannot stream copy video. Stream is marked as not AVC");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Source and target codecs must match
|
||||
if (!string.Equals(request.VideoCodec, videoStream.Codec, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
|
|
@ -575,6 +575,14 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
return false;
|
||||
}
|
||||
|
||||
if (string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (videoStream.IsAVC.HasValue && !videoStream.IsAVC.Value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If client is requesting a specific video profile, it must match the source
|
||||
if (!string.IsNullOrEmpty(request.Profile))
|
||||
{
|
||||
|
|
|
@ -411,6 +411,17 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
NalLengthSize = streamInfo.nal_length_size
|
||||
};
|
||||
|
||||
if (string.Equals(streamInfo.is_avc, "true", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(streamInfo.is_avc, "1", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
stream.IsAVC = true;
|
||||
}
|
||||
else if (string.Equals(streamInfo.is_avc, "false", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(streamInfo.is_avc, "0", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
stream.IsAVC = false;
|
||||
}
|
||||
|
||||
// Filter out junk
|
||||
if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string) && streamInfo.codec_tag_string.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
|
||||
{
|
||||
|
|
|
@ -42,6 +42,8 @@ namespace MediaBrowser.Model.Entities
|
|||
/// <value><c>true</c> if this instance is interlaced; otherwise, <c>false</c>.</value>
|
||||
public bool IsInterlaced { get; set; }
|
||||
|
||||
public bool? IsAVC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the channel layout.
|
||||
/// </summary>
|
||||
|
|
|
@ -26,6 +26,38 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
AddCodecTagColumn();
|
||||
AddCommentColumn();
|
||||
AddNalColumn();
|
||||
AddIsAvcColumn();
|
||||
}
|
||||
|
||||
private void AddIsAvcColumn()
|
||||
{
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "PRAGMA table_info(mediastreams)";
|
||||
|
||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
if (!reader.IsDBNull(1))
|
||||
{
|
||||
var name = reader.GetString(1);
|
||||
|
||||
if (string.Equals(name, "IsAvc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
|
||||
builder.AppendLine("alter table mediastreams");
|
||||
builder.AppendLine("add column IsAvc BIT NULL");
|
||||
|
||||
_connection.RunQueries(new[] { builder.ToString() }, _logger);
|
||||
}
|
||||
|
||||
private void AddNalColumn()
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
_connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);
|
||||
|
||||
var createMediaStreamsTableCommand
|
||||
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
|
||||
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, PRIMARY KEY (ItemId, StreamIndex))";
|
||||
|
||||
string[] queries = {
|
||||
|
||||
|
@ -391,7 +391,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"RefFrames",
|
||||
"CodecTag",
|
||||
"Comment",
|
||||
"NalLengthSize"
|
||||
"NalLengthSize",
|
||||
"IsAvc"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -2897,6 +2898,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
_saveStreamCommand.GetParameter(index++).Value = stream.CodecTag;
|
||||
_saveStreamCommand.GetParameter(index++).Value = stream.Comment;
|
||||
_saveStreamCommand.GetParameter(index++).Value = stream.NalLengthSize;
|
||||
_saveStreamCommand.GetParameter(index++).Value = stream.IsAVC;
|
||||
|
||||
_saveStreamCommand.Transaction = transaction;
|
||||
_saveStreamCommand.ExecuteNonQuery();
|
||||
|
@ -3060,6 +3062,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
item.NalLengthSize = reader.GetString(27);
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(28))
|
||||
{
|
||||
item.IsAVC = reader.GetBoolean(28);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user