-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode.php
More file actions
52 lines (45 loc) · 1.47 KB
/
Copy pathencode.php
File metadata and controls
52 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require_once __DIR__ . '/vendor/autoload.php';
ini_set('memory_limit', '2048M');
/** -----提示:仅支持baseline profile级别的h264 + aac 格式的flv/mp4/hls重编码------ */
$profiles = [
'240p' => [
'width' => 426,
'height' => 240,
'bitrate' => 300000,
'fps' => 10,
'audioBitrate' => 48000,
'qp' => 10,
'watermark'=>false,
'watermark_file'=> __DIR__."/watermark_80x16.yuv",
'motionWorkers' => 8,
],
];
/** flv转hls重编码 */
$generator = new \Xiaosongshu\Flv2mp4\Recode\PurePhpHlsGenerator(
$profiles,
__DIR__ . '/hls/output',
true,//是否开启分布式多进程加速
);
$startTime = time();
$generator->processFlv(__DIR__ . '/test.flv');
$endTime = time();
$cost = $endTime - $startTime;
echo "HLS 生成完成!\n";
echo "索引地址: hls/output/master.m3u8\n";
echo "cost {$cost}s\n";
$config = $profiles['240p'];
/** 重编码flv文件 */
//$start1 = time();
//$recoder = new \Xiaosongshu\Flv2mp4\Recode\FlvRecoder($config, true);
//$recoder->processFlv(__DIR__ . '/test.flv', __DIR__.'/output.flv');
//$end1 = time();
//$cost1 = $end1 - $start1;
//echo "flv重编码完成,耗时{$cost1}s\r\n";
/** 重编码mp4文件 */
//$start2 = time();
//$recoder = new \Xiaosongshu\Flv2mp4\Recode\Mp4Recoder($config, true);
//$recoder->processMp4(__DIR__ . '/demo.mp4', __DIR__ . '/output.mp4');
//$end2 = time();
//$cost2 = $end2 - $start2;
//echo "mp4重编码完成 {$cost2}s\r\n";