The same file plays properly in Windows Media Player, which MediaElement is supposed to be using under the hood. It also plays properly on my dev computer with an Nvidia adapter. I tried bypassing hardware decoding and got the same result. It's beginning to look like a Microsoft fumble, but is there something else I ought to try before I give up and re-encode everything at full range?

[Attachment 49397 - Click to enlarge] ]]>

Suggestions for improvement, modifications and bug reports are welcome.

Code:

`# Code by David Heidelberger, adapted from Andrew Duncan`

# http://www.davidheidelberger.com/blog/?p=29

# Given an int called framenumber and a double called framerate

# Framerate should be 29.97, 59.94, or 23.976, otherwise the calculations will be off.

import time

import math

d = 0

m = 0

framerate = 30 / 1.001 #29.97

framenumber = 0

framePeriod = 1 / framerate

while framenumber < 120:

dropFrames = round(framerate * .066666) #Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate

framesPerHour = round(framerate*60*60) #Number of frames in an hour

framesPer24Hours = framesPerHour*24 #Number of frames in a day - timecode rolls over after 24 hours

framesPer10Minutes = round(framerate * 60 * 10) #Number of frames per ten minutes

framesPerMinute = (round(framerate)*60)- dropFrames #Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames

if framenumber < 0: #Negative time. Add 24 hours.

framenumber=framesPer24Hours+framenumber

#If framenumber is greater than 24 hrs, next operation will rollover clock

framenumber = framenumber % framesPer24Hours #% is the modulus operator, which returns a remainder. a % b = the remainder of a/b

#d = framenumber\framesPer10Minutes # \ means integer division, which is a/b without a remainder. Some languages you could use floor(a/b)

d = math.floor(framenumber/framesPer10Minutes)

m = framenumber % framesPer10Minutes

#In the original post, the next line read m>1, which only worked for 29.97. Jean-Baptiste Mardelle correctly pointed out that m should be compared to dropFrames.

if m>dropFrames:

framenumber=framenumber + (dropFrames*9*d) + math.floor(dropFrames*((m-dropFrames)/framesPerMinute))

else:

framenumber = framenumber + dropFrames*9*d

frRound = round(framerate)

frames = framenumber % frRound

seconds = math.floor(framenumber / frRound) % 60

minutes = math.floor(math.floor(framenumber / frRound) / 60) % 60

hours = math.floor(math.floor(math.floor(framenumber / frRound) / 60) / 60)

print (round(hours),":",round(minutes),":",round(seconds),":",round(frames))

framenumber += 1

time.sleep(framePeriod)