-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-summary.php
More file actions
66 lines (51 loc) · 1.67 KB
/
Copy pathcreate-summary.php
File metadata and controls
66 lines (51 loc) · 1.67 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
<?php
include "conn.php";
$rate = 2;
$supported_ext = array('flv', 'mp4');
//$ffmpeg_path = "/opt/local/bin/ffmpeg";
$path = './video/';
$ffpath = "ff/";
$scpath = "sc/";
$temp_dir = "ffmpeg_temp";
if ($handle = opendir($path)) {
echo "Entries:<br>";
while (false !== ($file = readdir($handle))) {
if (!is_dir($path.$file)){
$splitted = explode('.', $file);
$ext = strtolower($splitted[count($splitted)-1]);
if (in_array($ext, $supported_ext)) {
//$files[] = $file;
echo "$file: ";
ob_start();
passthru("mkdir ffmpeg_temp");
$command = FFMPEG_PATH . " -i " . $path.$file . " -r " . $rate . " -f image2 " . $temp_dir . "/%05d.png";
passthru($command);
$command2 = FFMPEG_PATH . " -i " . $path.$temp_dir . "/%05d.png -sameq " . $path.$ffpath.$file;
passthru($command2);
passthru("rm -rf " . $path . $temp_dir);
ob_end_clean();
//echo $command2;
echo "done<br>";
/*
passthru("/opt/local/bin/ffmpeg -i \"". $path.$file . "\" 2>&1");
$duration = ob_get_contents();
ob_end_clean();
preg_match('/Duration: (.*?),/', $duration, $matches);
$duration = $matches[1];
echo "$duration ";
$duration_array = split(':', $duration);
$duration = $duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2];
$duration = floor($duration);
echo "$duration<br>";
if (!$mysqli->query("UPDATE videos SET duration='$duration' WHERE filename='$file'"))
echo "query error";
//if ($mysqli->affected_rows != 1)
// echo "query error";
*/
}
}
}
closedir($handle);
}
$mysqli->close();
?>