1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the PHP-FFmpeg-video-streaming package. |
5
|
|
|
* |
6
|
|
|
* (c) Amin Yazdanpanah <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Streaming\Format; |
13
|
|
|
|
14
|
|
|
final class HEVC extends StreamFormat |
15
|
|
|
{ |
16
|
|
|
private const MODULUS = 2; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* HEVC constructor. |
20
|
|
|
* @param string $video_codec |
21
|
|
|
* @param string|null $audio_codec |
22
|
|
|
* @param bool $default_init_opts |
23
|
|
|
*/ |
24
|
|
|
public function __construct(string $video_codec = 'libx265', string $audio_codec = 'aac', bool $default_init_opts = true) |
25
|
|
|
{ |
26
|
|
|
$this |
27
|
|
|
->setVideoCodec($video_codec) |
28
|
|
|
->setAudioCodec($audio_codec); |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* set the default value of h265 codec options |
32
|
|
|
* see https://ffmpeg.org/ffmpeg-codecs.html#Options-29 for more information about options |
33
|
|
|
*/ |
34
|
|
|
if ($default_init_opts) { |
35
|
|
|
$this->setAdditionalParameters([ |
36
|
|
|
'keyint_min' => 25, |
37
|
|
|
'g' => 250, |
38
|
|
|
'sc_threshold' => 40 |
39
|
|
|
]); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Returns the list of available audio codecs for this format. |
45
|
|
|
* |
46
|
|
|
* @return array |
47
|
|
|
*/ |
48
|
|
|
public function getAvailableAudioCodecs() |
49
|
|
|
{ |
50
|
|
|
return ['aac', 'libvo_aacenc', 'libfaac', 'libmp3lame', 'libfdk_aac']; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getAvailableVideoCodecs(): array |
54
|
|
|
{ |
55
|
|
|
return ['libx265', 'h265', 'hevc_nvenc']; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return int |
60
|
|
|
*/ |
61
|
|
|
public function getModulus() |
62
|
|
|
{ |
63
|
|
|
return static::MODULUS; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Returns true if the current format supports B-Frames. |
68
|
|
|
* |
69
|
|
|
* @see https://wikipedia.org/wiki/Video_compression_picture_types |
70
|
|
|
* |
71
|
|
|
* @return Boolean |
72
|
|
|
*/ |
73
|
|
|
public function supportBFrames() |
74
|
|
|
{ |
75
|
|
|
return true; |
76
|
|
|
} |
77
|
|
|
} |