Skip to content

Instantly share code, notes, and snippets.

@ramirez7
Last active March 29, 2023 16:10
Show Gist options
  • Select an option

  • Save ramirez7/5d3694954fad3c8d75c252d286b17d24 to your computer and use it in GitHub Desktop.

Select an option

Save ramirez7/5d3694954fad3c8d75c252d286b17d24 to your computer and use it in GitHub Desktop.

[Final result here]

<script src="./hls.js"></script>
<marquee direction="up"><h1>HLS STREAMING</h1></marquee>
<video id="video" controls></video>
<marquee direction="left"><h1>SO</h1></marquee>
<marquee direction="right"><h1>COOL</h1></marquee>
<
<script>
  if(Hls.isSupported()) {
    var video = document.getElementById('video');
    video.muted = 'muted';
    var hls = new Hls();
    hls.loadSource('./ld51-controller-demo-hls.m3u8');
    hls.attachMedia(video);
    hls.on(Hls.Events.MANIFEST_PARSED,function() {
      video.play();
  });
 }
</script>

I downloaded hls.js and served it locally.

I transcoded an mp4 to HLS (m3u8 playlist + ts video file(s)) with ffmpeg (thanks to this gist):

ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

This is what the final directory looks like:

[~/Videos/hls-test]$ ls
hls.js  hls-test.html  ld51-controller-demo-hls0.ts  ld51-controller-demo-hls.m3u8

I uploaded the files directory to my Digital Ocean Spaces and set them to public and it Just Worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment