2011-08-24 15 views
9

Actualmente estoy tratando de personalizar un reproductor de video HTML5 para que pueda agregar un botón que devuelva el número de fotograma actual.¿Puedo obtener el número del fotograma actual en un video HTML5?

Digamos que tengo un video de 30 fps que dura 90 segundos. Cuando hago clic en ese botón, quiero que me imprima el número del fotograma actual. ¿Es eso posible?

Respuesta

1

No creo que haya una velocidad de cuadros estándar establecida en los navegadores ni ninguna forma de acceder al marco actual con un video html5. Sin embargo, lo que podría hacer es utilizar la velocidad de cuadro estándar de televisión de 29,97 fotogramas por segundo y simplemente multiplique eso por el tiempo actual del video como así: (vid.currentTime * 29.97).toPrecision(6).

Aquí es un violín I fijó la demostración de cómo enlazar a un botón para obtener el cuadro actual: http://jsfiddle.net/893aM/1/

+1

Aunque se trata de una respuesta de edad, por favor, tenga en cuenta que "estándar de televisión" no es el mismo en los EE.UU. como en el resto del mundo. La mayoría de los videos web están codificados y filmados a 25FPS de todos modos. – WesleyE

+0

'.currentTime' no es lo suficientemente preciso como para bajar a un nivel por fotograma. – Brad

3

Creo que se puede utilizar la siguiente API para Webkit/navegador basado en Mozilla:

Mozilla han implementado las siguientes estadísticas en Firefox:

mozParsedFrames - number of frames that have been demuxed and extracted out of the media. 
mozDecodedFrames - number of frames that have been decoded - converted into YCbCr. 
mozPresentedFrames - number of frames that have been presented to the rendering pipeline for rendering - were "set as the current image". 
mozPaintedFrames - number of frames which were presented to the rendering pipeline and ended up being painted on the screen. Note that if the video is not on screen (e.g. in another tab or scrolled off screen), this counter will not increase. 
mozFrameDelay - the time delay between presenting the last frame and it being painted on screen (approximately). 

Mozilla también están trabajando en algunas de las estadísticas enumeradas aquí.

Webkit han implementado las siguientes:

webkitAudioBytesDecoded - number of audio bytes that have been decoded. 
webkitVideoBytesDecoded - number of video bytes that have been decoded. 
webkitDecodedFrames - number of frames that have been demuxed and extracted out of the media. 
webkitDroppedFrames - number of frames that were decoded but not displayed due to performance issues. 

que sigue investigando la resolución sobre IE9 ...

Referencia: http: //wiki.whatwg.org/wiki/Video_Metrics

Cuestiones relacionadas