Microsoft's Media Foundation has a mp4 file source implementation that doesn't support well the distinction between presentation and decode timestamps. When H.264 video content is encoded with so-called B-Frames - present in Main and High profiles - this requires some of the later frames in the stream to be decoded earlier (leading to out-of-order layout in the file). The resulting timestamp offsets and their impact on track duration is incorrectly reported in the API, causing internal issues in end-detection and looping implementation.
We do have some countermeasures to work around these issues, but when they persist, the best approach is to encode with the Baseline H.264 profile, which doesn't use B-Frames. The consequence is that the video will be less compact but also has the advantage of taking less computing resources for decoding.