Definition at line 401 of file RgbDataSrcLavc_old.h. References mFormatCtx, Impala::Core::Stream::RgbDataSrc::mSrcName, Impala::Core::Stream::RgbDataSrc::mStreamCount, mVideoStream, and mVideoStreamIndex. Referenced by Init(). 00402 { 00403 mStreamCount = mFormatCtx->nb_streams; 00404 mVideoStreamIndex = -1; 00405 mVideoStream = 0; 00406 00407 // find the first video stream 00408 for (int i = 0; i < mStreamCount; i++) 00409 { 00410 if (mFormatCtx->streams[i]->codec->codec_type 00411 == CODEC_TYPE_VIDEO) 00412 { 00413 if (mVideoStreamIndex >= 0) 00414 throw (LAVCException("Multiple video streams found in: " 00415 + mSrcName, 0)); 00416 00417 mVideoStreamIndex = i; 00418 mVideoStream = mFormatCtx->streams[i]; 00419 } 00420 } 00421 if (mVideoStream == 0) 00422 throw LAVCException("Could not find video stream in: " 00423 + mSrcName, 0); 00424 00425 // collect video stream info 00426 mVideoDuration = mVideoStream->duration; // number of (time) fractions 00427 const AVRational videoTimeBase = 00428 mVideoStream->time_base; // time fraction duration (seconds) 00429 mTimeBaseNum = videoTimeBase.num; 00430 mTimeBaseDen = videoTimeBase.den; 00431 mDuration = ceil( 00432 double(mVideoDuration) * mTimeBaseNum / mTimeBaseDen 00433 ); // rounded up (number of seconds) 00434 mDurationSec = mDuration; 00435 mDurationHour = mDurationSec / 3600; 00436 mDurationSec %= 3600; 00437 mDurationMin = mDurationSec / 60; 00438 mDurationSec %= 60; 00439 00440 // collect frame info 00441 mFrameRateNum = mVideoStream->r_frame_rate.num; 00442 mFrameRateDen = mVideoStream->r_frame_rate.den; 00443 const double fractionsPerSec = double(mTimeBaseDen) / mTimeBaseNum; 00444 const double secondsPerFrame = double(mFrameRateDen) / mFrameRateNum; 00445 const double fractionsPerFrame = fractionsPerSec * secondsPerFrame; 00446 const double frameCount = mVideoDuration / fractionsPerFrame; 00447 mFrameCountCalculated = ceil(frameCount); 00448 ILOG_DEBUG("Frame count estimate based on video duration: " << 00449 mFrameCountCalculated); 00450 00451 return true; 00452 }
|