File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
src/AvTranscoder/properties Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -396,7 +396,17 @@ size_t VideoProperties::getNbFrames() const
396
396
throw std::runtime_error (" unknown format context" );
397
397
size_t nbFrames = _formatContext->streams [_streamIndex]->nb_frames ;
398
398
if (nbFrames == 0 )
399
- nbFrames = getFps () * getDuration ();
399
+ {
400
+ LOG_WARN (" The number of frames in the stream '" << _streamIndex << " ' of file '" << _formatContext->filename << " ' is unknown." )
401
+ const float duration = getDuration ();
402
+ if (duration != 0 )
403
+ {
404
+ LOG_INFO (" Try to compute the number of frames from the fps and the duration." )
405
+ nbFrames = getFps () * duration;
406
+ }
407
+ else
408
+ return 0 ;
409
+ }
400
410
return nbFrames;
401
411
}
402
412
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class AvExport VideoProperties : public StreamProperties
43
43
size_t getBitRate () const ; // /< in bits/s
44
44
size_t getMaxBitRate () const ;
45
45
size_t getMinBitRate () const ;
46
- size_t getNbFrames () const ;
46
+ size_t getNbFrames () const ; // /< 0 if unknown
47
47
size_t getTicksPerFrame () const ;
48
48
size_t getWidth () const ;
49
49
size_t getHeight () const ;
You can’t perform that action at this time.
0 commit comments