mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Add rounding to the time base check
This commit is contained in:
parent
3a89e88033
commit
9abe9e7e54
@ -724,13 +724,17 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||||||
stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
|
stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
|
||||||
|
|
||||||
// Some interlaced H.264 files in mp4 containers using MBAFF coding aren't flagged as being interlaced by FFprobe,
|
// Some interlaced H.264 files in mp4 containers using MBAFF coding aren't flagged as being interlaced by FFprobe,
|
||||||
// so for H.264 files we also check if the codec timebase duration is half the reported frame rate duration to
|
// so for H.264 files we also calculate the frame rate from the codec time base and check if it is double the reported
|
||||||
// determine if the file is interlaced
|
// frame rate (both rounded to the nearest integer) to determine if the file is interlaced
|
||||||
|
float roundedTimeBaseFPS = MathF.Round(1 / GetFrameRate(stream.CodecTimeBase) ?? 0);
|
||||||
|
float roundedDoubleFrameRate = MathF.Round(stream.AverageFrameRate * 2 ?? 0);
|
||||||
|
|
||||||
bool videoInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
|
bool videoInterlaced = !string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
|
||||||
&& !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
|
&& !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
|
||||||
bool h264MbaffCoded = string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase)
|
bool h264MbaffCoded = string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase)
|
||||||
&& string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
|
&& string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
|
||||||
&& 1f / (stream.AverageFrameRate * 2) == GetFrameRate(stream.CodecTimeBase);
|
&& roundedTimeBaseFPS == roundedDoubleFrameRate;
|
||||||
|
|
||||||
if (videoInterlaced || h264MbaffCoded)
|
if (videoInterlaced || h264MbaffCoded)
|
||||||
{
|
{
|
||||||
stream.IsInterlaced = true;
|
stream.IsInterlaced = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user