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