mirror of https://github.com/jellyfin/jellyfin.git
extract ref frame count using ffprobe
This commit is contained in:
parent
442eb66e04
commit
a050f20ac5
|
@ -114,6 +114,12 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
/// <value>The width.</value>
|
/// <value>The width.</value>
|
||||||
public int width { get; set; }
|
public int width { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the refs.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The refs.</value>
|
||||||
|
public int refs { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the height.
|
/// Gets or sets the height.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -130,13 +130,18 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
var stream = new MediaStream
|
var stream = new MediaStream
|
||||||
{
|
{
|
||||||
Codec = streamInfo.codec_name,
|
Codec = streamInfo.codec_name,
|
||||||
CodecTag = streamInfo.codec_tag_string,
|
|
||||||
Profile = streamInfo.profile,
|
Profile = streamInfo.profile,
|
||||||
Level = streamInfo.level,
|
Level = streamInfo.level,
|
||||||
Index = streamInfo.index,
|
Index = streamInfo.index,
|
||||||
PixelFormat = streamInfo.pix_fmt
|
PixelFormat = streamInfo.pix_fmt
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Filter out junk
|
||||||
|
if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string) && streamInfo.codec_tag_string.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1)
|
||||||
|
{
|
||||||
|
stream.CodecTag = streamInfo.codec_tag_string;
|
||||||
|
}
|
||||||
|
|
||||||
if (streamInfo.tags != null)
|
if (streamInfo.tags != null)
|
||||||
{
|
{
|
||||||
stream.Language = GetDictionaryValue(streamInfo.tags, "language");
|
stream.Language = GetDictionaryValue(streamInfo.tags, "language");
|
||||||
|
@ -184,6 +189,11 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
|
// http://stackoverflow.com/questions/17353387/how-to-detect-anamorphic-video-with-ffprobe
|
||||||
stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase);
|
stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (streamInfo.refs > 0)
|
||||||
|
{
|
||||||
|
stream.RefFrames = streamInfo.refs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -922,25 +932,26 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
|
|
||||||
private void UpdateFromMediaInfo(MediaSourceInfo video, MediaStream videoStream)
|
private void UpdateFromMediaInfo(MediaSourceInfo video, MediaStream videoStream)
|
||||||
{
|
{
|
||||||
if (video.Protocol == MediaProtocol.File)
|
if (video.Protocol == MediaProtocol.File && videoStream != null)
|
||||||
{
|
{
|
||||||
if (videoStream != null)
|
try
|
||||||
{
|
{
|
||||||
try
|
_logger.Debug("Running MediaInfo against {0}", video.Path);
|
||||||
{
|
|
||||||
_logger.Debug("Running MediaInfo against {0}", video.Path);
|
|
||||||
|
|
||||||
var result = new MediaInfoLib().GetVideoInfo(video.Path);
|
var result = new MediaInfoLib().GetVideoInfo(video.Path);
|
||||||
|
|
||||||
videoStream.IsCabac = result.IsCabac ?? videoStream.IsCabac;
|
videoStream.IsCabac = result.IsCabac ?? videoStream.IsCabac;
|
||||||
videoStream.IsInterlaced = result.IsInterlaced ?? videoStream.IsInterlaced;
|
videoStream.IsInterlaced = result.IsInterlaced ?? videoStream.IsInterlaced;
|
||||||
videoStream.BitDepth = result.BitDepth ?? videoStream.BitDepth;
|
videoStream.BitDepth = result.BitDepth ?? videoStream.BitDepth;
|
||||||
videoStream.RefFrames = result.RefFrames;
|
videoStream.RefFrames = result.RefFrames ?? videoStream.RefFrames;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (TypeLoadException)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error running MediaInfo on {0}", ex, video.Path);
|
// This is non-essential. Don't spam the log
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error running MediaInfo on {0}", ex, video.Path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue