MCPcopy Create free account
hub / github.com/IENT/YUView / openFileAndFindVideoStream

Method openFileAndFindVideoStream

YUViewLib/src/filesource/FileSourceFFmpegFile.cpp:474–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472}
473
474void FileSourceFFmpegFile::openFileAndFindVideoStream(QString fileName)
475{
476 this->isFileOpened = false;
477
478 this->ff.loadFFmpegLibraries();
479 if (!this->ff.loadingSuccessfull())
480 return;
481
482 // Open the input file
483 if (!this->ff.openInput(this->formatCtx, fileName))
484 return;
485
486 this->formatCtx.getInputFormat();
487
488 for (unsigned idx = 0; idx < this->formatCtx.getNbStreams(); idx++)
489 {
490 auto stream = this->formatCtx.getStream(idx);
491 auto streamType = stream.getCodecType();
492 auto codeID = this->ff.getCodecIDWrapper(stream.getCodecID());
493 if (streamType == AVMEDIA_TYPE_VIDEO)
494 {
495 this->video_stream = stream;
496 this->streamIndices.video = idx;
497 }
498 else if (streamType == AVMEDIA_TYPE_AUDIO)
499 this->streamIndices.audio.append(idx);
500 else if (streamType == AVMEDIA_TYPE_SUBTITLE)
501 {
502 if (codeID.getCodecName() == "dvb_subtitle")
503 this->streamIndices.subtitle.dvb.append(idx);
504 else if (codeID.getCodecName() == "eia_608")
505 this->streamIndices.subtitle.eia608.append(idx);
506 else
507 this->streamIndices.subtitle.other.append(idx);
508 }
509 }
510 if (!this->video_stream)
511 return;
512
513 this->currentPacket = this->ff.allocatePacket();
514
515 // Get the frame rate, picture size and color conversion mode
516 auto avgFrameRate = this->video_stream.getAvgFrameRate();
517 if (avgFrameRate.den == 0)
518 this->frameRate = -1.0;
519 else
520 this->frameRate = avgFrameRate.num / double(avgFrameRate.den);
521
522 const auto ffmpegPixFormat =
523 this->ff.getAvPixFmtDescriptionFromAvPixelFormat(this->video_stream.getPixelFormat());
524 this->rawFormat = ffmpegPixFormat.getRawFormat();
525 if (this->rawFormat == video::RawFormat::YUV)
526 this->pixelFormat_yuv = ffmpegPixFormat.getPixelFormatYUV();
527 else if (this->rawFormat == video::RawFormat::RGB)
528 this->pixelFormat_rgb = ffmpegPixFormat.getRGBPixelFormat();
529
530 this->duration = this->formatCtx.getDuration();
531 this->timeBase = this->video_stream.getTimeBase();

Callers 1

openFileMethod · 0.95

Calls 15

loadFFmpegLibrariesMethod · 0.80
loadingSuccessfullMethod · 0.80
openInputMethod · 0.80
getNbStreamsMethod · 0.80
getStreamMethod · 0.80
getCodecIDWrapperMethod · 0.80
appendMethod · 0.80
allocatePacketMethod · 0.80
getAvgFrameRateMethod · 0.80
getInputFormatMethod · 0.45
getCodecTypeMethod · 0.45

Tested by

no test coverage detected