diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-10-30 11:26:36 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-10-30 11:26:36 -0400 |
| commit | a050f20ac5ce37ce501d399346a5be40054da7f4 (patch) | |
| tree | 9aac3bb516bc06e8ce65fa73354cec6b17ab4251 | |
| parent | 442eb66e04518a249f635bb1fcc8336081c76662 (diff) | |
extract ref frame count using ffprobe
| -rw-r--r-- | MediaBrowser.MediaEncoding/Probing/InternalMediaInfoResult.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs | 43 |
2 files changed, 33 insertions, 16 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/InternalMediaInfoResult.cs b/MediaBrowser.MediaEncoding/Probing/InternalMediaInfoResult.cs index 9b95e83e7..3e4bfe1a7 100644 --- a/MediaBrowser.MediaEncoding/Probing/InternalMediaInfoResult.cs +++ b/MediaBrowser.MediaEncoding/Probing/InternalMediaInfoResult.cs @@ -115,6 +115,12 @@ namespace MediaBrowser.MediaEncoding.Probing public int width { get; set; } /// <summary> + /// Gets or sets the refs. + /// </summary> + /// <value>The refs.</value> + public int refs { get; set; } + + /// <summary> /// Gets or sets the height. /// </summary> /// <value>The height.</value> diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 7e9fa151b..ddcd48b8b 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -130,13 +130,18 @@ namespace MediaBrowser.MediaEncoding.Probing var stream = new MediaStream { Codec = streamInfo.codec_name, - CodecTag = streamInfo.codec_tag_string, Profile = streamInfo.profile, Level = streamInfo.level, Index = streamInfo.index, 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) { 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 stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase); + + if (streamInfo.refs > 0) + { + stream.RefFrames = streamInfo.refs; + } } else { @@ -922,25 +932,26 @@ namespace MediaBrowser.MediaEncoding.Probing 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.IsInterlaced = result.IsInterlaced ?? videoStream.IsInterlaced; - videoStream.BitDepth = result.BitDepth ?? videoStream.BitDepth; - videoStream.RefFrames = result.RefFrames; - } - catch (Exception ex) - { - _logger.ErrorException("Error running MediaInfo on {0}", ex, video.Path); - } + videoStream.IsCabac = result.IsCabac ?? videoStream.IsCabac; + videoStream.IsInterlaced = result.IsInterlaced ?? videoStream.IsInterlaced; + videoStream.BitDepth = result.BitDepth ?? videoStream.BitDepth; + videoStream.RefFrames = result.RefFrames ?? videoStream.RefFrames; + } + catch (TypeLoadException) + { + // This is non-essential. Don't spam the log + } + catch (Exception ex) + { + _logger.ErrorException("Error running MediaInfo on {0}", ex, video.Path); } } } |
