forked from mediasoftpro/PhpMediaHandler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplates.php
251 lines (246 loc) · 7.58 KB
/
templates.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
// video and audio publishing templates
class MediaTemplates {
// FLV Video Encoding
// 0: FLV 240p
// 1: FLV 360p
// 2: FLV 480p
// 3: FLV 720p
// MP4 Video Encoding
// 4: MP4 240p
// 5: MP4 360p
// 6: MP4 480p
// 7: MP4 720p
// 8: MP4 1080p
// WebM Video Encoding
// 9: WebM 240p
// 10: WebM 360p
// 11: WebM 480P
// 12: WebM 720p
// 13: WebM 1080p
// MP3 Encoding
// 14: mp3 audio
public function returnSettings($id)
{
$params = array();
// optional commands
//$params[] = "-fs 10000000"; // limit filesize => 10MB
//$params[] = "-t 10"; // create 10 second clip
//$params[] = "-ss 10"; // start encoding after 10nth seconds
//$params[] = "-metadata title='my title' // key=value pair
$rootPath = $_SERVER['DOCUMENT_ROOT'] . "vsk/";
$presetsFolder = "ffmpeg_aug_2013/presets/";
switch($id)
{
case 0:
// 240p flv encoding
$params[] = "-s 400x240"; // video size
$params[] = "-b:v 256k"; // video bitrate
$params[] = "-bufsize 256k";
$params[] = "-b:a 64k"; // audio bitrate
$params[] = "-ar 22050"; // audio sampling rate
$params[] = "-f flv"; // force
break;
case 1:
// 360p flv encoding
$params[] = "-s 640x360";
$params[] = "-b:v 500k";
$params[] = "-bufsize 500k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod320.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 2:
// 480p flv encoding
$params[] = "-s 854x480";
$params[] = "-b:v 1000k";
$params[] = "-bufsize 1000k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod640.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 3:
// 720p flv encoding
$params[] = "-s 1280x720";
$params[] = "-b:v 2000k";
$params[] = "-bufsize 2000k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod640.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 4:
// 240p mp4 encoding
$params[] = "-s 400x240";
$params[] = "-b:v 256k";
$params[] = "-bufsize 256k";
$params[] = "-b:a 64k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod320.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 5:
// 360p mp4 encoding
$params[] = "-s 640x380";
$params[] = "-b:v 500k";
$params[] = "-bufsize 500k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod320.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 6:
// 480p mp4 encoding
$params[] = "-s 854x480";
$params[] = "-b:v 1000k";
$params[] = "-bufsize 1000k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod640.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 7:
// 720p mp4 encoding
$params[] = "-s 1280x720";
$params[] = "-b:v 2200k";
$params[] = "-bufsize 2200k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod640.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 8:
// 1080p mp4 encoding
$params[] = "-s 1920x1080";
$params[] = "-b:v 2900k";
$params[] = "-bufsize 2900k";
$params[] = "-b:a 152k";
$params[] = "-ar 44100";
$params[] = "-c:v libx264";
$presetpath = $rootPath . "" . $presetsFolder . "/libx264-ipod640.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 9:
// 240p webm encoding
$params[] = "-s 400x240";
$params[] = "-b:v 256k";
$params[] = "-bufsize 256k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libvpx";
$params[] = "-c:a vorbis";
$params[] = "-strict -2"; //for vorbis codec (as its experimental) use libvorbis if your ffmpeg build support it
$params[] = "-f webm";
$params[] = "-aspect 4:3";
$presetpath = $rootPath . "" . $presetsFolder . "/libvpx-360p.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 10:
// 360p webm encoding
$params[] = "-s 640x380";
$params[] = "-b:v 500k";
$params[] = "-bufsize 500k";
$params[] = "-b:a 128k";
$params[] = "-ar 44100";
$params[] = "-c:v libvpx";
$params[] = "-c:a vorbis";
$params[] = "-strict -2"; //for vorbis codec (as its experimental) use libvorbis if your ffmpeg build support it
$params[] = "-f webm";
$params[] = "-aspect 4:3";
$presetpath = $rootPath . "" . $presetsFolder . "/libvpx-360p.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 11:
// 480p webm encoding
$params[] = "-s 854x480";
$params[] = "-b:v 1000k";
$params[] = "-bufsize 1000k";
$params[] = "-b:a 192k";
$params[] = "-ar 44100";
$params[] = "-c:v libvpx";
$params[] = "-c:a vorbis";
$params[] = "-strict -2"; //for vorbis codec (as its experimental) use libvorbis if your ffmpeg build support it
$params[] = "-f webm";
$params[] = "-aspect 4:3";
$presetpath = $rootPath . "" . $presetsFolder . "/libvpx-360p.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 12:
// 720p webm encoding
$params[] = "-s 1280x720";
$params[] = "-b:v 2200k";
$params[] = "-bufsize 2200k";
$params[] = "-b:a 192k";
$params[] = "-ar 44100";
$params[] = "-c:v libvpx";
$params[] = "-c:a vorbis";
$params[] = "-strict -2"; //for vorbis codec (as its experimental) use libvorbis if your ffmpeg build support it
$params[] = "-f webm";
$params[] = "-aspect 4:3";
$presetpath = $rootPath . "" . $presetsFolder . "/libvpx-720p.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 13:
// 1080p webm encoding
$params[] = "-s 1920x1080";
$params[] = "-b:v 2900k";
$params[] = "-bufsize 2900k";
$params[] = "-b:a 192k";
$params[] = "-ar 44100";
$params[] = "-c:v libvpx";
$params[] = "-c:a vorbis";
$params[] = "-strict -2"; //for vorbis codec (as its experimental) use libvorbis if your ffmpeg build support it
$params[] = "-f webm";
$params[] = "-aspect 4:3";
$presetpath = $rootPath . "" . $presetsFolder . "/libvpx-1080p.ffpreset";
$params[] = "-fpre " . escapeshellarg($presetpath);
break;
case 14:
// mp3 audio encoding
$params[] = "-vn";
break;
}
return $params;
}
public function returnExtension($id)
{
$extension = "";
switch($id)
{
case 0:
case 1:
case 2:
case 3:
$extension = ".flv";
break;
case 4:
case 5:
case 6:
case 7:
case 8:
$extension = ".mp4";
break;
case 9:
case 10:
case 11:
case 12:
case 13:
$extension = ".webm";
break;
case 14:
$extension = ".mp3";
break;
}
return $extension;
}
}
?>