H5的video标签来播放视频。请问如何自动截取视频的第一帧作为视频的预览图片?
同问:
如果是跨域视频文件呢?
这个怎么解决?
<video id="video" controls="controls">
<source src="http://mt-development.oss-cn-hangzhou.aliyuncs.com/chance/feeds/video/5b72370f25998.mp4">
</video>
video 有个属性 poster
poster: A URL for an image to be shown while the video is downloading.
If this attribute isn't specified, nothing is displayed until the
first frame is available, then the first frame is shown as the poster
frame.
你只要设置
<video width="620" controls
poster="https://upload.wikimedia.org/wikipedia/commons/e/e8/Elephants_Dream_s5_both.jpg"
<source src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4" type="video/mp4"> <source src="https://archive.org/download/ElephantsDream/ed_hd.ogv" type="video/ogg"> <source src="https://archive.org/download/ElephantsDream/ed_hd.avi" type="video/avi"> Your browser doesn't support HTML5 video tag. </video>
就可以设置首屏图片了
6 回答3.3k 阅读✓ 已解决
5 回答6.3k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.7k 阅读✓ 已解决
4 回答2.6k 阅读
2 回答962 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
来源:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
演示https://www.youtube.com/watch?v=-ZZtYNIwYBU&feature=player_detailpage#t=194s