[whatwg] HTML5 video: frame accuracy / SMPTE

On Jan 12, 2011, at 2:05 PM, Rob Coenen wrote:

> The need for SMPTE still remains as I want to be able to do things such as video.seekTo(smpte_timecode_converted_to_seconds, seek_exact=true); so that my video goes to exactly the exact frame as indicated by smpte_timecode_converted_to_seconds. Think chapter bookmarking, scene indexing, etc.
> 

With the step() in place, this would be a simple convenience function. This pseudo-code is not ideal and making some assumptions, but the approach should work: 

function seekToTimecode(timecode) {
    var seconds = convert_timecode_to_seconds(timecode);
    videoElement.seek(seconds);
    var delta = seconds - videoElement.currentTime;
    while (delta > 0) {
        videoElement.step(1);
        delta = seconds - videoElement.currentTime;
    }
};

Its basically stepping to the frame that's closest to the timecode (as elaborated by others, there's no such thing as timecode in MP4/WebM. It's just timestamps). 

Note you actually do want to have this conversion taking place in javascript, since there are many reasons to adjust/offset the conversion (sync issues, timecode base differences, ...). If it's locked  up inside the browser API you have to do duplicate work around it if the input files / conversion assumptions don't align.

- Jeroen

Received on Wednesday, 12 January 2011 05:23:39 UTC