Ignore:
Timestamp:
May 3, 2016, 2:14:41 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update vendor to version 16.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified smplayer/vendor/current/src/videopreview/videopreview.cpp

    r168 r175  
    11/*  smplayer, GUI front-end for mplayer.
    2     Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
     2    Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
    33
    44    This program is free software; you can redistribute it and/or modify
     
    1919#include "videopreview.h"
    2020#include "videopreviewconfigdialog.h"
     21#include "playerid.h"
    2122#include <QProcess>
    2223#include <QRegExp>
     
    4344#define RENAME_PICTURES 0
    4445
     46#define N_OUTPUT_FRAMES 1
     47
     48// MPlayer2 doesn't support png outdir
     49/* #define VP_USE_PNG_OUTDIR */
     50
    4551VideoPreview::VideoPreview(QString mplayer_path, QWidget * parent) : QWidget(parent, Qt::Window)
    4652{
     
    6369        full_output_dir = QDir::tempPath() +"/"+ output_dir;
    6470
    65         progress = new QProgressDialog(this);
     71        progress = new QProgressDialog(parent != 0 ? parent : this);
    6672        progress->setMinimumDuration(0);
    6773        connect( progress, SIGNAL(canceled()), this, SLOT(cancelPressed()) );
     
    167173
    168174QString VideoPreview::framePicture() {
    169         if (prop.extract_format == PNG)
    170                 return "00000005.png";
    171         else
    172                 return "00000005.jpg";
     175        return QString("0000000%1.%2").arg(N_OUTPUT_FRAMES == 1 ? 1 : N_OUTPUT_FRAMES-1).arg(prop.extract_format == PNG ? "png" : "jpg");
    173176}
    174177
     
    242245                if (canceled) return false;
    243246
    244                 if (!runMplayer(current_time, aspect_ratio)) return false;
     247                if (!runPlayer(current_time, aspect_ratio)) return false;
    245248
    246249                QString frame_picture = full_output_dir + "/" + framePicture();
     
    268271}
    269272
    270 bool VideoPreview::runMplayer(int seek, double aspect_ratio) {
     273bool VideoPreview::runPlayer(int seek, double aspect_ratio) {
    271274        QStringList args;
    272         args << "-nosound";
    273 
    274         if (prop.extract_format == PNG) {
    275                 args << "-vo"
    276                 << "png:outdir=\""+full_output_dir+"\"";
    277         } else {
    278                 args << "-vo"
    279                 << "jpeg:outdir=\""+full_output_dir+"\"";
    280         }
    281 
    282         args << "-frames" << "6" << "-ss" << QString::number(seek);
    283 
    284         if (aspect_ratio != 0) {
    285                 args << "-aspect" << QString::number(aspect_ratio) << "-zoom";
    286         }
    287 
    288         if (!prop.dvd_device.isEmpty()) {
    289                 args << "-dvd-device" << prop.dvd_device;
    290         }
    291 
    292         /*
    293         if (display_osd) {
    294                 args << "-vf" << "expand=osd=1" << "-osdlevel" << "2";
    295         }
    296         */
     275
     276        if (PlayerID::player(mplayer_bin) == PlayerID::MPV) {
     277                #ifdef MPV_SUPPORT
     278                // MPV
     279                args << "--no-config" << "--no-audio" << "--no-cache";
     280                args << "--frames=" + QString::number(N_OUTPUT_FRAMES);
     281                args << "--framedrop=no" << "--start=" + QString::number(seek);
     282                if (aspect_ratio != 0) {
     283                        args << "--video-aspect=" + QString::number(aspect_ratio);
     284                }
     285                if (!prop.dvd_device.isEmpty()) args << "--dvd-device=" + prop.dvd_device;
     286                QString format = (prop.extract_format == PNG) ? "png:png-compression=0" : "jpg";
     287                args << QString("--vo=image=format=%1:outdir=\"%2\"").arg(format).arg(full_output_dir);
     288               
     289                #ifdef Q_OS_WIN
     290                args << "--use-text-osd=no";
     291                #endif
     292                #endif // MPV_SUPPORT
     293        }
     294        else {
     295                #ifdef MPLAYER_SUPPORT
     296                // MPlayer
     297                args << "-nosound" << "-nocache" << "-noframedrop";
     298
     299                if (prop.extract_format == PNG) {
     300                        args << "-vo"
     301                        #ifdef VP_USE_PNG_OUTDIR
     302                        << "png:outdir=\""+full_output_dir+"\"";
     303                        #else
     304                        << "png";
     305                        #endif
     306                } else {
     307                        args << "-vo"
     308                        << "jpeg:outdir=\""+full_output_dir+"\"";
     309                }
     310
     311                args << "-frames" << QString::number(N_OUTPUT_FRAMES) << "-ss" << QString::number(seek);
     312
     313                if (aspect_ratio != 0) {
     314                        args << "-aspect" << QString::number(aspect_ratio) << "-zoom";
     315                }
     316
     317                if (!prop.dvd_device.isEmpty()) {
     318                        args << "-dvd-device" << prop.dvd_device;
     319                }
     320
     321                #ifdef Q_OS_WIN
     322                args << "-nofontconfig";
     323                #endif
     324
     325                /*
     326                if (display_osd) {
     327                        args << "-vf" << "expand=osd=1" << "-osdlevel" << "2";
     328                }
     329                */
     330                #endif // MPLAYER_SUPPORT
     331        }
    297332
    298333        args << prop.input_video;
     
    303338
    304339        QProcess p;
     340        #ifndef VP_USE_PNG_OUTDIR
     341        p.setWorkingDirectory(full_output_dir);
     342        #endif
    305343        p.start(mplayer_bin, args);
    306344        if (!p.waitForFinished()) {
     
    443481
    444482        QStringList args;
    445         args << "-vo" << "null" << "-ao" << "null" << "-frames" << "1" << "-identify" << "-nocache" << "-noquiet" << filename;
    446 
    447         if (!prop.dvd_device.isEmpty()) {
    448                 args << "-dvd-device" << prop.dvd_device;
     483
     484        if (PlayerID::player(mplayer_path) == PlayerID::MPV) {
     485                #ifdef MPV_SUPPORT
     486                // MPV
     487                args << "--term-playing-msg="
     488                "ID_LENGTH=${=length}\n"
     489                "ID_VIDEO_WIDTH=${=width}\n"
     490                "ID_VIDEO_HEIGHT=${=height}\n"
     491                "ID_VIDEO_FPS=${=fps}\n"
     492                "ID_VIDEO_ASPECT=${=video-aspect}\n"
     493                "ID_VIDEO_BITRATE=${=video-bitrate}\n"
     494                "ID_AUDIO_BITRATE=${=audio-bitrate}\n"
     495                "ID_AUDIO_RATE=${=audio-samplerate}\n"
     496                "ID_VIDEO_FORMAT=${=video-format}";
     497
     498                args << "--vo=null" << "-ao=null" << "--frames=1" << "--no-quiet" << "--no-cache" << "--no-config";
     499                if (!prop.dvd_device.isEmpty()) args << "--dvd-device=" + prop.dvd_device;
     500                args << filename;
     501                #endif // MPV_SUPPORT
     502        }
     503        else {
     504                #ifdef MPLAYER_SUPPORT
     505                // MPlayer
     506                args << "-vo" << "null" << "-ao" << "null" << "-frames" << "1" << "-identify" << "-nocache" << "-noquiet";
     507                if (!prop.dvd_device.isEmpty()) args << "-dvd-device" << prop.dvd_device;
     508
     509                #ifdef Q_OS_WIN
     510                args << "-nofontconfig";
     511                #endif
     512
     513                args << filename;
     514                #endif // MPLAYER_SUPPORT
    449515        }
    450516
Note: See TracChangeset for help on using the changeset viewer.