Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Jan 9, 2025
1 parent b7da420 commit cb20fa0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions objects/HLSProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public static function createHLSWithAudioTracks($pathFileName, $destinationFile)
file_put_contents($destinationFile . $keyFileName, $key);

// Create keyinfo file for HLS encryption
$str = "../{$keyFileName}".PHP_EOL;
$str = "../{$keyFileName}" . PHP_EOL;
$str .= "{$destinationFile}{$keyFileName}";
file_put_contents($keyInfoFile, $str);
}

// Initialize the master playlist content
$masterPlaylist = "#EXTM3U".PHP_EOL;
$masterPlaylist .= "#EXT-X-VERSION:3".PHP_EOL;
$masterPlaylist = "#EXTM3U" . PHP_EOL;
$masterPlaylist .= "#EXT-X-VERSION:3" . PHP_EOL;

// Generate separate audio-only HLS streams for each audio track
foreach ($audioTracks as $key => $track) {
Expand All @@ -69,10 +69,10 @@ public static function createHLSWithAudioTracks($pathFileName, $destinationFile)
rmdir("{$destinationFile}audio_tracks/{$langDir}");
unset($audioTracks[$key]);
} else {
_error_log("HLSProcessor: createHLSWithAudioTracks audioFile Success" );
_error_log("HLSProcessor: createHLSWithAudioTracks audioFile Success");
// Add audio track entry to the master playlist
$default = ($track->index == 0) ? "YES" : "NO"; // Set first audio track as default
$masterPlaylist .= "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio_group\",NAME=\"{$track->title}\",LANGUAGE=\"{$language}\",DEFAULT={$default},AUTOSELECT=YES,URI=\"audio_tracks/{$langDir}/audio.m3u8\"".PHP_EOL;
$masterPlaylist .= "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio_group\",NAME=\"{$track->title}\",LANGUAGE=\"{$language}\",DEFAULT={$default},AUTOSELECT=YES,URI=\"audio_tracks/{$langDir}/audio.m3u8\"" . PHP_EOL;
}
}

Expand All @@ -90,8 +90,8 @@ public static function createHLSWithAudioTracks($pathFileName, $destinationFile)
$outputFile = "{$dir}index.m3u8";

// Add resolution playlist entry to the master playlist
$masterPlaylist .= "#EXT-X-STREAM-INF:BANDWIDTH=" . ($rate * 1000) . ",RESOLUTION=-2x{$value},AUDIO=\"audio_group\"".PHP_EOL;
$masterPlaylist .= "res{$value}/index.m3u8".PHP_EOL;
$masterPlaylist .= "#EXT-X-STREAM-INF:BANDWIDTH=" . ($rate * 1000) . ",RESOLUTION=-2x{$value},AUDIO=\"audio_group\"" . PHP_EOL;
$masterPlaylist .= "res{$value}/index.m3u8" . PHP_EOL;

// Append FFmpeg command for this resolution
$ffmpegCommand .= self::getFFmpegCommandForResolution($pathFileName, $value, $rate, $framerate, $audioTracks, $keyInfoFile, $outputFile);
Expand All @@ -113,8 +113,8 @@ public static function createHLSWithAudioTracks($pathFileName, $destinationFile)
$outputFile = "{$dir}index.m3u8";

// Add resolution playlist entry to the master playlist
$masterPlaylist .= "#EXT-X-STREAM-INF:BANDWIDTH=" . ($rate * 1000) . ",RESOLUTION=-2x{$resolution},AUDIO=\"audio_group\"".PHP_EOL;
$masterPlaylist .= "res{$resolution}/index.m3u8".PHP_EOL;
$masterPlaylist .= "#EXT-X-STREAM-INF:BANDWIDTH=" . ($rate * 1000) . ",RESOLUTION=-2x{$resolution},AUDIO=\"audio_group\"" . PHP_EOL;
$masterPlaylist .= "res{$resolution}/index.m3u8" . PHP_EOL;

// Append FFmpeg command for this resolution
$ffmpegCommand .= self::getFFmpegCommandForResolution($pathFileName, $resolution, $rate, $framerate, $audioTracks, $keyInfoFile, $outputFile);
Expand Down

0 comments on commit cb20fa0

Please sign in to comment.