Using seek() and PlayHeadTime() with FLVPlayback component of video files in Flash can be quite inaccurate. We had the same problem when we were building a prototype for our project, which involved switching and syncing of videos using specific timing. PlayHeadTime gave a decimal value, but whenever we would do a seek() using the PlayHeadTime value on a video, the timing would be off by 0.5-1 second.
Apparently, the accuracy of the seek() function is dependent on the keyFrameInterval of the video and the FPS meaning Precision = keyFrameInterval / FPS.
So for example, if you have a keyFrameInterval = 30 (1st frame will be a keyframe, 30th frame will be a keyframe, 60th frame … etc.) and FPS is set on 15, you’ll only be able to seek in 2-seconds intervals of time (precision = 30 / 15).
To make the seeking more accurate, set the key frame distance when exporting your video with Adobe Premiere. This option can be found in the “video” tab, “Advanced Settings”, check “Set Key Frame Distance” and set the key frame distance lower. Export it and now your seek() accuracy would be more precise!
Related Posts
November 3, 2012
[How] Combine Text Files Into One File
March 4, 2012
[HOW] HTML/CSS: Prevent Scrollbar Jump
May 8, 2011
Project Blender – Day4: Eye for an Eye
February 1, 2018
[FIX] Unity3D – Moving Files Failed Error When Making Build
I was trying out the Google Player Services plugin and got this error message when I was trying to make an Android build which prevented me from finishing the build.
2 Comments
Leave a Reply to Ahmed Fouad Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Wowww..
Does this mean if I set it to 1 (A key frame every frame), I will get a 100% accuracy ??
If your video is for example on 30 fps and you set the key frame distance to 1 key, you’ll get a precision of 1/30 second-intervals of time between each frame. It’s technically not 100% accurate, but the interval is so small that you probably wouldn’t notice any difference when seeking through the video 🙂