視訊播放ts hls m3u8 playbackRate
阿新 • • 發佈:2019-09-06
<script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script> <video id="video"></video> <script> if(Hls.isSupported()) { var video = document.getElementById('video'); var hls = new Hls(); hls.loadSource('http://www.streambox.fr/playlists/test_001/stream.m3u8'); hls.attachMedia(video); hls.on(Hls.Events.MANIFEST_PARSED,function() { video.play(); }); } </script>
ffmpeg -i e785b2c81c9e018296671a1287e99615_2.mp4 -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list out.m3u8 -segment_time 10 out%03d.ts
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<button onclick="getPlaySpeed()" type="button">播放速度是多少?</button>
<button onclick="setPlaySpeed()" type="button">將視訊設定為以快速播放</button>
<br />
<br />
<video id="video" controls="controls">
<source src="http://www.streambox.fr/playlists/test_001/stream.m3u8" type="video/mp4" >
</video>
<script>
var video = document.getElementById("video");
function getPlaySpeed() {
alert(video.playbackRate);//獲取視訊/音訊的播放速度
}
function setPlaySpeed() {
video.playbackRate=2;//設定視訊/音訊的播放速度
}
</script>
</body>
</html>