Html 从 JavaScript 更改 HTML5 视频的质量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17614660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:02:42  来源:igfitidea点击:

Change HTML5 video’s quality from JavaScript

javascripthtmlhtml5-video

提问by tenstar

In YouTube, we can change the quality of the video from a dropdown like 360p, 144p, 240p, etc. Can we do the same with HTML5 video element from JavaScript?

在 YouTube 中,我们可以从 360p、144p、240p 等下拉菜单中更改视频的质量。我们可以对 JavaScript 中的 HTML5 视频元素做同样的事情吗?

回答by Quentin

Manual selection of quality is just a matter of:

手动选择质量只是一个问题:

  1. Saving the currentTimein a variable
  2. setting the video srcto the URL of a different video (with the same content at a different quality)
  3. Setting the currentTimeto the value in the variable
  4. Playing the video
  1. 保存currentTime在变量中
  2. 将视频设置src为不同视频的 URL(具有不同质量的相同内容)
  3. 将 设置currentTime为变量中的值
  4. 播放视频

回答by Guilherme Nascimento

You want to use the youtube-apiwith html5-playeror you are using video files on your server? if youtube-api, try:

您想将youtube-apihtml5-player一起使用,还是在您的服务器上使用视频文件?如果 youtube-api,请尝试:

https://developers.google.com/youtube/iframe_api_reference

https://developers.google.com/youtube/iframe_api_reference

[edit]

[编辑]

The javascriptor actionscriptonly access different videos, as they do not have exchanged the quality would have to recompile in real time (which is unfeasible).

javascriptactionscript唯一的访问不同的视频,因为他们没有交换的质量将会有实时(这是不可行的)重新编译。

Do you happen to be interested, you can use ffmpegon your server (or before you upload the videos to your desktop) to generate various formats (qualities) of video, you can study the following link: http://ffmpeg.org/trac/ffmpeg/wiki/Creating%20multiple%20outputs

有没有兴趣,你可以在你的服务器上(或者在你把视频上传到桌面之前)使用ffmpeg来生成各种格式(质量)的视频,你可以研究以下链接:http: //ffmpeg.org/ trac/ffmpeg/wiki/Creating%20multiple%20outputs

hope this helps.

希望这可以帮助。