AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
avtranscoder::InputFile Class Reference

#include <InputFile.hpp>

Public Member Functions

 InputFile (const std::string &filename)
 Open a media file. More...
 
virtual ~InputFile ()
 
void analyse (IProgress &progress, const EAnalyseLevel level=eAnalyseLevelFirstGop)
 Run the analyse on the file after a setup. call this function before getProperties(). More...
 
bool readNextPacket (CodedData &data, const size_t streamIndex)
 Read the next packet of the specified stream. More...
 
bool seekAtFrame (const size_t frame, const int flag=AVSEEK_FLAG_ANY)
 Seek at a specific frame / time (in seconds) More...
 
bool seekAtTime (const double time, const int flag=AVSEEK_FLAG_ANY)
 
void activateStream (const size_t streamIndex, const bool activate=true)
 Activate the indicated stream. More...
 
const FilePropertiesgetProperties () const
 Return media properties on the current InputFile. More...
 
InputStreamgetStream (size_t index)
 Get stream type: video, audio, subtitle, etc. More...
 
std::string getFilename () const
 
FormatContextgetFormatContext ()
 
virtual void setupUnwrapping (const ProfileLoader::Profile &profile)
 Set the format of the input file. More...
 

Static Public Member Functions

static FileProperties analyseFile (const std::string &filename, IProgress &progress, const EAnalyseLevel level=eAnalyseLevelFirstGop)
 Get media file properties using static method. More...
 

Protected Attributes

FormatContext _formatContext
 
FileProperties_properties
 
std::string _filename
 
std::vector< InputStream * > _inputStreams
 Has ownership. More...
 

Private Member Functions

 InputFile (const InputFile &inputFile)
 
InputFileoperator= (const InputFile &inputFile)
 
double getFps ()
 Get Fps from first video stream. More...
 

Detailed Description

Definition at line 18 of file InputFile.hpp.

Constructor & Destructor Documentation

avtranscoder::InputFile::InputFile ( const InputFile inputFile)
private
avtranscoder::InputFile::InputFile ( const std::string &  filename)

Open a media file.

Note
The constructor also analyses header of input file
Parameters
filenameresource to access
Exceptions
ios_base::failurelaunched if unable to open file

Definition at line 23 of file InputFile.cpp.

References _formatContext, _inputStreams, _properties, avtranscoder::FormatContext::findStreamInfo(), and avtranscoder::FormatContext::getNbStreams().

avtranscoder::InputFile::~InputFile ( )
virtual

Definition at line 42 of file InputFile.cpp.

References _inputStreams, and _properties.

Member Function Documentation

void avtranscoder::InputFile::activateStream ( const size_t  streamIndex,
const bool  activate = true 
)

Activate the indicated stream.

Note
Activate a stream results in buffered its data when processing

Definition at line 108 of file InputFile.cpp.

References avtranscoder::InputStream::activate(), and getStream().

Referenced by avtranscoder::Transcoder::addInputFile(), avtranscoder::AudioReader::init(), and avtranscoder::VideoReader::init().

void avtranscoder::InputFile::analyse ( IProgress progress,
const EAnalyseLevel  level = eAnalyseLevelFirstGop 
)

Run the analyse on the file after a setup. call this function before getProperties().

Parameters
progresscallback to get analysis progression
levelby default eAnalyseLevelFirstGop

Definition at line 51 of file InputFile.cpp.

References _properties, and avtranscoder::FileProperties::extractStreamProperties().

Referenced by analyseFile(), avtranscoder::AudioReader::init(), avtranscoder::VideoReader::init(), and main().

FileProperties avtranscoder::InputFile::analyseFile ( const std::string &  filename,
IProgress progress,
const EAnalyseLevel  level = eAnalyseLevelFirstGop 
)
static

Get media file properties using static method.

Parameters
filenameinput filename
progresscallback to get analysis progression
Returns
structure of media metadatas

Definition at line 56 of file InputFile.cpp.

References analyse(), and getProperties().

std::string avtranscoder::InputFile::getFilename ( ) const
inline

Definition at line 80 of file InputFile.hpp.

Referenced by getStream(), and avtranscoder::InputStream::readNextPacket().

FormatContext& avtranscoder::InputFile::getFormatContext ( )
inline

Definition at line 82 of file InputFile.hpp.

Referenced by avtranscoder::InputStream::InputStream().

double avtranscoder::InputFile::getFps ( )
private

Get Fps from first video stream.

Note
if there is no video stream, return 1.

Definition at line 129 of file InputFile.cpp.

References _properties, avtranscoder::FileProperties::getNbVideoStreams(), and avtranscoder::FileProperties::getVideoProperties().

Referenced by seekAtFrame().

const FileProperties& avtranscoder::InputFile::getProperties ( ) const
inline

Return media properties on the current InputFile.

Note
require to launch analyse() before to fill the property struture
Returns
structure of media metadatas

Definition at line 71 of file InputFile.hpp.

Referenced by avtranscoder::Transcoder::add(), avtranscoder::Transcoder::addInputFile(), analyseFile(), avtranscoder::Transcoder::getProfileFromFile(), avtranscoder::InputStream::getProperties(), avtranscoder::AudioReader::init(), avtranscoder::VideoReader::init(), main(), and avtranscoder::operator<<().

InputStream & avtranscoder::InputFile::getStream ( size_t  index)

Get stream type: video, audio, subtitle, etc.

Parameters
indexstream index
Returns
media stream type of specified index stream

Definition at line 113 of file InputFile.cpp.

References _inputStreams, and getFilename().

Referenced by activateStream(), avtranscoder::Transcoder::addRewrapStream(), avtranscoder::Transcoder::getProfileFromFile(), avtranscoder::AudioReader::init(), and avtranscoder::VideoReader::init().

InputFile& avtranscoder::InputFile::operator= ( const InputFile inputFile)
private
bool avtranscoder::InputFile::readNextPacket ( CodedData data,
const size_t  streamIndex 
)
bool avtranscoder::InputFile::seekAtFrame ( const size_t  frame,
const int  flag = AVSEEK_FLAG_ANY 
)

Seek at a specific frame / time (in seconds)

Note
Seek in file by using the default stream (according to ffmpeg)
Parameters
flagffmpeg seek flag (by default seek to any frame, even non-keyframes)
Warning
If the seek is done to a non key-frame, the decoding will start from the next key-frame
Returns
seek status

Definition at line 96 of file InputFile.cpp.

References _formatContext, getFps(), and avtranscoder::FormatContext::seek().

Referenced by avtranscoder::IReader::readFrameAt().

bool avtranscoder::InputFile::seekAtTime ( const double  time,
const int  flag = AVSEEK_FLAG_ANY 
)
void avtranscoder::InputFile::setupUnwrapping ( const ProfileLoader::Profile profile)
virtual

Field Documentation

std::string avtranscoder::InputFile::_filename
protected

Definition at line 110 of file InputFile.hpp.

Referenced by readNextPacket().

FormatContext avtranscoder::InputFile::_formatContext
protected

Definition at line 108 of file InputFile.hpp.

Referenced by InputFile(), readNextPacket(), seekAtFrame(), seekAtTime(), and setupUnwrapping().

std::vector<InputStream*> avtranscoder::InputFile::_inputStreams
protected

Has ownership.

Definition at line 111 of file InputFile.hpp.

Referenced by getStream(), InputFile(), readNextPacket(), and ~InputFile().

FileProperties* avtranscoder::InputFile::_properties
protected

Definition at line 109 of file InputFile.hpp.

Referenced by analyse(), getFps(), InputFile(), and ~InputFile().


The documentation for this class was generated from the following files: