| 418 | } |
| 419 | |
| 420 | bool FileSourceFFmpegFile::scanBitstream(QWidget *mainWindow) |
| 421 | { |
| 422 | if (!this->isFileOpened) |
| 423 | return false; |
| 424 | |
| 425 | // Create the dialog (if the given pointer is not null) |
| 426 | auto maxPTS = this->getMaxTS(); |
| 427 | // Updating the dialog (setValue) is quite slow. Only do this if the percent value changes. |
| 428 | int curPercentValue = 0; |
| 429 | QScopedPointer<QProgressDialog> progress; |
| 430 | if (mainWindow != nullptr) |
| 431 | { |
| 432 | progress.reset( |
| 433 | new QProgressDialog("Parsing (indexing) bitstream...", "Cancel", 0, 100, mainWindow)); |
| 434 | progress->setMinimumDuration(1000); // Show after 1s |
| 435 | progress->setAutoClose(false); |
| 436 | progress->setAutoReset(false); |
| 437 | progress->setWindowModality(Qt::WindowModal); |
| 438 | } |
| 439 | |
| 440 | this->nrFrames = 0; |
| 441 | while (this->goToNextPacket(true)) |
| 442 | { |
| 443 | DEBUG_FFMPEG("FileSourceFFmpegFile::scanBitstream: frame %d pts %d dts %d%s", |
| 444 | this->nrFrames, |
| 445 | (int)this->currentPacket.getPTS(), |
| 446 | (int)this->currentPacket.getDTS(), |
| 447 | this->currentPacket.getFlagKeyframe() ? " - keyframe" : ""); |
| 448 | |
| 449 | if (this->currentPacket.getFlagKeyframe()) |
| 450 | this->keyFrameList.append(pictureIdx(this->nrFrames, this->currentPacket.getDTS())); |
| 451 | |
| 452 | if (progress && progress->wasCanceled()) |
| 453 | return false; |
| 454 | |
| 455 | int newPercentValue = 0; |
| 456 | if (maxPTS != 0) |
| 457 | newPercentValue = functions::clip(int(this->currentPacket.getPTS() * 100 / maxPTS), 0, 100); |
| 458 | if (newPercentValue != curPercentValue) |
| 459 | { |
| 460 | if (progress) |
| 461 | progress->setValue(newPercentValue); |
| 462 | curPercentValue = newPercentValue; |
| 463 | } |
| 464 | |
| 465 | this->nrFrames++; |
| 466 | } |
| 467 | |
| 468 | DEBUG_FFMPEG("FileSourceFFmpegFile::scanBitstream: Scan done. Found %d frames and %d keyframes.", |
| 469 | this->nrFrames, |
| 470 | this->keyFrameList.length()); |
| 471 | return !progress->wasCanceled(); |
| 472 | } |
| 473 | |
| 474 | void FileSourceFFmpegFile::openFileAndFindVideoStream(QString fileName) |
| 475 | { |
no test coverage detected