-
Notifications
You must be signed in to change notification settings - Fork 7
/
start.php
40 lines (28 loc) · 922 Bytes
/
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
<?php
/*
* By Pedroxam
*/
if(empty($_POST['code']) or empty($_POST['video']))
exit('error');
$root = dirname(__FILE__);
$parameter = trim($_POST['code']);
$video = trim($_POST['video']);
$input = $root . '/input/' . $video;
$output = $root . '/output/' . basename($video);
// ffmpeg path
// eg, for linux "/usr/bin/ffmpeg" and for windows, if you not set environment variables path, you can just enter path of ffmpeg.exe binary
$ffmpeg = 'ffmpeg';
$command = str_ireplace(['ffmpeg', 'INPUT', 'OUTPUT'], [$ffmpeg, $input, $output], $parameter);
$log = $root . '/log.txt';
//validate ffmpeg command
if (strpos($parameter, 'ffmpeg') !== false){
//Start Task
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
}
}