I'm working on a project where we are using the value from the video element's currentTime property to perform processing on the server backend using ffmpeg. I've come across an issue where the video element seems to report a time code that is slightly different from the time code ffmpeg needs to access the correct point in the video.
So for instance in Firefox if the currentTime property reports that the current video time is 26.83 I might find that the frame I really want ended at 26.72 and so if I use the time to extract a frame using ffmpeg on the server I get the next frame instead of the current frame.
The amount of offset seems to be slightly different in different parts of the video and in different videos. But the offset is usually close to one tenth of a second in Firefox. In chrome the currentTime actually seems to be ahead or the correct currentTime by about 5 hundredths of a second. It's more difficult to figure out the offset in IE because the place where the frame shifts seems to change as I enter different time codes to look for the exact time code where the frame changes.
I'm pretty sure the time as used by ffmpeg is the correct time. It seems to agree more closely with other video editing software such as adobe premier.
Any ideas on what could be causing this behavior?
JS to get currentTime:
AVideo.prototype.getCurrentTime = function()
{
return this.videoElement[0].currentTime;
};
Resulting ffmpeg command:
ffmpeg -y -i '/tmp/myVideo.mov' -vframes 1 -ss 2.4871 -f image2 -y '/tmp/myFrame.jpg' 2>&1