Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wimil committed Nov 21, 2020
1 parent 5f9b0e6 commit 24b66aa
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/Filters/HLSFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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;
}

Expand All @@ -102,21 +102,25 @@ 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(),
"hls_segment_type" => $this->hls->getHlsSegmentType(),
"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()
);
}

/**
Expand Down Expand Up @@ -175,4 +179,4 @@ public function streamFilter(StreamInterface $stream): void
$this->getArgs($rep, $reps->end() !== $rep);
}
}
}
}
41 changes: 40 additions & 1 deletion src/Representation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -154,4 +160,37 @@ public function getSize(): Dimension
{
return $this->size;
}
}

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;
}
}

0 comments on commit 24b66aa

Please sign in to comment.