forked from amereservant/phpffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideoProcess.php
More file actions
91 lines (78 loc) · 3.1 KB
/
Copy pathvideoProcess.php
File metadata and controls
91 lines (78 loc) · 3.1 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
require 'database.php';
require 'config.php';
require 'functions.php';
//echo '<pre>';
//print_r($_POST);
//echo '</pre>';
//$sql = 'SELECT 1 from streams WHERE status = "Downloading" OR status = "Converting" LIMIT 1';
//$stmt = $pdo->prepare($sql);
//$stmt->execute();
//if ($stmt->fetchColumn()) echo('(Overload protection: <span style="color:red">OFF</span>) There is already a stream being converted or downloaded at the moment.<br>');
if (isset($_POST['queue']) || isset($_POST['queueUnlisted'])) {
if (isset($_POST['queueUnlisted'])) {
$unlisted = true;
} else {
$unlisted = false;
}
unset($_POST['queue'], $_POST['queueUnlisted']);
foreach ($_POST as $stream) {
$fkey = hash('crc32', $stream['vFilename'], false);
$data = [
'id' => substr($stream['vFilename'], 0, 19),
'title' => $stream['vTitle'],
'game' => $stream['vCategory'],
'status' => 'Conv_queue',
'fkey' => $fkey,
'date' => $stream['vDate'],
];
if ($unlisted) {
$data['status'] = 'Conv_queue_unlisted';
}
$sql = "INSERT IGNORE INTO streams (id, title, game, status, fkey, date) VALUES (:id, :title, :game, :status, :fkey, :date)";
$stmt = $pdo->prepare($sql);
$stmt->execute($data);
echo 'Added to queue: ' . $stream['vTitle'] . '<br>';
}
}
if (isset($_POST['process'])) {
unset($_POST['process']);
foreach ($_POST as $stream) {
$fkey = hash('crc32', $stream['vFilename'], false);
$enableReplace = '';
if (isset($stream['vReplace'])) {
$enableReplace = ' -y';
}
$data = [
'title' => $stream['vDate'] . " - " . $stream['vTitle'],
'filename' => $stream['vFilename'],
'fkey' => $fkey,
'type' => 'convert',
'params' => '-threads 1 -movflags +faststart -crf 24 -pix_fmt yuv420p -vcodec libx264 -b:v 0k -s 1280x720 -c:a copy -bsf:a aac_adtstoasc -r 30000/1001 -max_muxing_queue_size 4096' . $enableReplace
];
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$status = file_get_contents(POST_URL, true, $context);
if ($status) {
$data = [
'id' => substr($stream['vFilename'], 0, 19),
'title' => $stream['vTitle'],
'game' => $stream['vCategory'],
'status' => 'Converting',
'fkey' => $fkey,
'date' => $stream['vDate'],
];
$sql = "INSERT IGNORE INTO streams (id, title, game, status, fkey, date) VALUES (:id, :title, :game, :status, :fkey, :date)";
$stmt = $pdo->prepare($sql);
$stmt->execute($data);
echo 'Started converting: ' . $stream['vTitle'] . '<br>';
}
}
}
echo '<br><a href="videoProcessor.php">Click here</a>';