Geschützte Streams

Bezeichnung

hls - Konvertiert ein Video in einen geschützten Stream

Übersicht

hls Video

Beschreibung

AES-verschlüsseltes HTTP Live Streaming (HLS)

Abhängigkeiten

ffmpeg

1
2
3
4
5
#!/bin/bash
ffmpeg -hide_banner -y -i "${1}" \
  -vf scale=w=640:h=360:force_original_aspect_ratio=decrease -c:a aac -b:a 128k -ac 2 -c:v h264 -preset medium -sc_threshold 0 -profile:v main -pix_fmt yuv420p -crf 20 -f hls -hls_time 6 -hls_enc 1 -hls_playlist_type vod -hls_segment_filename 360p_%03d.ts 360p.m3u8 \
  -vf scale=w=1280:h=720:force_original_aspect_ratio=decrease -c:a aac -b:a 128k -ac 2 -c:v h264 -preset medium -sc_threshold 0 -profile:v main -pix_fmt yuv420p -crf 20 -f hls -hls_time 6 -hls_enc 1 -hls_playlist_type vod -hls_segment_filename 720p_%03d.ts 720p.m3u8 \
  -vf scale=w=1920:h=1080:force_original_aspect_ratio=decrease -c:a aac -b:a 192k -ac 2 -c:v h264 -preset medium -sc_threshold 0 -profile:v main -pix_fmt yuv420p -crf 20 -f hls -hls_time 6 -hls_enc 1 -hls_playlist_type vod -hls_segment_filename 1080p_%03d.ts 1080p.m3u8;

Webseite

Abhängigkeiten

hls.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<!DOCTYPE html>
<html>
  <head>
    <title>AES-verschlüsselter HLS-Stream</title>
    <script src="hls.js"></script>
  </head>
  <body>
    <center>
      <p><video id="video" width="600px" controls></video></p>
    </center>
    <script src="stream.js"></script>
  </body>
</html>
1
2
3
4
5
6
7
8
9
var video = document.getElementById('video');
if (Hls.isSupported()) {
  var hls = new Hls();
  hls.loadSource("index.m3u8");
  hls.attachMedia(video);
}
else if (video.canPlayType('application/vnd.apple.mpegurl')) {
  video.src = videoSrc;
}
1
2
3
4
5
6
7
8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1500000,RESOLUTION=640x360
360p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3000000,RESOLUTION=1280x720
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=6000000,RESOLUTION=1920x1080
1080p.m3u8

Demo

Zurück