WIP
This commit is contained in:
parent
6669b63bd2
commit
2b670f30fd
1 changed files with 53 additions and 0 deletions
|
@ -398,12 +398,62 @@ function extractFragmentedMP4( $filename ) {
|
||||||
return $segments;
|
return $segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function playlist( $filename, $segments ) {
|
||||||
|
/*
|
||||||
|
#EXTM3U
|
||||||
|
#EXT-X-VERSION:7
|
||||||
|
#EXT-X-TARGETDURATION:10
|
||||||
|
#EXT-X-MEDIA-SEQUENCE:0
|
||||||
|
#EXT-X-PLAYLIST-TYPE:VOD
|
||||||
|
#EXT-X-MAP:URI="new-vp9.mp4",BYTERANGE="811@0"
|
||||||
|
#EXTINF:10.000000,
|
||||||
|
#EXT-X-BYTERANGE:1058384@811
|
||||||
|
new-vp9.mp4
|
||||||
|
#EXTINF:10.000000,
|
||||||
|
#EXT-X-BYTERANGE:1085979@1059195
|
||||||
|
new-vp9.mp4
|
||||||
|
#EXTINF:10.000000,
|
||||||
|
#EXT-X-BYTERANGE:1268619@2145174
|
||||||
|
new-vp9.mp4
|
||||||
|
#EXTINF:10.000000,
|
||||||
|
#EXT-X-BYTERANGE:1418664@3413793
|
||||||
|
new-vp9.mp4
|
||||||
|
#EXTINF:10.000000,
|
||||||
|
#EXT-X-BYTERANGE:1129265@4832457
|
||||||
|
new-vp9.mp4
|
||||||
|
...
|
||||||
|
#EXT-X-ENDLIST
|
||||||
|
*/
|
||||||
|
$lines = [];
|
||||||
|
$lines[] = "#EXTM3U";
|
||||||
|
$lines[] = "#EXT-X-TARGETDURATION:10";
|
||||||
|
$lines[] = "#EXT-MEDIA-SEQUENCE:0";
|
||||||
|
$lines[] = "#EXT-PLAYLIST-TYPE:VOD";
|
||||||
|
|
||||||
|
$init = $segments['init'] ?? false;
|
||||||
|
if ( $init ) {
|
||||||
|
$lines[] = "#EXT-X-MAP:URI=\"$filename\",BYTERANGE=\"{$init['size']}@{$init['start']}\"";
|
||||||
|
$lines[] = $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
$n = count( $segments ) - 1;
|
||||||
|
for ( $i = 0; $i < $n; $i++ ) {
|
||||||
|
$segment = $segments[$i];
|
||||||
|
$lines[] = "#EXTINF:{$segment['duration']}";
|
||||||
|
$lines[] = "#EXT-X-BYTERANGE:{$segment['size']}@{$segment['start']}";
|
||||||
|
$lines[] = $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode( "\n", $lines );
|
||||||
|
}
|
||||||
|
|
||||||
$argv = $_SERVER['argv'];
|
$argv = $_SERVER['argv'];
|
||||||
$self = array_shift( $argv );
|
$self = array_shift( $argv );
|
||||||
$filename = array_shift( $argv );
|
$filename = array_shift( $argv );
|
||||||
$segments = extractFragmentedMP4( $filename );
|
$segments = extractFragmentedMP4( $filename );
|
||||||
//var_dump( $segments );
|
//var_dump( $segments );
|
||||||
|
|
||||||
|
/*
|
||||||
foreach ( $segments as $key => $segment ) {
|
foreach ( $segments as $key => $segment ) {
|
||||||
if ( $key === 'init' ) {
|
if ( $key === 'init' ) {
|
||||||
print "$key {$segment['start']},{$segment['size']}\n";
|
print "$key {$segment['start']},{$segment['size']}\n";
|
||||||
|
@ -411,3 +461,6 @@ foreach ( $segments as $key => $segment ) {
|
||||||
print "$key {$segment['timestamp']},{$segment['duration']} @ {$segment['start']},{$segment['size']}\n";
|
print "$key {$segment['timestamp']},{$segment['duration']} @ {$segment['start']},{$segment['size']}\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
$m3u8 = playlist( urlencode( $filename ), $segments );
|
||||||
|
print $m3u8 . "\n";
|
Loading…
Reference in a new issue