HTML视频播放器必须知道它正在播放的文件的帧率,否则它将不可避免地以错误的速度播放视频。
如何获取当前加载视频的视频播放器当前使用的帧率?
发布于 2021-02-18 02:27:16
如果您想要帧速率,请遵循以下解决方案。
$(video).on('timeupdate', function () {
var ct = document.getElementById('#video').currentTime;
var dur = document.getElementById('#video').duration;
var videoProgressPos = ct / dur;
console.log(videoProgressPos)
});此videoProgressPos变量将为您提供正在播放的视频的当前帧。我将JS和jQuery混合在一起,你可以根据自己的意愿开发它。如果我的回答对你没有帮助,请让我知道。谢谢。
发布于 2021-02-19 06:14:47
你可以用FFprobe测试你正在看的每个视频。它是FFMPEG的一部分,我已经在https://ffprobe.a.video上建立了一个在线版本。
它会告诉你比特率(以及关于你的视频的许多其他有趣的事实
它需要节点服务器和FFMPEG:
URL作为查询字符串发送,然后弹出到ffprobe...节点的其余部分正在格式化...
app.get('/probe', (req,res) =>{
let url = req.query.url;
console.log(" url="+url);
let ffprobeResult = ffprobe(url)
ffprobeResult.then(function(info){
//extract some essentials
//sometimes video is thr first stream.. someties second
var streamCount = info.format.nb_streams;
//format data is overall
var bitrate= info.format.bit_rate;
var sizeBytes = info.format.size;
var duration = info.format.duration;
var formatName = info.format.format_name;
var formatLong = info.format.format_long_name;
//get video/audio specific infos
for (var i=0;i<streamCount;i++){
if (info.streams[i].codec_type == "video"){
var height = info.streams[i].height;
var width =info.streams[i].width;
var aspectRatio = info.streams[i].display_aspect_ratio;
var videoCodec = info.streams[i].codec_name;
}else{
//audio
var audioCodec = info.streams[i].codec_name;
}
}
console.log(bitrate, sizeBytes, duration, formatLong);
console.log(height, width, aspectRatio, videoCodec, audioCodec);
var format = info.format;
var streams = info.streams;
console.log(format);
console.log(streams);
return res.render('results', {format, streams, bitrate, sizeBytes, duration, formatLong, height, width, aspectRatio, videoCodec,audioCodec});但是这些数据不会从HTML5视频播放器中暴露出来。
道格
https://stackoverflow.com/questions/66247703
复制相似问题