-
Notifications
You must be signed in to change notification settings - Fork 27
/
HLS.php
54 lines (44 loc) · 1.88 KB
/
HLS.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* =========================================================
* HLS Live
* =========================================================
* The example is similar to the on-demand, see HLS example.
*/
use Shaka\Options\Streams\HLSStream;
require_once '../init.require.php';
$stream1 = HLSStream::input( 'udp://225.1.1.8:8001?interface=172.29.46.122')
->streamSelector('audio')
->initSegment($output_path . 'audio_init.mp4')
->segmentTemplate($output_path . 'audio_$Number$.m4s')
->playlistName('audio.m3u8')
->HLSGroupId('audio')
->HLSName('ENGLISH');
$stream2 = HLSStream::input( 'udp://225.1.1.8:8001?interface=172.29.46.122')
->streamSelector('video')
->initSegment($output_path . 'h264_360p_init.mp4')
->segmentTemplate($output_path . 'h264_360p_$Number$.m4s')
->playlistName('h264_360p.m3u8');
$stream3 = HLSStream::input( 'udp://225.1.1.8:8002?interface=172.29.46.122')
->streamSelector('video')
->initSegment($output_path . 'h264_480p_init.mp4')
->segmentTemplate($output_path . 'h264_480p_$Number$.m4s')
->playlistName('h264_480p.m3u8');
$stream4 = HLSStream::input( 'udp://225.1.1.8:8003?interface=172.29.46.122')
->streamSelector('video')
->initSegment($output_path . 'h264_720p_init.mp4')
->segmentTemplate($output_path . 'h264_720p_$Number$.m4s')
->playlistName('h264_720p.m3u8');
$stream5 = HLSStream::input( 'udp://225.1.1.8:8004?interface=172.29.46.122')
->streamSelector('video')
->initSegment($output_path . 'h264_1080p_init.mp4')
->segmentTemplate($output_path . 'h264_1080p_$Number$.m4s')
->playlistName('h264_1080p.m3u8');
$export = \Shaka\Shaka::initialize()
->streams($stream1, $stream2, $stream3, $stream4, $stream5)
->mediaPackaging()
->HLS($output_path . 'h264_master.m3u8', function ($options) {
return $options->HLSPlaylistType('LIVE');
})
->export();
echo $export;