| 565 | } |
| 566 | |
| 567 | bool ParserAVFormat::runParsingOfFile(QString compressedFilePath) |
| 568 | { |
| 569 | // Open the file but don't parse it yet. |
| 570 | QScopedPointer<FileSourceFFmpegFile> ffmpegFile(new FileSourceFFmpegFile()); |
| 571 | if (!ffmpegFile->openFile(compressedFilePath, nullptr, nullptr, false)) |
| 572 | { |
| 573 | emit backgroundParsingDone("Error opening the ffmpeg file."); |
| 574 | return false; |
| 575 | } |
| 576 | |
| 577 | this->codecID = ffmpegFile->getVideoStreamCodecID(); |
| 578 | if (this->codecID.isAVC()) |
| 579 | this->annexBParser.reset(new ParserAnnexBAVC()); |
| 580 | else if (this->codecID.isHEVC()) |
| 581 | this->annexBParser.reset(new ParserAnnexBHEVC()); |
| 582 | else if (this->codecID.isMpeg2()) |
| 583 | this->annexBParser.reset(new ParserAnnexBMpeg2()); |
| 584 | else if (this->codecID.isAV1()) |
| 585 | this->obuParser.reset(new ParserAV1OBU()); |
| 586 | else if (this->codecID.isNone()) |
| 587 | { |
| 588 | emit backgroundParsingDone("Unknown codec ID " + this->codecID.getCodecName()); |
| 589 | return false; |
| 590 | } |
| 591 | |
| 592 | if (this->annexBParser) |
| 593 | this->annexBParser->setRedirectPlotModel(this->getHRDPlotModel()); |
| 594 | if (this->obuParser) |
| 595 | this->obuParser->setRedirectPlotModel(this->getHRDPlotModel()); |
| 596 | |
| 597 | // Don't seek to the beginning here. This causes more problems then it solves. |
| 598 | // ffmpegFile->seekFileToBeginning(); |
| 599 | |
| 600 | // First get the extradata and push it to the parser |
| 601 | try |
| 602 | { |
| 603 | auto extradata = SubByteReaderLogging::convertToByteVector(ffmpegFile->getExtradata()); |
| 604 | this->parseExtradata(extradata); |
| 605 | } |
| 606 | catch (...) |
| 607 | { |
| 608 | emit backgroundParsingDone("Error parsing Extradata from container"); |
| 609 | return false; |
| 610 | } |
| 611 | try |
| 612 | { |
| 613 | auto metadata = ffmpegFile->getMetadata(); |
| 614 | this->parseMetadata(metadata); |
| 615 | } |
| 616 | catch (...) |
| 617 | { |
| 618 | emit backgroundParsingDone("Error parsing Metadata from container"); |
| 619 | return false; |
| 620 | } |
| 621 | |
| 622 | int max_ts = ffmpegFile->getMaxTS(); |
| 623 | this->videoStreamIndex = ffmpegFile->getVideoStreamIndex(); |
| 624 | this->framerate = ffmpegFile->getFramerate(); |
nothing calls this directly
no test coverage detected