aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding
diff options
context:
space:
mode:
authorOrry Verducci <orry@orryverducci.co.uk>2021-10-31 17:04:04 +0000
committerOrry Verducci <orry@orryverducci.co.uk>2021-10-31 17:04:04 +0000
commit9abe9e7e54cc454667ba2128b5d321631b5ece51 (patch)
treecb2cc3ae826b6a073d74f28658f95b35017a5017 /MediaBrowser.MediaEncoding
parent3a89e88033fc54360d926d73591293660e6bf43c (diff)
Add rounding to the time base check
Diffstat (limited to 'MediaBrowser.MediaEncoding')
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs10
1 files changed, 7 insertions, 3 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index c9885ae76..eb8850cd2 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -724,13 +724,17 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.RealFrameRate = GetFrameRate(streamInfo.RFrameRate);
// 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
- // determine if the file is interlaced
+ // so for H.264 files we also calculate the frame rate from the codec time base and check if it is double the reported
+ // 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)
&& !string.Equals(streamInfo.FieldOrder, "progressive", StringComparison.OrdinalIgnoreCase);
bool h264MbaffCoded = string.Equals(stream.Codec, "h264", StringComparison.OrdinalIgnoreCase)
&& string.IsNullOrWhiteSpace(streamInfo.FieldOrder)
- && 1f / (stream.AverageFrameRate * 2) == GetFrameRate(stream.CodecTimeBase);
+ && roundedTimeBaseFPS == roundedDoubleFrameRate;
+
if (videoInterlaced || h264MbaffCoded)
{
stream.IsInterlaced = true;