-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_getCodec.php
More file actions
60 lines (45 loc) · 1.75 KB
/
fix_getCodec.php
File metadata and controls
60 lines (45 loc) · 1.75 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
<?php
/**
* Created by PhpStorm.
* User: user
* Date: 18.06.2025
* Time: 3:05
*/
include_once(__DIR__.'/config.php');
include_once(__DIR__.'/functions.php');
ob_start();
header('Content-type: text/plain; charset=utf-8');
//header('Content-type: application/json; charset=utf-8');
//header('Content-type: text/html; charset=utf-8');
echo 'START: '.print_r(date('d/m/Y, H:i:s'),1)."<BR>\r\n";
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->query("SELECT * FROM videos WHERE codec_video IS NULL LIMIT 100");
$count = $stmt->rowCount();
echo '$count: '.print_r($count,1)."<BR>\r\n";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$path = $row['path'];
// echo '$path: '.print_r($path,1)."<BR>\r\n";
$result = getCodecInfo($path);
$videoCodec = $result['video'];
$audioCodec = $result['audio'];
// echo '$videoCodec: '.print_r($videoCodec,1)."<BR>\r\n";
// echo '$audioCodec: '.print_r($audioCodec,1)."<BR>\r\n";
if(empty($videoCodec)) $videoCodec = 'NONE';
if(empty($audioCodec)) $audioCodec = 'NONE';
if(empty($videoCodec) || empty($audioCodec)){
echo '$path: '.print_r($path,1)."<BR>\r\n";
echo '$result: '.print_r($result,1)."<BR>\r\n";
exit();
}
$upd = $pdo->prepare("UPDATE videos SET codec_video = ?, codec_audio = ? WHERE id = ?");
$upd->execute([$videoCodec, $audioCodec, $row['id']]);
// exit();
}
echo 'END: '.print_r(date('d/m/Y, H:i:s'),1)."<BR>\r\n";
if(!empty($count)){
// header("Refresh: 2"); // only for HTML
echo 'REFRESH: '.print_r($_SERVER['PHP_SELF'],1)."<BR>\r\n";
sleep(2); // подождать 2 секунды
header("Location: ".$_SERVER['PHP_SELF'].'?time='.time()); // reload текущей страницы
exit;
}