티스토리 뷰

hls.js를 이용해서 hls 영상을 실시간 스트리밍으로 전송해 보았습니다.

 

 

아래의 링크를 통해 hls.js 를 더 자세히 보실 수 있습니다.

 

hls.js 바로가기 : github.com/video-dev/hls.js/ 

 

 

아래와 같이 CDN을 이용해서 쉽게 구현이 가능합니다.

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>hls.js</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body>
<video controls autoplay id="video-player"></video>
<script>
	var video = document.getElementById('video-player');
	var videoSrc = 'http://{Domain or IP}:{Port}/{Application}/_definst_/mp4:{Path}/{File Name}/playlist.m3u8';
	//
	// First check for native browser HLS support
	//
	if (video.canPlayType('application/vnd.apple.mpegurl')) {
		video.src = videoSrc;
		//
		// If no native HLS support, check if hls.js is supported
		//
	} else if (Hls.isSupported()) {
		var hls = new Hls();
		hls.loadSource(videoSrc);
		hls.attachMedia(video);
	}
</script>
</body>
</html>

 

 

아래 사이트도 참고!

https://docs.gumlet.com/docs/insights-hlsjs-web

댓글