Skip to content

Commit 44add38

Browse files
author
Clement Champetier
committed
InputFile: seekAtFrame use correct fps of input
Instead of hardcoded fps = 25.
1 parent cec6d00 commit 44add38

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/AvTranscoder/file/InputFile.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,16 @@ bool InputFile::readNextPacket( CodedData& data, const size_t streamIndex )
146146

147147
void InputFile::seekAtFrame( const size_t frame )
148148
{
149-
uint64_t pos = frame / 25 * AV_TIME_BASE; // WARNING: hardcoded fps
149+
// Get Fps from first video stream or first audio stream if no video
150+
double fps = 1;
151+
if( _properties.getNbVideoStreams() )
152+
fps = _properties.getVideoProperties().at( 0 ).getFps();
153+
else if( _properties.getNbAudioStreams() )
154+
fps = _properties.getAudioProperties().at( 0 ).getFps();
150155

156+
uint64_t pos = frame / fps * AV_TIME_BASE;
157+
158+
// Offset of start time
151159
if( (int)_formatContext.getStartTime() != AV_NOPTS_VALUE )
152160
pos += _formatContext.getStartTime();
153161

0 commit comments

Comments
 (0)