目前所有浏览器都实现了 HTML5
但是,我不知道浏览器如何计算帧速率。
他们要么读取视频文件的容器信息以获取某些 fps
属性,要么自行计算。
通过使用 FFmpeg,您可以通过 FFmpeg -i video.avi
获得该结果,它返回 Stream #0.0: Video: libvpx, yuv420p, 512x288, PAR 1:1 DAR 16:9, 25 fps , 25 tbr, 1k tbn, 25 tbc
,您可以在那里看到 fps
。
问题是:这准确吗?如果不是,有没有准确的计算方法?我只是想模仿浏览器,这样我就可以准确地进行帧搜索。
All browsers currently implement HTML5 <video
> frame-seeking API as time divisions. e.g. In a video of 10fps, Frame #10 is time=1.0
seconds. Thus, if you want to be able to frame-seek accurately, i.e. advance one frame forward, you need to go to time=1.1
seconds. This frame-to-time calculation is done by knowing the video's frame rate (fps).
However, I don't know how the browsers calculate the frame rate.
They either read the video file's container information for some fps
property, or calculate it on their own.
By using FFmpeg, you can get that by FFmpeg -i video.avi
which returns Stream #0.0: Video: libvpx, yuv420p, 512x288, PAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 25 tbc
, and you can see the fps
there.
The question is: Is this accurate? If not, is there an accurate way of calculating this? I just want to mimic the browsers so I can frame-seek accurately.
发布评论
评论(1)
视频的帧速率不是计算的,而是作为视频元数据的一部分存储的。视频标题中只有一个字段表示每秒有多少帧(或者可能是每帧显示的时间量)。这与浏览器了解视频分辨率的方式相同。
The framerate of a video isn't calculated, it's stored as part of the video's metadata. There's just a field in the video's header that says how many frames per second (or possibly the amount of time each frame is shown). It's the same way the browser knows the video's resolution.