1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include <QDir>
|
---|
20 | #include <QDebug>
|
---|
21 | #include "inforeader.h"
|
---|
22 |
|
---|
23 | void MPVProcess::addArgument(const QString & /*a*/) {
|
---|
24 | }
|
---|
25 |
|
---|
26 | void MPVProcess::setMedia(const QString & media, bool is_playlist) {
|
---|
27 | arg << "--term-playing-msg="
|
---|
28 | "MPV_VERSION=${=mpv-version:}\n"
|
---|
29 | "INFO_VIDEO_WIDTH=${=width}\nINFO_VIDEO_HEIGHT=${=height}\n"
|
---|
30 | "INFO_VIDEO_ASPECT=${=video-aspect}\n"
|
---|
31 | // "INFO_VIDEO_DSIZE=${=dwidth}x${=dheight}\n"
|
---|
32 | "INFO_VIDEO_FPS=${=fps}\n"
|
---|
33 | // "INFO_VIDEO_BITRATE=${=video-bitrate}\n"
|
---|
34 | "INFO_VIDEO_FORMAT=${=video-format}\n"
|
---|
35 | "INFO_VIDEO_CODEC=${=video-codec}\n"
|
---|
36 |
|
---|
37 | // "INFO_AUDIO_BITRATE=${=audio-bitrate}\n"
|
---|
38 | // "INFO_AUDIO_FORMAT=${=audio-format}\n" // old
|
---|
39 | "INFO_AUDIO_FORMAT=${=audio-codec-name}\n"
|
---|
40 | "INFO_AUDIO_CODEC=${=audio-codec}\n"
|
---|
41 | // "INFO_AUDIO_RATE=${=audio-samplerate}\n" // old
|
---|
42 | "INFO_AUDIO_RATE=${=audio-params/samplerate}\n"
|
---|
43 | // "INFO_AUDIO_NCH=${=audio-channels}\n" // old
|
---|
44 | "INFO_AUDIO_NCH=${=audio-params/channel-count}\n"
|
---|
45 |
|
---|
46 | // "INFO_LENGTH=${=length}\n"
|
---|
47 | "INFO_LENGTH=${=duration:${=length}}\n"
|
---|
48 |
|
---|
49 | "INFO_DEMUXER=${=demuxer}\n"
|
---|
50 | "INFO_SEEKABLE=${=seekable}\n"
|
---|
51 | "INFO_TITLES=${=disc-titles}\n"
|
---|
52 | "INFO_CHAPTERS=${=chapters}\n"
|
---|
53 | "INFO_TRACKS_COUNT=${=track-list/count}\n"
|
---|
54 |
|
---|
55 | "METADATA_TITLE=${metadata/by-key/title:}\n"
|
---|
56 | "METADATA_ARTIST=${metadata/by-key/artist:}\n"
|
---|
57 | "METADATA_ALBUM=${metadata/by-key/album:}\n"
|
---|
58 | "METADATA_GENRE=${metadata/by-key/genre:}\n"
|
---|
59 | "METADATA_DATE=${metadata/by-key/date:}\n"
|
---|
60 | "METADATA_TRACK=${metadata/by-key/track:}\n"
|
---|
61 | "METADATA_COPYRIGHT=${metadata/by-key/copyright:}\n"
|
---|
62 |
|
---|
63 | "INFO_MEDIA_TITLE=${=media-title:}\n";
|
---|
64 |
|
---|
65 | #ifdef CUSTOM_STATUS
|
---|
66 | arg << "--term-status-msg=STATUS: ${=time-pos} / ${=duration:${=length:0}} P: ${=pause} B: ${=paused-for-cache} I: ${=core-idle}";
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | if (is_playlist) {
|
---|
70 | arg << "--playlist=" + media;
|
---|
71 | } else {
|
---|
72 | arg << media;
|
---|
73 | }
|
---|
74 |
|
---|
75 | #ifdef CAPTURE_STREAM
|
---|
76 | capturing = false;
|
---|
77 | #endif
|
---|
78 | }
|
---|
79 |
|
---|
80 | void MPVProcess::setFixedOptions() {
|
---|
81 | arg << "--no-config";
|
---|
82 | arg << "--no-quiet";
|
---|
83 | arg << "--terminal";
|
---|
84 | arg << "--no-msg-color";
|
---|
85 | arg << "--input-file=/dev/stdin";
|
---|
86 | //arg << "--no-osc";
|
---|
87 | //arg << "--msg-level=vd=v";
|
---|
88 | }
|
---|
89 |
|
---|
90 | void MPVProcess::disableInput() {
|
---|
91 | arg << "--no-input-default-bindings";
|
---|
92 | arg << "--input-x11-keyboard=no";
|
---|
93 | arg << "--no-input-cursor";
|
---|
94 | arg << "--cursor-autohide=no";
|
---|
95 | }
|
---|
96 |
|
---|
97 | bool MPVProcess::isOptionAvailable(const QString & option) {
|
---|
98 | InfoReader * ir = InfoReader::obj(executable());
|
---|
99 | ir->getInfo();
|
---|
100 | //qDebug() << "MPVProcess::isOptionAvailable: option_list:" << ir->optionList();
|
---|
101 | return ir->optionList().contains(option);
|
---|
102 | }
|
---|
103 |
|
---|
104 | void MPVProcess::addVFIfAvailable(const QString & vf, const QString & value) {
|
---|
105 | InfoReader * ir = InfoReader::obj(executable());
|
---|
106 | ir->getInfo();
|
---|
107 | if (ir->vfList().contains(vf)) {
|
---|
108 | QString s = "--vf-add=" + vf;
|
---|
109 | if (!value.isEmpty()) s += "=" + value;
|
---|
110 | arg << s;
|
---|
111 | } else {
|
---|
112 | QString f = vf +"="+ value;
|
---|
113 | qDebug("MPVProcess::addVFIfAvailable: filter %s is not used because it's not available", f.toLatin1().constData());
|
---|
114 | }
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MPVProcess::messageFilterNotSupported(const QString & filter_name) {
|
---|
118 | QString text = tr("the '%1' filter is not supported by mpv").arg(filter_name);
|
---|
119 | writeToStdin(QString("show_text \"%1\" 3000").arg(text));
|
---|
120 | }
|
---|
121 |
|
---|
122 | void MPVProcess::enableScreenshots(const QString & dir, const QString & templ, const QString & format) {
|
---|
123 | if (!templ.isEmpty()) {
|
---|
124 | arg << "--screenshot-template=" + templ;
|
---|
125 | }
|
---|
126 |
|
---|
127 | if (!format.isEmpty()) {
|
---|
128 | arg << "--screenshot-format=" + format;
|
---|
129 | }
|
---|
130 |
|
---|
131 | if (!dir.isEmpty()) {
|
---|
132 | QString d = QDir::toNativeSeparators(dir);
|
---|
133 | if (!isOptionAvailable("--screenshot-directory")) {
|
---|
134 | qDebug() << "MPVProcess::enableScreenshots: the option --screenshot-directory is not available in this version of mpv";
|
---|
135 | qDebug() << "MPVProcess::enableScreenshots: changing working directory to" << d;
|
---|
136 | setWorkingDirectory(d);
|
---|
137 | } else {
|
---|
138 | arg << "--screenshot-directory=" + d;
|
---|
139 | }
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | void MPVProcess::setOption(const QString & option_name, const QVariant & value) {
|
---|
144 | if (option_name == "cache") {
|
---|
145 | int cache = value.toInt();
|
---|
146 | if (cache > 31) {
|
---|
147 | arg << "--cache=" + value.toString();
|
---|
148 | } else {
|
---|
149 | arg << "--cache=no";
|
---|
150 | }
|
---|
151 | }
|
---|
152 | else
|
---|
153 | if (option_name == "cache_auto") {
|
---|
154 | arg << "--cache=auto";
|
---|
155 | }
|
---|
156 | else
|
---|
157 | if (option_name == "ss") {
|
---|
158 | arg << "--start=" + value.toString();
|
---|
159 | }
|
---|
160 | else
|
---|
161 | if (option_name == "endpos") {
|
---|
162 | arg << "--length=" + value.toString();
|
---|
163 | }
|
---|
164 | else
|
---|
165 | if (option_name == "loop") {
|
---|
166 | QString o = value.toString();
|
---|
167 | if (o == "0") o = "inf";
|
---|
168 | arg << "--loop=" + o;
|
---|
169 | }
|
---|
170 | else
|
---|
171 | if (option_name == "ass") {
|
---|
172 | arg << "--sub-ass";
|
---|
173 | }
|
---|
174 | else
|
---|
175 | if (option_name == "noass") {
|
---|
176 | arg << "--no-sub-ass";
|
---|
177 | }
|
---|
178 | else
|
---|
179 | if (option_name == "sub-fuzziness") {
|
---|
180 | QString v;
|
---|
181 | switch (value.toInt()) {
|
---|
182 | case 1: v = "fuzzy"; break;
|
---|
183 | case 2: v = "all"; break;
|
---|
184 | default: v = "exact";
|
---|
185 | }
|
---|
186 | arg << "--sub-auto=" + v;
|
---|
187 | }
|
---|
188 | else
|
---|
189 | if (option_name == "audiofile") {
|
---|
190 | arg << "--audio-file=" + value.toString();
|
---|
191 | }
|
---|
192 | else
|
---|
193 | if (option_name == "delay") {
|
---|
194 | arg << "--audio-delay=" + value.toString();
|
---|
195 | }
|
---|
196 | else
|
---|
197 | if (option_name == "subdelay") {
|
---|
198 | arg << "--sub-delay=" + value.toString();
|
---|
199 | }
|
---|
200 | else
|
---|
201 | if (option_name == "sub") {
|
---|
202 | arg << "--sub-file=" + value.toString();
|
---|
203 | }
|
---|
204 | else
|
---|
205 | if (option_name == "subpos") {
|
---|
206 | arg << "--sub-pos=" + value.toString();
|
---|
207 | }
|
---|
208 | else
|
---|
209 | if (option_name == "font") {
|
---|
210 | arg << "--osd-font=" + value.toString();
|
---|
211 | }
|
---|
212 | else
|
---|
213 | if (option_name == "subcp") {
|
---|
214 | QString cp = value.toString();
|
---|
215 | if (!cp.startsWith("enca")) cp = "utf8:" + cp;
|
---|
216 | arg << "--sub-codepage=" + cp;
|
---|
217 | }
|
---|
218 | else
|
---|
219 | if (option_name == "osdlevel") {
|
---|
220 | arg << "--osd-level=" + value.toString();
|
---|
221 | }
|
---|
222 | else
|
---|
223 | if (option_name == "sws") {
|
---|
224 | arg << "--sws-scaler=lanczos";
|
---|
225 | }
|
---|
226 | else
|
---|
227 | if (option_name == "channels") {
|
---|
228 | arg << "--audio-channels=" + value.toString();
|
---|
229 | }
|
---|
230 | else
|
---|
231 | if (option_name == "subfont-text-scale" || option_name == "ass-font-scale") {
|
---|
232 | arg << "--sub-scale=" + value.toString();
|
---|
233 | }
|
---|
234 | else
|
---|
235 | if (option_name == "stop-xscreensaver") {
|
---|
236 | bool stop_ss = value.toBool();
|
---|
237 | if (stop_ss) arg << "--stop-screensaver"; else arg << "--no-stop-screensaver";
|
---|
238 | }
|
---|
239 | else
|
---|
240 | if (option_name == "correct-pts") {
|
---|
241 | bool b = value.toBool();
|
---|
242 | if (b) arg << "--correct-pts"; else arg << "--no-correct-pts";
|
---|
243 | }
|
---|
244 | else
|
---|
245 | if (option_name == "idx") {
|
---|
246 | arg << "--index=default";
|
---|
247 | }
|
---|
248 | else
|
---|
249 | if (option_name == "softvol") {
|
---|
250 | if (value.toString() == "off") {
|
---|
251 | if (isOptionAvailable("--volume-max")) {
|
---|
252 | arg << "--volume-max=100";
|
---|
253 | }
|
---|
254 | } else {
|
---|
255 | int v = value.toInt();
|
---|
256 | if (v < 100) v = 100;
|
---|
257 | if (isOptionAvailable("--volume-max")) {
|
---|
258 | arg << "--volume-max=" + QString::number(v);
|
---|
259 | } else {
|
---|
260 | arg << "--softvol=yes";
|
---|
261 | arg << "--softvol-max=" + QString::number(v);
|
---|
262 | }
|
---|
263 | }
|
---|
264 | }
|
---|
265 | else
|
---|
266 | if (option_name == "subfps") {
|
---|
267 | arg << "--sub-fps=" + value.toString();
|
---|
268 | }
|
---|
269 | else
|
---|
270 | if (option_name == "forcedsubsonly") {
|
---|
271 | arg << "--sub-forced-only";
|
---|
272 | }
|
---|
273 | else
|
---|
274 | if (option_name == "prefer-ipv4" || option_name == "prefer-ipv6" ||
|
---|
275 | option_name == "dr" || option_name == "double" ||
|
---|
276 | option_name == "adapter" || option_name == "edl" ||
|
---|
277 | option_name == "slices" || option_name == "colorkey" ||
|
---|
278 | option_name == "subcc" || option_name == "vobsub" ||
|
---|
279 | option_name == "zoom" || option_name == "flip-hebrew" ||
|
---|
280 | option_name == "autoq")
|
---|
281 | {
|
---|
282 | // Ignore
|
---|
283 | }
|
---|
284 | else
|
---|
285 | if (option_name == "tsprog") {
|
---|
286 | // Unsupported
|
---|
287 | }
|
---|
288 | else
|
---|
289 | if (option_name == "dvdangle") {
|
---|
290 | /*
|
---|
291 | arg << "--dvd-angle=" + value.toString();
|
---|
292 | */
|
---|
293 | }
|
---|
294 | else
|
---|
295 | if (option_name == "threads") {
|
---|
296 | arg << "--vd-lavc-threads=" + value.toString();
|
---|
297 | }
|
---|
298 | else
|
---|
299 | if (option_name == "skiploopfilter") {
|
---|
300 | arg << "--vd-lavc-skiploopfilter=all";
|
---|
301 | }
|
---|
302 | else
|
---|
303 | if (option_name == "keepaspect" || option_name == "fs") {
|
---|
304 | bool b = value.toBool();
|
---|
305 | if (b) arg << "--" + option_name; else arg << "--no-" + option_name;
|
---|
306 | }
|
---|
307 | else
|
---|
308 | if (option_name == "ao") {
|
---|
309 | QString o = value.toString();
|
---|
310 | if (o.startsWith("alsa:device=")) {
|
---|
311 | QString device = o.mid(12);
|
---|
312 | //qDebug() << "MPVProcess::setOption: alsa device:" << device;
|
---|
313 | device = device.replace("=", ":").replace(".", ",");
|
---|
314 | o = "alsa:device=[" + device + "]";
|
---|
315 | }
|
---|
316 | arg << "--ao=" + o;
|
---|
317 | }
|
---|
318 | else
|
---|
319 | if (option_name == "vc") {
|
---|
320 | qDebug() << "MPVProcess::setOption: video codec ignored";
|
---|
321 | }
|
---|
322 | else
|
---|
323 | if (option_name == "ac") {
|
---|
324 | qDebug() << "MPVProcess::setOption: audio codec ignored";
|
---|
325 | }
|
---|
326 | else
|
---|
327 | if (option_name == "afm") {
|
---|
328 | QString s = value.toString();
|
---|
329 | if (s == "hwac3") arg << "--ad=spdif:ac3,spdif:dts";
|
---|
330 | }
|
---|
331 | else
|
---|
332 | if (option_name == "enable_streaming_sites_support") {
|
---|
333 | if (isOptionAvailable("--ytdl")) {
|
---|
334 | if (value.toBool()) arg << "--ytdl"; else arg << "--ytdl=no";
|
---|
335 | }
|
---|
336 | }
|
---|
337 | else
|
---|
338 | if (option_name == "fontconfig") {
|
---|
339 | if (isOptionAvailable("--use-text-osd")) {
|
---|
340 | bool b = value.toBool();
|
---|
341 | if (b) arg << "--use-text-osd=yes"; else arg << "--use-text-osd=no";
|
---|
342 | }
|
---|
343 | }
|
---|
344 | else
|
---|
345 | if (option_name == "verbose") {
|
---|
346 | arg << "-v";
|
---|
347 | verbose = true;
|
---|
348 | }
|
---|
349 | else
|
---|
350 | if (option_name == "mute") {
|
---|
351 | arg << "--mute=yes";
|
---|
352 | }
|
---|
353 | else
|
---|
354 | if (option_name == "scaletempo") {
|
---|
355 | if (isOptionAvailable("--audio-pitch-correction")) {
|
---|
356 | bool enabled = value.toBool();
|
---|
357 | if (enabled) arg << "--audio-pitch-correction=yes"; else arg << "--audio-pitch-correction=no";
|
---|
358 | }
|
---|
359 | }
|
---|
360 | else
|
---|
361 | if (option_name == "vf-add") {
|
---|
362 | if (!value.isNull()) arg << "--vf-add=" + value.toString();
|
---|
363 | }
|
---|
364 | else
|
---|
365 | if (option_name == "af-add") {
|
---|
366 | if (!value.isNull()) arg << "--af-add=" + value.toString();
|
---|
367 | }
|
---|
368 | else
|
---|
369 | if (option_name == "wid" ||
|
---|
370 | option_name == "vo" ||
|
---|
371 | option_name == "aid" || option_name == "vid" ||
|
---|
372 | option_name == "volume" ||
|
---|
373 | option_name == "ass-styles" || option_name == "ass-force-style" ||
|
---|
374 | option_name == "ass-line-spacing" ||
|
---|
375 | option_name == "embeddedfonts" ||
|
---|
376 | option_name == "osd-scale" ||
|
---|
377 | option_name == "speed" ||
|
---|
378 | option_name == "contrast" || option_name == "brightness" ||
|
---|
379 | option_name == "hue" || option_name == "saturation" || option_name == "gamma" ||
|
---|
380 | option_name == "monitorpixelaspect" || option_name == "monitoraspect" ||
|
---|
381 | option_name == "mc" ||
|
---|
382 | option_name == "framedrop" ||
|
---|
383 | option_name == "priority" ||
|
---|
384 | option_name == "hwdec" ||
|
---|
385 | option_name == "autosync" ||
|
---|
386 | option_name == "dvd-device" || option_name == "cdrom-device" ||
|
---|
387 | option_name == "demuxer" ||
|
---|
388 | option_name == "frames" ||
|
---|
389 | option_name == "ab-loop-a" || option_name == "ab-loop-b")
|
---|
390 | {
|
---|
391 | QString s = "--" + option_name;
|
---|
392 | if (!value.isNull()) s += "=" + value.toString();
|
---|
393 | arg << s;
|
---|
394 | }
|
---|
395 | else
|
---|
396 | {
|
---|
397 | qDebug() << "MPVProcess::setOption: unknown option:" << option_name;
|
---|
398 | }
|
---|
399 | }
|
---|
400 |
|
---|
401 | void MPVProcess::addUserOption(const QString & option) {
|
---|
402 | arg << option;
|
---|
403 | if (option == "-v") {
|
---|
404 | verbose = true;
|
---|
405 | }
|
---|
406 | }
|
---|
407 |
|
---|
408 | void MPVProcess::addVF(const QString & filter_name, const QVariant & value) {
|
---|
409 | QString option = value.toString();
|
---|
410 |
|
---|
411 | if ((filter_name == "harddup") || (filter_name == "hue")) {
|
---|
412 | // ignore
|
---|
413 | }
|
---|
414 | else
|
---|
415 | if (filter_name == "eq2") {
|
---|
416 | arg << "--vf-add=eq";
|
---|
417 | }
|
---|
418 | else
|
---|
419 | if (filter_name == "blur") {
|
---|
420 | addVFIfAvailable("lavfi", "[unsharp=la=-1.5:ca=-1.5]");
|
---|
421 | }
|
---|
422 | else
|
---|
423 | if (filter_name == "sharpen") {
|
---|
424 | addVFIfAvailable("lavfi", "[unsharp=la=1.5:ca=1.5]");
|
---|
425 | }
|
---|
426 | else
|
---|
427 | if (filter_name == "noise") {
|
---|
428 | addVFIfAvailable("lavfi", "[noise=alls=9:allf=t]");
|
---|
429 | }
|
---|
430 | else
|
---|
431 | if (filter_name == "deblock") {
|
---|
432 | addVFIfAvailable("lavfi", "[pp=" + option +"]");
|
---|
433 | }
|
---|
434 | else
|
---|
435 | if (filter_name == "dering") {
|
---|
436 | addVFIfAvailable("lavfi", "[pp=dr]");
|
---|
437 | }
|
---|
438 | else
|
---|
439 | if (filter_name == "phase") {
|
---|
440 | addVFIfAvailable("lavfi", "[phase=" + option +"]");
|
---|
441 | }
|
---|
442 | else
|
---|
443 | if (filter_name == "postprocessing") {
|
---|
444 | addVFIfAvailable("lavfi", "[pp]");
|
---|
445 | }
|
---|
446 | else
|
---|
447 | if (filter_name == "hqdn3d") {
|
---|
448 | QString o;
|
---|
449 | if (!option.isEmpty()) o = "=" + option;
|
---|
450 | addVFIfAvailable("lavfi", "[hqdn3d" + o +"]");
|
---|
451 | }
|
---|
452 | else
|
---|
453 | if (filter_name == "yadif") {
|
---|
454 | if (option == "1") {
|
---|
455 | arg << "--vf-add=yadif=field";
|
---|
456 | } else {
|
---|
457 | arg << "--vf-add=yadif";
|
---|
458 | }
|
---|
459 | }
|
---|
460 | else
|
---|
461 | if (filter_name == "kerndeint") {
|
---|
462 | addVFIfAvailable("lavfi", "[kerndeint=" + option +"]");
|
---|
463 | }
|
---|
464 | else
|
---|
465 | if (filter_name == "lb" || filter_name == "l5") {
|
---|
466 | addVFIfAvailable("lavfi", "[pp=" + filter_name +"]");
|
---|
467 | }
|
---|
468 | else
|
---|
469 | if (filter_name == "subs_on_screenshots") {
|
---|
470 | // Ignore
|
---|
471 | }
|
---|
472 | else
|
---|
473 | if (filter_name == "rotate") {
|
---|
474 | if (option == "0") {
|
---|
475 | arg << "--vf-add=rotate=270,flip";
|
---|
476 | }
|
---|
477 | else
|
---|
478 | if (option == "1") {
|
---|
479 | arg << "--vf-add=rotate=90";
|
---|
480 | }
|
---|
481 | else
|
---|
482 | if (option == "2") {
|
---|
483 | arg << "--vf-add=rotate=270";
|
---|
484 | }
|
---|
485 | else
|
---|
486 | if (option == "3") {
|
---|
487 | arg << "--vf-add=rotate=90,flip";
|
---|
488 | }
|
---|
489 | }
|
---|
490 | else {
|
---|
491 | if (filter_name == "pp") {
|
---|
492 | QString s;
|
---|
493 | if (option.isEmpty()) s = "[pp]"; else s = "[pp=" + option + "]";
|
---|
494 | addVFIfAvailable("lavfi", s);
|
---|
495 | } else {
|
---|
496 | QString s = filter_name;
|
---|
497 | if (!option.isEmpty()) s += "=" + option;
|
---|
498 | arg << "--vf-add=" + s;
|
---|
499 | }
|
---|
500 | }
|
---|
501 | }
|
---|
502 |
|
---|
503 | void MPVProcess::addStereo3DFilter(const QString & in, const QString & out) {
|
---|
504 | arg << "--vf-add=stereo3d=" + in + ":" + out;
|
---|
505 | }
|
---|
506 |
|
---|
507 | void MPVProcess::addAF(const QString & filter_name, const QVariant & value) {
|
---|
508 | QString option = value.toString();
|
---|
509 |
|
---|
510 | if (filter_name == "volnorm") {
|
---|
511 | QString s = "drc";
|
---|
512 | if (!option.isEmpty()) s += "=" + option;
|
---|
513 | arg << "--af-add=" + s;
|
---|
514 | }
|
---|
515 | else
|
---|
516 | if (filter_name == "channels") {
|
---|
517 | if (option == "2:2:0:1:0:0") arg << "--af-add=channels=2:[0-1,0-0]";
|
---|
518 | else
|
---|
519 | if (option == "2:2:1:0:1:1") arg << "--af-add=channels=2:[1-0,1-1]";
|
---|
520 | else
|
---|
521 | if (option == "2:2:0:1:1:0") arg << "--af-add=channels=2:[0-1,1-0]";
|
---|
522 | }
|
---|
523 | else
|
---|
524 | if (filter_name == "pan") {
|
---|
525 | if (option == "1:0.5:0.5") {
|
---|
526 | arg << "--af-add=pan=1:[0.5,0.5]";
|
---|
527 | }
|
---|
528 | }
|
---|
529 | else
|
---|
530 | if (filter_name == "equalizer") {
|
---|
531 | previous_eq = option;
|
---|
532 | arg << "--af-add=equalizer=" + option;
|
---|
533 | }
|
---|
534 | else
|
---|
535 | if (filter_name == "extrastereo") {
|
---|
536 | arg << "--af-add=lavfi=[extrastereo]";
|
---|
537 | }
|
---|
538 | else
|
---|
539 | if (filter_name == "karaoke") {
|
---|
540 | /* Not supported anymore */
|
---|
541 | /* Ignore */
|
---|
542 | }
|
---|
543 | else {
|
---|
544 | QString s = filter_name;
|
---|
545 | if (!option.isEmpty()) s += "=" + option;
|
---|
546 | arg << "--af-add=" + s;
|
---|
547 | }
|
---|
548 | }
|
---|
549 |
|
---|
550 | void MPVProcess::quit() {
|
---|
551 | writeToStdin("quit 0");
|
---|
552 | }
|
---|
553 |
|
---|
554 | void MPVProcess::setVolume(int v) {
|
---|
555 | writeToStdin("set volume " + QString::number(v));
|
---|
556 | }
|
---|
557 |
|
---|
558 | void MPVProcess::setOSD(int o) {
|
---|
559 | writeToStdin("osd " + QString::number(o));
|
---|
560 | }
|
---|
561 |
|
---|
562 | void MPVProcess::setAudio(int ID) {
|
---|
563 | writeToStdin("set aid " + QString::number(ID));
|
---|
564 | }
|
---|
565 |
|
---|
566 | void MPVProcess::setVideo(int ID) {
|
---|
567 | writeToStdin("set vid " + QString::number(ID));
|
---|
568 | }
|
---|
569 |
|
---|
570 | void MPVProcess::setSubtitle(int /*type*/, int ID) {
|
---|
571 | writeToStdin("set sid " + QString::number(ID));
|
---|
572 | }
|
---|
573 |
|
---|
574 | void MPVProcess::disableSubtitles() {
|
---|
575 | writeToStdin("set sid no");
|
---|
576 | }
|
---|
577 |
|
---|
578 | void MPVProcess::setSecondarySubtitle(int ID) {
|
---|
579 | writeToStdin("set secondary-sid " + QString::number(ID));
|
---|
580 | }
|
---|
581 |
|
---|
582 | void MPVProcess::disableSecondarySubtitles() {
|
---|
583 | writeToStdin("set secondary-sid no");
|
---|
584 | }
|
---|
585 |
|
---|
586 | void MPVProcess::setSubtitlesVisibility(bool b) {
|
---|
587 | writeToStdin(QString("set sub-visibility %1").arg(b ? "yes" : "no"));
|
---|
588 | }
|
---|
589 |
|
---|
590 | void MPVProcess::seek(double secs, int mode, bool precise) {
|
---|
591 | QString s = "seek " + QString::number(secs) + " ";
|
---|
592 | switch (mode) {
|
---|
593 | case 0 : s += "relative "; break;
|
---|
594 | case 1 : s += "absolute-percent "; break;
|
---|
595 | case 2 : s += "absolute "; break;
|
---|
596 | }
|
---|
597 | if (precise) s += "exact"; else s += "keyframes";
|
---|
598 | writeToStdin(s);
|
---|
599 | }
|
---|
600 |
|
---|
601 | void MPVProcess::mute(bool b) {
|
---|
602 | writeToStdin(QString("set mute %1").arg(b ? "yes" : "no"));
|
---|
603 | }
|
---|
604 |
|
---|
605 | void MPVProcess::setPause(bool b) {
|
---|
606 | writeToStdin(QString("set pause %1").arg(b ? "yes" : "no"));
|
---|
607 | }
|
---|
608 |
|
---|
609 | void MPVProcess::frameStep() {
|
---|
610 | writeToStdin("frame_step");
|
---|
611 | }
|
---|
612 |
|
---|
613 | void MPVProcess::frameBackStep() {
|
---|
614 | writeToStdin("frame_back_step");
|
---|
615 | }
|
---|
616 |
|
---|
617 | void MPVProcess::showOSDText(const QString & text, int duration, int level) {
|
---|
618 | QString str = QString("show_text \"%1\" %2 %3").arg(text).arg(duration).arg(level);
|
---|
619 | writeToStdin(str);
|
---|
620 | }
|
---|
621 |
|
---|
622 | void MPVProcess::showFilenameOnOSD() {
|
---|
623 | writeToStdin("show_text \"${filename}\" 2000 0");
|
---|
624 | }
|
---|
625 |
|
---|
626 | void MPVProcess::showTimeOnOSD() {
|
---|
627 | writeToStdin("show_text \"${time-pos} / ${length:0} (${percent-pos}%)\" 2000 0");
|
---|
628 | }
|
---|
629 |
|
---|
630 | void MPVProcess::setContrast(int value) {
|
---|
631 | writeToStdin("set contrast " + QString::number(value));
|
---|
632 | }
|
---|
633 |
|
---|
634 | void MPVProcess::setBrightness(int value) {
|
---|
635 | writeToStdin("set brightness " + QString::number(value));
|
---|
636 | }
|
---|
637 |
|
---|
638 | void MPVProcess::setHue(int value) {
|
---|
639 | writeToStdin("set hue " + QString::number(value));
|
---|
640 | }
|
---|
641 |
|
---|
642 | void MPVProcess::setSaturation(int value) {
|
---|
643 | writeToStdin("set saturation " + QString::number(value));
|
---|
644 | }
|
---|
645 |
|
---|
646 | void MPVProcess::setGamma(int value) {
|
---|
647 | writeToStdin("set gamma " + QString::number(value));
|
---|
648 | }
|
---|
649 |
|
---|
650 | void MPVProcess::setChapter(int ID) {
|
---|
651 | writeToStdin("set chapter " + QString::number(ID));
|
---|
652 | }
|
---|
653 |
|
---|
654 | void MPVProcess::nextChapter() {
|
---|
655 | writeToStdin("add chapter 1");
|
---|
656 | }
|
---|
657 |
|
---|
658 | void MPVProcess::previousChapter() {
|
---|
659 | writeToStdin("add chapter -1");
|
---|
660 | }
|
---|
661 |
|
---|
662 | void MPVProcess::setExternalSubtitleFile(const QString & filename) {
|
---|
663 | writeToStdin("sub_add \""+ filename +"\"");
|
---|
664 | //writeToStdin("print_text ${track-list}");
|
---|
665 | writeToStdin("print_text \"INFO_TRACKS_COUNT=${=track-list/count}\"");
|
---|
666 | }
|
---|
667 |
|
---|
668 | void MPVProcess::setSubPos(int pos) {
|
---|
669 | writeToStdin("set sub-pos " + QString::number(pos));
|
---|
670 | }
|
---|
671 |
|
---|
672 | void MPVProcess::setSubScale(double value) {
|
---|
673 | writeToStdin("set sub-scale " + QString::number(value));
|
---|
674 | }
|
---|
675 |
|
---|
676 | void MPVProcess::setSubStep(int value) {
|
---|
677 | writeToStdin("sub_step " + QString::number(value));
|
---|
678 | }
|
---|
679 |
|
---|
680 | void MPVProcess::seekSub(int value) {
|
---|
681 | writeToStdin("sub-seek " + QString::number(value));
|
---|
682 | }
|
---|
683 |
|
---|
684 | void MPVProcess::setSubForcedOnly(bool b) {
|
---|
685 | writeToStdin(QString("set sub-forced-only %1").arg(b ? "yes" : "no"));
|
---|
686 | }
|
---|
687 |
|
---|
688 | void MPVProcess::setSpeed(double value) {
|
---|
689 | writeToStdin("set speed " + QString::number(value));
|
---|
690 | }
|
---|
691 |
|
---|
692 | #ifdef MPLAYER_SUPPORT
|
---|
693 | void MPVProcess::enableKaraoke(bool /*b*/) {
|
---|
694 | /*
|
---|
695 | if (b) writeToStdin("af add karaoke"); else writeToStdin("af del karaoke");
|
---|
696 | */
|
---|
697 | messageFilterNotSupported("karaoke");
|
---|
698 | }
|
---|
699 | #endif
|
---|
700 |
|
---|
701 | void MPVProcess::enableExtrastereo(bool b) {
|
---|
702 | if (b) writeToStdin("af add lavfi=[extrastereo]"); else writeToStdin("af del lavfi=[extrastereo]");
|
---|
703 | }
|
---|
704 |
|
---|
705 | void MPVProcess::enableVolnorm(bool b, const QString & option) {
|
---|
706 | if (b) writeToStdin("af add drc=" + option); else writeToStdin("af del drc=" + option);
|
---|
707 | }
|
---|
708 |
|
---|
709 | void MPVProcess::setAudioEqualizer(const QString & values) {
|
---|
710 | if (values == previous_eq) return;
|
---|
711 |
|
---|
712 | if (!previous_eq.isEmpty()) {
|
---|
713 | writeToStdin("af del equalizer=" + previous_eq);
|
---|
714 | }
|
---|
715 | writeToStdin("af add equalizer=" + values);
|
---|
716 | previous_eq = values;
|
---|
717 | }
|
---|
718 |
|
---|
719 | void MPVProcess::setAudioDelay(double delay) {
|
---|
720 | writeToStdin("set audio-delay " + QString::number(delay));
|
---|
721 | }
|
---|
722 |
|
---|
723 | void MPVProcess::setSubDelay(double delay) {
|
---|
724 | writeToStdin("set sub-delay " + QString::number(delay));
|
---|
725 | }
|
---|
726 |
|
---|
727 | void MPVProcess::setLoop(int v) {
|
---|
728 | QString o;
|
---|
729 | switch (v) {
|
---|
730 | case -1: o = "no"; break;
|
---|
731 | case 0: o = "inf"; break;
|
---|
732 | default: o = QString::number(v);
|
---|
733 | }
|
---|
734 | writeToStdin(QString("set loop %1").arg(o));
|
---|
735 | }
|
---|
736 |
|
---|
737 | void MPVProcess::setAMarker(int sec) {
|
---|
738 | writeToStdin(QString("set ab-loop-a %1").arg(sec));
|
---|
739 | }
|
---|
740 |
|
---|
741 | void MPVProcess::setBMarker(int sec) {
|
---|
742 | writeToStdin(QString("set ab-loop-b %1").arg(sec));
|
---|
743 | }
|
---|
744 |
|
---|
745 | void MPVProcess::clearABMarkers() {
|
---|
746 | writeToStdin("set ab-loop-a no");
|
---|
747 | writeToStdin("set ab-loop-b no");
|
---|
748 | }
|
---|
749 |
|
---|
750 | void MPVProcess::takeScreenshot(ScreenshotType t, bool include_subtitles) {
|
---|
751 | writeToStdin(QString("screenshot %1 %2").arg(include_subtitles ? "subtitles" : "video").arg(t == Single ? "single" : "each-frame"));
|
---|
752 | }
|
---|
753 |
|
---|
754 | #ifdef CAPTURE_STREAM
|
---|
755 | void MPVProcess::switchCapturing() {
|
---|
756 | if (!capture_filename.isEmpty()) {
|
---|
757 | if (!capturing) {
|
---|
758 | QString f = capture_filename;
|
---|
759 | #ifdef Q_OS_WIN
|
---|
760 | // I hate Windows
|
---|
761 | f = f.replace("\\", "\\\\");
|
---|
762 | #endif
|
---|
763 | writeToStdin("set stream-capture \"" + f + "\"");
|
---|
764 | } else {
|
---|
765 | writeToStdin("set stream-capture \"\"");
|
---|
766 | }
|
---|
767 | capturing = !capturing;
|
---|
768 | }
|
---|
769 | }
|
---|
770 | #endif
|
---|
771 |
|
---|
772 | void MPVProcess::setTitle(int ID) {
|
---|
773 | writeToStdin("set disc-title " + QString::number(ID));
|
---|
774 | }
|
---|
775 |
|
---|
776 | #if DVDNAV_SUPPORT
|
---|
777 | void MPVProcess::discSetMousePos(int x, int y) {
|
---|
778 | qDebug("MPVProcess::discSetMousePos: %d %d", x, y);
|
---|
779 | //writeToStdin(QString("discnav mouse_move %1 %2").arg(x).arg(y));
|
---|
780 | // mouse_move doesn't accept options :?
|
---|
781 |
|
---|
782 | // For some reason this doesn't work either...
|
---|
783 | // So it's not possible to select options in the dvd menus just
|
---|
784 | // because there's no way to pass the mouse position to mpv, or it
|
---|
785 | // ignores it.
|
---|
786 | writeToStdin(QString("mouse %1 %2").arg(x).arg(y));
|
---|
787 | //writeToStdin("discnav mouse_move");
|
---|
788 | }
|
---|
789 |
|
---|
790 | void MPVProcess::discButtonPressed(const QString & button_name) {
|
---|
791 | writeToStdin("discnav " + button_name);
|
---|
792 | }
|
---|
793 | #endif
|
---|
794 |
|
---|
795 | void MPVProcess::setAspect(double aspect) {
|
---|
796 | writeToStdin("set video-aspect " + QString::number(aspect));
|
---|
797 | }
|
---|
798 |
|
---|
799 | void MPVProcess::setFullscreen(bool b) {
|
---|
800 | writeToStdin(QString("set fullscreen %1").arg(b ? "yes" : "no"));
|
---|
801 | }
|
---|
802 |
|
---|
803 | #if PROGRAM_SWITCH
|
---|
804 | void MPVProcess::setTSProgram(int ID) {
|
---|
805 | qDebug("MPVProcess::setTSProgram: function not supported");
|
---|
806 | }
|
---|
807 | #endif
|
---|
808 |
|
---|
809 | void MPVProcess::toggleDeinterlace() {
|
---|
810 | writeToStdin("cycle deinterlace");
|
---|
811 | }
|
---|
812 |
|
---|
813 | void MPVProcess::askForLength() {
|
---|
814 | writeToStdin("print_text \"INFO_LENGTH=${=length}\"");
|
---|
815 | }
|
---|
816 |
|
---|
817 | void MPVProcess::setOSDScale(double value) {
|
---|
818 | writeToStdin("set osd-scale " + QString::number(value));
|
---|
819 | }
|
---|
820 |
|
---|
821 | void MPVProcess::changeVF(const QString & filter, bool enable, const QVariant & option) {
|
---|
822 | qDebug() << "MPVProcess::changeVF:" << filter << enable;
|
---|
823 |
|
---|
824 | QString f;
|
---|
825 | if (filter == "letterbox") {
|
---|
826 | f = QString("expand=aspect=%1").arg(option.toDouble());
|
---|
827 | }
|
---|
828 | else
|
---|
829 | if (filter == "noise") {
|
---|
830 | f = "lavfi=[noise=alls=9:allf=t]";
|
---|
831 | }
|
---|
832 | else
|
---|
833 | if (filter == "blur") {
|
---|
834 | f = "lavfi=[unsharp=la=-1.5:ca=-1.5]";
|
---|
835 | }
|
---|
836 | else
|
---|
837 | if (filter == "sharpen") {
|
---|
838 | f = "lavfi=[unsharp=la=1.5:ca=1.5]";
|
---|
839 | }
|
---|
840 | else
|
---|
841 | if (filter == "deblock") {
|
---|
842 | f = "lavfi=[pp=" + option.toString() +"]";
|
---|
843 | }
|
---|
844 | else
|
---|
845 | if (filter == "dering") {
|
---|
846 | f = "lavfi=[pp=dr]";
|
---|
847 | }
|
---|
848 | else
|
---|
849 | if (filter == "phase") {
|
---|
850 | f = "lavfi=[phase=" + option.toString() +"]";
|
---|
851 | }
|
---|
852 | else
|
---|
853 | if (filter == "postprocessing") {
|
---|
854 | f = "lavfi=[pp]";
|
---|
855 | }
|
---|
856 | else
|
---|
857 | if (filter == "hqdn3d") {
|
---|
858 | QString o = option.toString();
|
---|
859 | if (!o.isEmpty()) o = "=" + o;
|
---|
860 | f = "lavfi=[hqdn3d" + o +"]";
|
---|
861 | }
|
---|
862 | else
|
---|
863 | if (filter == "rotate") {
|
---|
864 | QString o = option.toString();
|
---|
865 | if (o == "0") {
|
---|
866 | f = "rotate=270,flip";
|
---|
867 | }
|
---|
868 | else
|
---|
869 | if (o == "1") {
|
---|
870 | f = "rotate=90";
|
---|
871 | }
|
---|
872 | else
|
---|
873 | if (o == "2") {
|
---|
874 | f = "rotate=270";
|
---|
875 | }
|
---|
876 | else
|
---|
877 | if (o == "3") {
|
---|
878 | f = "rotate=90,flip";
|
---|
879 | }
|
---|
880 | }
|
---|
881 | else
|
---|
882 | if (filter == "flip" || filter == "mirror") {
|
---|
883 | f = filter;
|
---|
884 | }
|
---|
885 | else
|
---|
886 | if (filter == "scale" || filter == "gradfun") {
|
---|
887 | f = filter;
|
---|
888 | QString o = option.toString();
|
---|
889 | if (!o.isEmpty()) f += "=" + o;
|
---|
890 | }
|
---|
891 | else
|
---|
892 | if (filter == "lb" || filter == "l5") {
|
---|
893 | f = "lavfi=[pp=" + filter +"]";
|
---|
894 | }
|
---|
895 | else
|
---|
896 | if (filter == "yadif") {
|
---|
897 | if (option.toString() == "1") {
|
---|
898 | f = "yadif=field";
|
---|
899 | } else {
|
---|
900 | f = "yadif";
|
---|
901 | }
|
---|
902 | }
|
---|
903 | else
|
---|
904 | if (filter == "kerndeint") {
|
---|
905 | f = "lavfi=[kerndeint=" + option.toString() +"]";
|
---|
906 | }
|
---|
907 | else {
|
---|
908 | qDebug() << "MPVProcess::changeVF: unknown filter:" << filter;
|
---|
909 | }
|
---|
910 |
|
---|
911 | if (!f.isEmpty()) {
|
---|
912 | writeToStdin(QString("vf %1 \"%2\"").arg(enable ? "add" : "del").arg(f));
|
---|
913 | }
|
---|
914 | }
|
---|
915 |
|
---|
916 | void MPVProcess::changeStereo3DFilter(bool enable, const QString & in, const QString & out) {
|
---|
917 | QString filter = "stereo3d=" + in + ":" + out;
|
---|
918 | writeToStdin(QString("vf %1 \"%2\"").arg(enable ? "add" : "del").arg(filter));
|
---|
919 | }
|
---|
920 |
|
---|
921 | void MPVProcess::setSubStyles(const AssStyles & styles, const QString &) {
|
---|
922 | QString font = styles.fontname;
|
---|
923 | //arg << "--sub-text-font=" + font.replace(" ", "");
|
---|
924 | arg << "--sub-text-font=" + font;
|
---|
925 | arg << "--sub-text-color=#" + ColorUtils::colorToRRGGBB(styles.primarycolor);
|
---|
926 |
|
---|
927 | if (styles.borderstyle == AssStyles::Outline) {
|
---|
928 | arg << "--sub-text-shadow-color=#" + ColorUtils::colorToRRGGBB(styles.backcolor);
|
---|
929 | } else {
|
---|
930 | arg << "--sub-text-back-color=#" + ColorUtils::colorToRRGGBB(styles.outlinecolor);
|
---|
931 | }
|
---|
932 | arg << "--sub-text-border-color=#" + ColorUtils::colorToRRGGBB(styles.outlinecolor);
|
---|
933 |
|
---|
934 | arg << "--sub-text-border-size=" + QString::number(styles.outline * 2.5);
|
---|
935 | arg << "--sub-text-shadow-offset=" + QString::number(styles.shadow * 2.5);
|
---|
936 |
|
---|
937 | if (isOptionAvailable("--sub-text-font-size")) {
|
---|
938 | arg << "--sub-text-font-size=" + QString::number(styles.fontsize * 2.5);
|
---|
939 | }
|
---|
940 |
|
---|
941 | if (isOptionAvailable("--sub-text-bold")) {
|
---|
942 | arg << QString("--sub-text-bold=%1").arg(styles.bold ? "yes" : "no");
|
---|
943 | }
|
---|
944 |
|
---|
945 | if (isOptionAvailable("--sub-text-italic")) {
|
---|
946 | arg << QString("--sub-text-italic=%1").arg(styles.italic ? "yes" : "no");
|
---|
947 | }
|
---|
948 |
|
---|
949 | QString halign;
|
---|
950 | switch (styles.halignment) {
|
---|
951 | case AssStyles::Left: halign = "left"; break;
|
---|
952 | case AssStyles::Right: halign = "right"; break;
|
---|
953 | }
|
---|
954 |
|
---|
955 | QString valign;
|
---|
956 | switch (styles.valignment) {
|
---|
957 | case AssStyles::VCenter: valign = "center"; break;
|
---|
958 | case AssStyles::Top: valign = "top"; break;
|
---|
959 | }
|
---|
960 |
|
---|
961 | if (!halign.isEmpty() || !valign.isEmpty()) {
|
---|
962 | if (isOptionAvailable("--sub-text-align-x")) {
|
---|
963 | if (!halign.isEmpty()) arg << "--sub-text-align-x=" + halign;
|
---|
964 | if (!valign.isEmpty()) arg << "--sub-text-align-y=" + valign;
|
---|
965 | }
|
---|
966 | }
|
---|
967 | }
|
---|
968 |
|
---|
969 | void MPVProcess::setChannelsFile(const QString & filename) {
|
---|
970 | arg << "--dvbin-file=" + filename;
|
---|
971 | }
|
---|