-
Notifications
You must be signed in to change notification settings - Fork 5
/
start.php
65 lines (51 loc) · 1.52 KB
/
start.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*
* By Pedram
* Telegram: @Pedroxam
* Email: pedroxam@gmail.com
*/
$root = dirname(__FILE__);
if(isset($_POST['log'])) {
exit(file_get_contents($root . '/log.txt'));
}
// Remove all illegal characters from a url
$url = filter_var(trim($_POST['url']), FILTER_SANITIZE_URL);
// Validate url
if (!filter_var($url, FILTER_VALIDATE_URL)) {
exit('error');
}
// Check Proxy
if(isset($_POST['proxy']) && !empty($_POST['proxy'])){
$proxy = "-http_proxy " . trim($_POST['proxy']);
}
else $proxy = "";
// Check Duration
if(isset($_POST['from']) && !empty($_POST['from'])
&& isset($_POST['to']) && !empty($_POST['to']))
{
if(strlen($_POST['from']) == 8 &&
strlen($_POST['to']) == 8
){
$from = trim($_POST['from']);
$_from = str_replace(':', '', $from);
$_to = str_replace(':', '', trim($_POST['to']));
$calc = intval($_to) - intval($_from);
$to = gmdate("H:i:s", $calc);
$duration = "-ss $from -t $to";
} else {
exit('error');
}
}
else $duration = "";
$output = $root . '/output/' . time() . '_';
$time = intval($_POST['time']);
$command = "ffmpeg $proxy -i \"$url\" $duration -c copy -flags +global_header -f segment -segment_time $time -segment_format_options movflags=+faststart -reset_timestamps 1 $output%d.mp4";
$log = './log.txt';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
pclose(popen("start /B " . $command . " 1> $log 2>&1", "r")); // Windows
}
else
{
shell_exec($command . " 1> $log 2>&1 >/dev/null &"); //Linux
}