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
Change HTML5 video’s quality from JavaScript
提问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:
手动选择质量只是一个问题:
- Saving the
currentTime
in a variable - setting the video
src
to the URL of a different video (with the same content at a different quality) - Setting the
currentTime
to the value in the variable - Playing the video
- 保存
currentTime
在变量中 - 将视频设置
src
为不同视频的 URL(具有不同质量的相同内容) - 将 设置
currentTime
为变量中的值 - 播放视频
回答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-api与html5-player一起使用,还是在您的服务器上使用视频文件?如果 youtube-api,请尝试:
https://developers.google.com/youtube/iframe_api_reference
https://developers.google.com/youtube/iframe_api_reference
[edit]
[编辑]
The javascript
or actionscript
only access different videos, as they do not have exchanged the quality would have to recompile in real time (which is unfeasible).
的javascript
或actionscript
唯一的访问不同的视频,因为他们没有交换的质量将会有实时(这是不可行的)重新编译。
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.
希望这可以帮助。