Repository navigation
Expand file tree
/
Copy pathffmpeg-filter-complex.php
More file actions
99 lines (68 loc) · 2.1 KB
/
Copy pathffmpeg-filter-complex.php
File metadata and controls
99 lines (68 loc) · 2.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
91
92
93
94
95
96
97
98
99
<?php
require_once("ffmpeg-filter.php");
class ffmpeg_video_filter_complex {
public $ffmpeg_wrapper;
public $filters;
public $string;
public $input_files;
public $last_stream;
private $concat_flag;
public function __construct($wrapper) {
$this->ffmpeg_wrapper = $wrapper;
$this->filters = array();
$this->input_files = array();
}
public function get_string() {
return $this->build();
}
private function stream_prefix() {
return "";
}
private function stream_str($s_id) {
return "[" . $this->stream_prefix() . $s_id . "]";
}
private function new_id() {
$stream_id = "_cat_" . substr(str_shuffle("abcdefghijklmnopqrstuvwxyz"),0,5);
return $stream_id;
}
private function build() {
$this->string = "-filter_complex" . " " . "'";
// add the filters
foreach ($this->filters as $filter) {
foreach ($filter->input_streams as $in_stream) {
$this->string .= $this->stream_str($in_stream);
}
$this->string .= $filter->get_string();
foreach ($filter->output_streams as $out_stream) {
$this->string .= $this->stream_str($out_stream);
}
}
$this->string .= "'" . " ";
if ($this->concat_flag) {
$this->string .= "-map '[v]'" . " ";
}
return $this->string;
}
// *************************************************************************************************** //
// ** ffmpeg_video_filter_complex :: public functions ** //
// *************************************************************************************************** //
public function concat_update_filter() {
$concat = new ffmpeg_filter();
$concat->id = $this->new_id();
$concat->name = "concat";
$concat->values = array( "n=" . count($this->input_files) , "v=1" , "a=0");
$concat->input_streams = array();
for ($i=0; $i < count($this->input_files) ; $i++) {
array_push($concat->input_streams, $i . ":0");
}
$concat->output_streams = array("v");
// reset the filters array
$this->filters = array($concat);
}
public function concat_add($file) {
$this->concat_flag = true;
array_push($this->input_files, $file);
$this->concat_update_filter();
}
}
?>