Skip to content

Commit eb7442d

Browse files
author
Clement Champetier
committed
VideoProperties: refactor how to return the number of frames
* Add log. * Avoid complicate if/else...
1 parent 604d7a8 commit eb7442d

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -373,24 +373,28 @@ size_t VideoProperties::getNbFrames() const
373373
{
374374
if(!_formatContext)
375375
throw std::runtime_error("unknown format context");
376+
376377
size_t nbFrames = _formatContext->streams[_streamIndex]->nb_frames;
377-
if(nbFrames == 0)
378-
{
379-
if(_levelAnalysis == eAnalyseLevelFull && _nbFrames)
380-
return _nbFrames;
378+
if(nbFrames)
379+
return nbFrames;
380+
LOG_WARN("The number of frames of the stream '" << _streamIndex << "' of file '" << _formatContext->filename
381+
<< "' is unknown.")
381382

382-
LOG_WARN("The number of frames in the stream '" << _streamIndex << "' of file '" << _formatContext->filename
383-
<< "' is unknown.")
384-
const float duration = getDuration();
385-
if(duration != 0)
383+
if(_levelAnalysis == eAnalyseLevelHeader)
384+
{
385+
LOG_INFO("Need a deeper analysis: see eAnalyseLevelFirstGop.")
386+
return 0;
387+
}
388+
else
389+
{
390+
if(! _nbFrames)
386391
{
387-
LOG_INFO("Try to compute the number of frames from the fps and the duration.")
388-
nbFrames = getFps() * duration;
392+
LOG_INFO("Estimate the number of frames from the fps and the duration.")
393+
return getFps() * getDuration();
389394
}
390-
else
391-
return 0;
395+
LOG_INFO("Get the exact number of frames.")
396+
return _nbFrames;
392397
}
393-
return nbFrames;
394398
}
395399

396400
size_t VideoProperties::getTicksPerFrame() const

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy