Changeset 175 for smplayer/vendor/current/src/videopreview/videopreview.cpp
- Timestamp:
- May 3, 2016, 2:14:41 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified smplayer/vendor/current/src/videopreview/videopreview.cpp ¶
r168 r175 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 4Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 19 19 #include "videopreview.h" 20 20 #include "videopreviewconfigdialog.h" 21 #include "playerid.h" 21 22 #include <QProcess> 22 23 #include <QRegExp> … … 43 44 #define RENAME_PICTURES 0 44 45 46 #define N_OUTPUT_FRAMES 1 47 48 // MPlayer2 doesn't support png outdir 49 /* #define VP_USE_PNG_OUTDIR */ 50 45 51 VideoPreview::VideoPreview(QString mplayer_path, QWidget * parent) : QWidget(parent, Qt::Window) 46 52 { … … 63 69 full_output_dir = QDir::tempPath() +"/"+ output_dir; 64 70 65 progress = new QProgressDialog( this);71 progress = new QProgressDialog(parent != 0 ? parent : this); 66 72 progress->setMinimumDuration(0); 67 73 connect( progress, SIGNAL(canceled()), this, SLOT(cancelPressed()) ); … … 167 173 168 174 QString 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"); 173 176 } 174 177 … … 242 245 if (canceled) return false; 243 246 244 if (!run Mplayer(current_time, aspect_ratio)) return false;247 if (!runPlayer(current_time, aspect_ratio)) return false; 245 248 246 249 QString frame_picture = full_output_dir + "/" + framePicture(); … … 268 271 } 269 272 270 bool VideoPreview::run Mplayer(int seek, double aspect_ratio) {273 bool VideoPreview::runPlayer(int seek, double aspect_ratio) { 271 274 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 } 297 332 298 333 args << prop.input_video; … … 303 338 304 339 QProcess p; 340 #ifndef VP_USE_PNG_OUTDIR 341 p.setWorkingDirectory(full_output_dir); 342 #endif 305 343 p.start(mplayer_bin, args); 306 344 if (!p.waitForFinished()) { … … 443 481 444 482 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 449 515 } 450 516
Note:
See TracChangeset
for help on using the changeset viewer.