Skip to content

Commit 5e6e05a

Browse files
author
Clement Champetier
committed
properties: seek at the beginning of the stream in the corresponding methods
Instead of a 'global' seek in FileProperties.
1 parent 1804369 commit 5e6e05a

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/AvTranscoder/properties/FileProperties.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ FileProperties::FileProperties(const FormatContext& formatContext)
3030

3131
void FileProperties::extractStreamProperties(IProgress& progress, const EAnalyseLevel level)
3232
{
33-
// if the analysis level wiil decode some streams parts, seek at the beginning
34-
if(level > eAnalyseLevelHeader && ! isRawFormat())
35-
const_cast<FormatContext*>(_formatContext)->seek(0, AVSEEK_FLAG_BACKWARD);
36-
3733
// clear properties
3834
clearStreamProperties();
3935

@@ -121,10 +117,6 @@ void FileProperties::extractStreamProperties(IProgress& progress, const EAnalyse
121117
const size_t unknownStreamIndex = _unknownStreams.at(streamIndex).getStreamIndex();
122118
_streams[unknownStreamIndex] = &_unknownStreams.at(streamIndex);
123119
}
124-
125-
// if the analysis level has decoded some streams parts, return at the beginning
126-
if(level > eAnalyseLevelHeader && ! isRawFormat())
127-
const_cast<FormatContext*>(_formatContext)->seek(0, AVSEEK_FLAG_BACKWARD);
128120
}
129121

130122
std::string FileProperties::getFilename() const

src/AvTranscoder/properties/StreamProperties.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,12 @@ size_t StreamProperties::getBitRate() const
139139
if(positionOfFirstKeyFrame != -1 && positionOfLastKeyFrame != -1)
140140
break;
141141
}
142+
// Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself)
142143
avcodec_close(_codecContext);
143144

145+
// Returns at the beginning of the stream
146+
const_cast<FormatContext*>(&_fileProperties->getFormatContext())->seek(0, AVSEEK_FLAG_BYTE);
147+
144148
const size_t gopSize = positionOfLastKeyFrame - positionOfFirstKeyFrame;
145149
if(gopSize > 0)
146150
{

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
484484

485485
// Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself)
486486
avcodec_close(_codecContext);
487+
488+
// Returns at the beginning of the stream
489+
const_cast<FormatContext*>(&_fileProperties->getFormatContext())->seek(0, AVSEEK_FLAG_BYTE);
487490
}
488491
}
489492
}

0 commit comments

Comments
 (0)