Search code examples
iosavfoundationhttp-live-streamingzencoder

AV Foundation reporting player item duration incorrectly


I am trying to play a video on iOS using AVPlayer that is encoded with zencoder. The problem I am seeing is that the duration that the player item reports is rounded / imprecise. For example, the video duration might be 173.134 and the player item will report it as a flat 174.0. This causes problems with detecting loaded percentage and other related things. If I try to use the video without encoding everything is reported correctly and precisely.

Has anyone else ever seen this or have a solution?


Solution

  • The problem turned out to be a problem with the source video / zencoder. The audio track was a slightly different length than the video which caused problems with the encoding. Cutting off the last second of the video so that the track durations would match up fixed the problem.