W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2011

[whatwg] HTML5 video: frame accuracy / SMPTE

From: Jeroen Wijering <jeroen@longtailvideo.com>
Date: Wed, 12 Jan 2011 14:23:39 +0100
Message-ID: <CFEAEB0A-09D4-4AF2-A7CF-D5EC19AEE98F@longtailvideo.com>

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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:29 UTC