Changeset 188 for smplayer/trunk/src/mpvoptions.cpp
- Timestamp:
- Jan 24, 2017, 12:41:54 PM (8 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 186
- Property svn:mergeinfo changed
-
smplayer/trunk/src/mpvoptions.cpp
r181 r188 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 6Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 20 20 #include <QDebug> 21 21 #include "inforeader.h" 22 #include "deviceinfo.h" 22 23 23 24 void MPVProcess::addArgument(const QString & /*a*/) { … … 30 31 "INFO_VIDEO_ASPECT=${=video-aspect}\n" 31 32 // "INFO_VIDEO_DSIZE=${=dwidth}x${=dheight}\n" 32 "INFO_VIDEO_FPS=${= fps}\n"33 "INFO_VIDEO_FPS=${=container-fps:${=fps}}\n" 33 34 // "INFO_VIDEO_BITRATE=${=video-bitrate}\n" 34 35 "INFO_VIDEO_FORMAT=${=video-format}\n" … … 47 48 "INFO_LENGTH=${=duration:${=length}}\n" 48 49 49 "INFO_DEMUXER=${= demuxer}\n"50 "INFO_DEMUXER=${=current-demuxer:${=demuxer}}\n" 50 51 "INFO_SEEKABLE=${=seekable}\n" 51 52 "INFO_TITLES=${=disc-titles}\n" … … 61 62 "METADATA_COPYRIGHT=${metadata/by-key/copyright:}\n" 62 63 63 "INFO_MEDIA_TITLE=${=media-title:}\n"; 64 "INFO_MEDIA_TITLE=${=media-title:}\n" 65 "INFO_STREAM_PATH=${stream-path}\n"; 64 66 65 67 #ifdef CUSTOM_STATUS 66 arg << "--term-status-msg=STATUS: ${=time-pos} / ${=duration:${=length:0}} P: ${=pause} B: ${=paused-for-cache} I: ${=core-idle} ";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}"; 67 69 #endif 68 70 … … 75 77 #ifdef CAPTURE_STREAM 76 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 } 77 87 #endif 78 88 } … … 90 100 void MPVProcess::disableInput() { 91 101 arg << "--no-input-default-bindings"; 92 arg << "--input-x11-keyboard=no"; 102 if (isOptionAvailable("--input-vo-keyboard")) { 103 arg << "--input-vo-keyboard=no"; 104 } else { 105 arg << "--input-x11-keyboard=no"; 106 } 93 107 arg << "--no-input-cursor"; 94 108 arg << "--cursor-autohide=no"; … … 96 110 97 111 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); 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); 102 124 } 103 125 … … 231 253 if (option_name == "subfont-text-scale" || option_name == "ass-font-scale") { 232 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(); 233 267 } 234 268 else … … 306 340 } 307 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 308 358 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; 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 + ","; 317 401 } 318 402 else … … 368 452 else 369 453 if (option_name == "wid" || 370 option_name == "vo" ||371 454 option_name == "aid" || option_name == "vid" || 372 455 option_name == "volume" || 373 option_name == "ass-styles" || option_name == "ass-force-style" || 374 option_name == "ass-line-spacing" || 456 option_name == "ass-styles" || 375 457 option_name == "embeddedfonts" || 376 458 option_name == "osd-scale" || … … 387 469 option_name == "demuxer" || 388 470 option_name == "frames" || 471 option_name == "user-agent" || option_name == "referrer" || 389 472 option_name == "ab-loop-a" || option_name == "ab-loop-b") 390 473 { … … 400 483 401 484 void MPVProcess::addUserOption(const QString & option) { 402 arg << 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; 403 502 if (option == "-v") { 404 503 verbose = true; … … 621 720 622 721 void MPVProcess::showFilenameOnOSD() { 623 writeToStdin("show_text \"${filename}\" 2000 0"); 722 #ifdef OSD_WITH_TIMER 723 toggleInfoOnOSD(); 724 #else 725 showOSDText("${filename}", 2000, 0); 726 #endif 624 727 } 625 728 626 729 void MPVProcess::showTimeOnOSD() { 627 writeToStdin("show_text \"${time-pos} / ${length:0} (${percent-pos}%)\" 2000 0"); 628 } 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 629 783 630 784 void MPVProcess::setContrast(int value) { … … 920 1074 921 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 922 1097 QString font = styles.fontname; 923 1098 //arg << "--sub-text-font=" + font.replace(" ", ""); 924 arg << "--sub-text-font=" + font;925 arg << "--sub-text-color=#" + ColorUtils::colorToRRGGBB(styles.primarycolor);1099 arg << sub_font + "=" + font; 1100 arg << sub_color + "=#" + ColorUtils::colorToAARRGGBB(styles.primarycolor); 926 1101 927 1102 if (styles.borderstyle == AssStyles::Outline) { 928 arg << "--sub-text-shadow-color=#" + ColorUtils::colorToRRGGBB(styles.backcolor);1103 arg << sub_shadow_color + "=#" + ColorUtils::colorToAARRGGBB(styles.backcolor); 929 1104 } 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);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); 936 1111 937 1112 if (isOptionAvailable("--sub-text-font-size")) {
Note:
See TracChangeset
for help on using the changeset viewer.