diff --git a/src/Filters/HLSFilter.php b/src/Filters/HLSFilter.php index f08cdfc..1224f10 100644 --- a/src/Filters/HLSFilter.php +++ b/src/Filters/HLSFilter.php @@ -82,7 +82,7 @@ private function getKeyInfo(): array */ private function getInitFilename(Representation $rep): string { - return $this->seg_sub_dir . $this->filename . "_" . $rep->getHeight() ."p_". $this->hls->getHlsFmp4InitFilename(); + return $this->seg_sub_dir . $this->filename . "_" . $rep->getHeight() . "p_" . $this->hls->getHlsFmp4InitFilename(); } /** @@ -91,7 +91,7 @@ private function getInitFilename(Representation $rep): string */ private function getSegmentFilename(Representation $rep): string { - $ext = ($this->hls->getHlsSegmentType() === "fmp4") ? "m4s" : "ts"; + $ext = ($this->hls->getHlsSegmentType() === "fmp4") ? "m4s" : $rep->getHlsSegmentExtension(); return $this->seg_filename . "_" . $rep->getHeight() . "p_%04d." . $ext; } @@ -102,6 +102,8 @@ private function getSegmentFilename(Representation $rep): string private function initArgs(Representation $rep): array { $init = [ + "preset" => $rep->getPereset(), + "crf" => $rep->getCRF(), "hls_list_size" => $this->hls->getHlsListSize(), "hls_time" => $this->hls->getHlsTime(), "hls_allow_cache" => (int)$this->hls->isHlsAllowCache(), @@ -109,14 +111,16 @@ private function initArgs(Representation $rep): array "hls_fmp4_init_filename" => $this->getInitFilename($rep), "hls_segment_filename" => $this->getSegmentFilename($rep), "s:v" => $rep->size2string(), - "b:v" => $rep->getKiloBitrate() . "k" + "b:v" => $rep->getKiloBitrate() . "k", ]; - return array_merge($init, + return array_merge( + $init, $this->getAudioBitrate($rep), $this->getBaseURL(), $this->flags(), - $this->getKeyInfo()); + $this->getKeyInfo() + ); } /** @@ -175,4 +179,4 @@ public function streamFilter(StreamInterface $stream): void $this->getArgs($rep, $reps->end() !== $rep); } } -} \ No newline at end of file +} diff --git a/src/Representation.php b/src/Representation.php index 1b45969..5aa8086 100644 --- a/src/Representation.php +++ b/src/Representation.php @@ -29,6 +29,12 @@ class Representation implements RepresentationInterface /** @var array $hls_stream_info hls stream info */ private $hls_stream_info = []; + private $hls_segment_extension = 'ts'; + + private $preset = 'medium'; + + private $crf = 23; + /** * @return string | null */ @@ -154,4 +160,37 @@ public function getSize(): Dimension { return $this->size; } -} \ No newline at end of file + + public function setHlsSegmentExtension(String $extension) + { + $this->hls_segment_extension = $extension; + return $this; + } + + public function getHlsSegmentExtension() + { + return $this->hls_segment_extension; + } + + public function setPreset($preset) + { + $this->preset = $preset; + return $this; + } + + public function getPereset() + { + return $this->preset; + } + + public function setCRF(Int $crf) + { + $this->crf = $crf; + return $this; + } + + public function getCRF() + { + return $this->crf; + } +}