用ffmpeg将rtmp保存为m3u8
sudo ffmpeg -v verbose -i rtmp://www.sfsyxx.cn/live/test1 -c:v libx264 -c:a aac -ac 1 -strict -2 -crf 20 -profile:v main -maxrate 800k -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -start_number 1 -f segment -segment_list playlist.m3u8 -segment_list_flags +live -segment_time 10 out%03d.ts -hls_list_size 5 -hls_wrap 5
<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('playlist.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.play();
});
}
</script>
使用h5播放器 播放m3u8
评论区