File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
src/AvTranscoder/properties Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
#include < AvTranscoder/data/decoded/Frame.hpp>
4
4
#include < AvTranscoder/properties/util.hpp>
5
+ #include < AvTranscoder/properties/FileProperties.hpp>
5
6
#include < AvTranscoder/progress/NoDisplayProgress.hpp>
6
7
7
8
extern " C" {
@@ -464,6 +465,22 @@ float VideoProperties::getFps() const
464
465
return av_q2d (_formatContext->streams [_streamIndex]->avg_frame_rate );
465
466
}
466
467
468
+ float VideoProperties::getDuration () const
469
+ {
470
+ const float duration = StreamProperties::getDuration ();
471
+ if (duration == 0 )
472
+ {
473
+ LOG_WARN (" The duration of the stream '" << _streamIndex << " ' of file '" << _formatContext->filename << " ' is unknown." )
474
+ if (_fileProperties->isRawFormat ())
475
+ {
476
+ LOG_INFO (" Get the file size to compute the duration." )
477
+ return _fileProperties->getFileSize () / getBitRate () * 8 ;
478
+ }
479
+ return 0 ;
480
+ }
481
+ return duration;
482
+ }
483
+
467
484
bool VideoProperties::hasBFrames () const
468
485
{
469
486
if (!_codecContext)
Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ class AvExport VideoProperties : public StreamProperties
61
61
*/
62
62
float getFps () const ;
63
63
64
+ /* *
65
+ * @brief Override StreamProperties method.
66
+ * @return The stream duration in seconds, 0 if not available
67
+ */
68
+ float getDuration () const ;
69
+
64
70
bool hasBFrames () const ;
65
71
// bool isClosedGop() const;
66
72
You can’t perform that action at this time.
0 commit comments