-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make video decoder and encoder configurable
- Loading branch information
1 parent
00acd52
commit 9fba1cd
Showing
5 changed files
with
129 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum Decoder: string | ||
{ | ||
// | ||
case CPU = 'cpu'; | ||
case NVIDIA_CUDA = 'nvidia_cuda'; | ||
|
||
public function getInitialParameters(bool $forMp4Fallback = false): array | ||
{ | ||
return array_merge( | ||
match ($this) { | ||
Decoder::NVIDIA_CUDA => [ | ||
'-hwaccel', 'cuda', | ||
'-hwaccel_output_format','cuda', | ||
'-extra_hw_frames', config('transmorpher.decoder.nvidia.hwFrames'), | ||
], | ||
default => [] | ||
}, | ||
config('transmorpher.initial_transcoding_parameters') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum Encoder: string | ||
{ | ||
case CPU_H264 = 'cpu_h264'; | ||
case CPU_HEVC = 'cpu_hevc'; | ||
case NVIDIA_H264 = 'nvidia_h264'; | ||
case NVIDIA_HEVC = 'nvidia_hevc'; | ||
|
||
public function getAdditionalParameters(bool $forMp4Fallback = false): array | ||
{ | ||
return array_merge( | ||
$forMp4Fallback ? ['-b:v', config('transmorpher.encoder.bitrate')] : [], | ||
match ($this) { | ||
Encoder::NVIDIA_H264 => [ | ||
'-c:v', 'h264_nvenc', | ||
'-preset', config('transmorpher.encoder.nvidia.preset') | ||
], | ||
Encoder::NVIDIA_HEVC => [ | ||
// Fallback MP4 video should be h264 | ||
'-c:v', $forMp4Fallback ? 'h264_nvenc' : 'hevc_nvenc', | ||
'-preset', config('transmorpher.encoder.nvidia.preset') | ||
], | ||
default => [] | ||
}, | ||
config('transmorpher.additional_transcoding_parameters') | ||
); | ||
} | ||
|
||
public function getStreamingCodec(): string | ||
{ | ||
return match ($this) { | ||
Encoder::CPU_H264, Encoder::NVIDIA_H264 => 'x264', | ||
Encoder::CPU_HEVC, Encoder::NVIDIA_HEVC => 'hevc', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters