update mjpeg stream detection

This commit is contained in:
Luke Pulverenti
2017-03-07 14:05:44 -05:00
parent 9fa6868af3
commit 1f63a30ee7
4 changed files with 30 additions and 8 deletions

View File

@@ -558,13 +558,36 @@ namespace MediaBrowser.MediaEncoding.Probing
? MediaStreamType.EmbeddedImage
: MediaStreamType.Video;
stream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate);
stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate);
if (isAudio || string.Equals(stream.Codec, "gif", StringComparison.OrdinalIgnoreCase) ||
string.Equals(stream.Codec, "png", StringComparison.OrdinalIgnoreCase))
{
stream.Type = MediaStreamType.EmbeddedImage;
}
else if (string.Equals(stream.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
{
// How to differentiate between video and embedded image?
// The only difference I've seen thus far is presence of codec tag, also embedded images have high (unusual) framerates
if (!string.IsNullOrWhiteSpace(stream.CodecTag))
{
stream.Type = MediaStreamType.Video;
}
else
{
stream.Type = MediaStreamType.EmbeddedImage;
}
}
else
{
stream.Type = MediaStreamType.Video;
}
stream.Width = streamInfo.width;
stream.Height = streamInfo.height;
stream.AspectRatio = GetAspectRatio(streamInfo);
stream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate);
stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate);
if (streamInfo.bits_per_sample > 0)
{
stream.BitDepth = streamInfo.bits_per_sample;