Skip to content

Commit 77f311e

Browse files
author
Clement Champetier
committed
InputFile: fixed filled of properties when create a new InputFile
* Need to find stream info before get them as properties. * Need to have FileProperties attribute as pointer, because we want to create it only once (after _formatContext.findStreamInfo()).
1 parent 6b4b558 commit 77f311e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/AvTranscoder/file/InputFile.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ namespace avtranscoder
2222

2323
InputFile::InputFile(const std::string& filename)
2424
: _formatContext(filename, AV_OPT_FLAG_DECODING_PARAM)
25-
, _properties(_formatContext)
25+
, _properties(NULL)
2626
, _filename(filename)
2727
, _inputStreams()
2828
{
29+
// Fill the FormatContext with the stream information
2930
_formatContext.findStreamInfo();
3031

32+
// Get the stream information as properties
33+
_properties = new FileProperties(_formatContext);
34+
3135
// Create streams
3236
for(size_t streamIndex = 0; streamIndex < _formatContext.getNbStreams(); ++streamIndex)
3337
{
@@ -37,6 +41,7 @@ InputFile::InputFile(const std::string& filename)
3741

3842
InputFile::~InputFile()
3943
{
44+
delete _properties;
4045
for(std::vector<InputStream*>::iterator it = _inputStreams.begin(); it != _inputStreams.end(); ++it)
4146
{
4247
delete(*it);
@@ -45,7 +50,7 @@ InputFile::~InputFile()
4550

4651
void InputFile::analyse(IProgress& progress, const EAnalyseLevel level)
4752
{
48-
_properties.extractStreamProperties(progress, level);
53+
_properties->extractStreamProperties(progress, level);
4954
}
5055

5156
FileProperties InputFile::analyseFile(const std::string& filename, IProgress& progress, const EAnalyseLevel level)
@@ -160,8 +165,8 @@ std::string InputFile::getFormatMimeType() const
160165
double InputFile::getFps()
161166
{
162167
double fps = 1;
163-
if(_properties.getNbVideoStreams())
164-
fps = _properties.getVideoProperties().at(0).getFps();
168+
if(_properties->getNbVideoStreams())
169+
fps = _properties->getVideoProperties().at(0).getFps();
165170
return fps;
166171
}
167172

src/AvTranscoder/file/InputFile.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class AvExport InputFile
6868
* @note require to launch analyse() before to fill the property struture
6969
* @return structure of media metadatas
7070
**/
71-
const FileProperties& getProperties() const { return _properties; }
71+
const FileProperties& getProperties() const { return *_properties; }
7272

7373
/**
7474
* @brief Get stream type: video, audio, subtitle, etc.
@@ -121,7 +121,7 @@ class AvExport InputFile
121121

122122
protected:
123123
FormatContext _formatContext;
124-
FileProperties _properties;
124+
FileProperties* _properties;
125125
std::string _filename;
126126
std::vector<InputStream*> _inputStreams; ///< Has ownership
127127
};

0 commit comments

Comments
 (0)