AvTranscoder
0.9.4
C++APIforLibav/FFmpeg
|
A Transcoder manages a list of streams, and process a transcode to create an output media file. More...
#include <Transcoder.hpp>
Public Member Functions | |
Transcoder (IOutputFile &outputFile) | |
~Transcoder () | |
void | add (const std::string &filename) |
Add all streams of the file with the given filename. All the streams will be rewrapped. More... | |
void | add (const std::string &filename, const size_t streamIndex, const std::string &profileName="", const float offset=0) |
Add a stream and set a profile. More... | |
void | add (const std::string &filename, const size_t streamIndex, const std::string &profileName, ICodec &codec, const float offset=0) |
void | add (const std::string &filename, const size_t streamIndex, const ProfileLoader::Profile &profile, const float offset=0) |
Add a stream and set a custom profile. More... | |
void | add (const std::string &filename, const size_t streamIndex, const ProfileLoader::Profile &profile, ICodec &codec, const float offset=0) |
void | add (const std::string &filename, const size_t streamIndex, const int subStreamIndex, const std::string &profileName="", const float offset=0) |
Add a stream and set a profile. More... | |
void | add (const std::string &filename, const size_t streamIndex, const int subStreamIndex, const std::string &profileName, ICodec &codec, const float offset=0) |
void | add (const std::string &filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile &profile, const float offset=0) |
Add a stream and set a custom profile. More... | |
void | add (const std::string &filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile &profile, ICodec &codec, const float offset=0) |
void | add (StreamTranscoder &streamTranscoder) |
Add the stream. More... | |
void | preProcessCodecLatency () |
Initialize all added streams, processing codec latency. More... | |
bool | processFrame () |
Process the next frame of all streams. More... | |
ProcessStat | process (IProgress &progress) |
Process all the streams, and ended the process depending on the transcode politic. More... | |
ProcessStat | process () |
Call process with no display of progression. More... | |
std::vector< StreamTranscoder * > & | getStreamTranscoders () |
Return the list of streams added to the transcoder. More... | |
StreamTranscoder & | getStreamTranscoder (size_t streamIndex) const |
EProcessMethod | getProcessMethod () const |
Get current processMethod. More... | |
void | setProcessMethod (const EProcessMethod eProcessMethod, const size_t indexBasedStream=0, const double outputDuration=0) |
Set the transcoding policy. More... | |
Private Member Functions | |
Transcoder (const Transcoder &transcoder) | |
Transcoder & | operator= (const Transcoder &transcoder) |
void | addRewrapStream (const std::string &filename, const size_t streamIndex, const float offset) |
void | addTranscodeStream (const std::string &filename, const size_t streamIndex, const int subStreamIndex, const float offset) |
void | addTranscodeStream (const std::string &filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile &profile, const float offset=0) |
void | addDummyStream (const ProfileLoader::Profile &profile, const ICodec &codec) |
InputFile * | addInputFile (const std::string &filename, const int streamIndex, const float offset) |
ProfileLoader::Profile | getProfileFromFile (InputFile &inputFile, const size_t streamIndex) |
The function analyses the inputFile. More... | |
float | getStreamDuration (size_t indexStream) const |
Get the duration of the stream, in seconds. More... | |
float | getMinTotalDuration () const |
Get the duration of the shortest stream, in seconds. More... | |
float | getMaxTotalDuration () const |
Get the duration of the longest stream, in seconds. More... | |
float | getExpectedOutputDuration () const |
Get the expected duration of the output program. More... | |
float | getCurrentOutputDuration () const |
Get the current duration of the output program. More... | |
void | manageSwitchToGenerator () |
Set for each StreamTranscoder if it can switch to generator at the end. More... | |
void | fillProcessStat (ProcessStat &processStat) |
Fill the given ProcessStat to summarize the process. More... | |
Private Attributes | |
IOutputFile & | _outputFile |
The output media file after process (has link) More... | |
std::vector< InputFile * > | _inputFiles |
The list of input files which contain added streams (has ownership) More... | |
std::vector< StreamTranscoder * > | _streamTranscoders |
All streams of the output media file after process. More... | |
std::vector< StreamTranscoder * > | _streamTranscodersAllocated |
Streams allocated inside the Transcoder (has ownership) More... | |
ProfileLoader | _profileLoader |
Objet to get existing profiles, and add new ones for the Transcoder. More... | |
EProcessMethod | _eProcessMethod |
Processing policy. More... | |
size_t | _mainStreamIndex |
Index of stream used to stop the process of transcode in case of eProcessMethodBasedOnStream. More... | |
float | _outputDuration |
A Transcoder manages a list of streams, and process a transcode to create an output media file.
Definition at line 42 of file Transcoder.hpp.
|
private |
avtranscoder::Transcoder::Transcoder | ( | IOutputFile & | outputFile | ) |
Definition at line 13 of file Transcoder.cpp.
avtranscoder::Transcoder::~Transcoder | ( | ) |
Definition at line 25 of file Transcoder.cpp.
References _inputFiles, and _streamTranscodersAllocated.
void avtranscoder::Transcoder::add | ( | const std::string & | filename | ) |
Add all streams of the file with the given filename. All the streams will be rewrapped.
Definition at line 38 of file Transcoder.cpp.
References addInputFile(), addRewrapStream(), avtranscoder::InputFile::getProperties(), avtranscoder::FileProperties::getStreamProperties(), avtranscoder::FileProperties::getStreamPropertiesWithIndex(), and avtranscoder::StreamProperties::getStreamType().
Referenced by add(), and parseConfigFile().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const std::string & | profileName = "" , |
||
const float | offset = 0 |
||
) |
Add a stream and set a profile.
Definition at line 53 of file Transcoder.cpp.
References _profileLoader, add(), addRewrapStream(), and avtranscoder::ProfileLoader::getProfile().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const std::string & | profileName, | ||
ICodec & | codec, | ||
const float | offset = 0 |
||
) |
Definition at line 73 of file Transcoder.cpp.
References _profileLoader, add(), addRewrapStream(), and avtranscoder::ProfileLoader::getProfile().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const ProfileLoader::Profile & | profile, | ||
const float | offset = 0 |
||
) |
Add a stream and set a custom profile.
Definition at line 93 of file Transcoder.cpp.
References addTranscodeStream().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const ProfileLoader::Profile & | profile, | ||
ICodec & | codec, | ||
const float | offset = 0 |
||
) |
Definition at line 103 of file Transcoder.cpp.
References addDummyStream(), and addTranscodeStream().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const int | subStreamIndex, | ||
const std::string & | profileName = "" , |
||
const float | offset = 0 |
||
) |
Add a stream and set a profile.
Definition at line 118 of file Transcoder.cpp.
References _profileLoader, add(), addRewrapStream(), addTranscodeStream(), and avtranscoder::ProfileLoader::getProfile().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const int | subStreamIndex, | ||
const std::string & | profileName, | ||
ICodec & | codec, | ||
const float | offset = 0 |
||
) |
Definition at line 149 of file Transcoder.cpp.
References _profileLoader, add(), addRewrapStream(), addTranscodeStream(), and avtranscoder::ProfileLoader::getProfile().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const int | subStreamIndex, | ||
const ProfileLoader::Profile & | profile, | ||
const float | offset = 0 |
||
) |
Add a stream and set a custom profile.
Definition at line 181 of file Transcoder.cpp.
References add(), and addTranscodeStream().
void avtranscoder::Transcoder::add | ( | const std::string & | filename, |
const size_t | streamIndex, | ||
const int | subStreamIndex, | ||
const ProfileLoader::Profile & | profile, | ||
ICodec & | codec, | ||
const float | offset = 0 |
||
) |
Definition at line 198 of file Transcoder.cpp.
References add(), addDummyStream(), and addTranscodeStream().
void avtranscoder::Transcoder::add | ( | StreamTranscoder & | streamTranscoder | ) |
|
private |
Definition at line 393 of file Transcoder.cpp.
References _outputFile, _profileLoader, _streamTranscoders, _streamTranscodersAllocated, avtranscoder::constants::avProfileIdentificatorHuman, avtranscoder::ICodec::getCodecName(), avtranscoder::ProfileLoader::hasProfile(), avtranscoder::ProfileLoader::loadProfile(), and LOG_INFO.
Referenced by add().
|
private |
Definition at line 406 of file Transcoder.cpp.
References _inputFiles, avtranscoder::InputFile::activateStream(), avtranscoder::FileProperties::getNbStreams(), avtranscoder::InputFile::getProperties(), LOG_DEBUG, and avtranscoder::InputFile::seekAtTime().
Referenced by add(), addRewrapStream(), and addTranscodeStream().
|
private |
Definition at line 334 of file Transcoder.cpp.
References _outputFile, _streamTranscoders, _streamTranscodersAllocated, addInputFile(), avtranscoder::InputFile::getStream(), and LOG_INFO.
Referenced by add().
|
private |
Definition at line 344 of file Transcoder.cpp.
References avtranscoder::constants::avProfileChannel, and getProfileFromFile().
Referenced by add().
|
private |
Definition at line 359 of file Transcoder.cpp.
References _outputFile, _profileLoader, _streamTranscoders, _streamTranscodersAllocated, addInputFile(), avtranscoder::constants::avProfileIdentificatorHuman, avtranscoder::ProfileLoader::hasProfile(), avtranscoder::ProfileLoader::loadProfile(), and LOG_INFO.
|
private |
Fill the given ProcessStat to summarize the process.
Definition at line 597 of file Transcoder.cpp.
References _streamTranscoders, avtranscoder::ProcessStat::addAudioStat(), avtranscoder::ProcessStat::addVideoStat(), avtranscoder::IOutputStream::getNbFrames(), avtranscoder::IInputStream::getProperties(), avtranscoder::IOutputStream::getStreamDuration(), avtranscoder::StreamProperties::getStreamType(), and LOG_WARN.
Referenced by process().
|
private |
Get the current duration of the output program.
Definition at line 545 of file Transcoder.cpp.
References _outputFile, _streamTranscoders, avtranscoder::IOutputFile::getStream(), and avtranscoder::IOutputStream::getStreamDuration().
Referenced by process().
|
private |
Get the expected duration of the output program.
Definition at line 526 of file Transcoder.cpp.
References _eProcessMethod, _mainStreamIndex, _outputDuration, avtranscoder::eProcessMethodBasedOnDuration, avtranscoder::eProcessMethodBasedOnStream, avtranscoder::eProcessMethodInfinity, avtranscoder::eProcessMethodLongest, avtranscoder::eProcessMethodShortest, getMaxTotalDuration(), getMinTotalDuration(), and getStreamDuration().
Referenced by process().
|
private |
Get the duration of the longest stream, in seconds.
Definition at line 516 of file Transcoder.cpp.
References _streamTranscoders, and getStreamDuration().
Referenced by getExpectedOutputDuration(), and manageSwitchToGenerator().
|
private |
Get the duration of the shortest stream, in seconds.
Definition at line 506 of file Transcoder.cpp.
References _streamTranscoders, and getStreamDuration().
Referenced by getExpectedOutputDuration(), and manageSwitchToGenerator().
|
inline |
|
private |
The function analyses the inputFile.
Definition at line 446 of file Transcoder.cpp.
References avtranscoder::constants::avProfileChannel, avtranscoder::constants::avProfileCodec, avtranscoder::constants::avProfileFrameRate, avtranscoder::constants::avProfileHeight, avtranscoder::constants::avProfileIdentificator, avtranscoder::constants::avProfileIdentificatorHuman, avtranscoder::constants::avProfilePixelFormat, avtranscoder::constants::avProfileSampleFormat, avtranscoder::constants::avProfileSampleRate, avtranscoder::constants::avProfileType, avtranscoder::constants::avProfileTypeAudio, avtranscoder::constants::avProfileTypeVideo, avtranscoder::constants::avProfileWidth, avtranscoder::StreamProperties::getCodecName(), avtranscoder::VideoProperties::getFps(), avtranscoder::VideoProperties::getHeight(), avtranscoder::AudioProperties::getNbChannels(), avtranscoder::PixelProperties::getPixelFormatName(), avtranscoder::VideoProperties::getPixelProperties(), avtranscoder::InputStream::getProperties(), avtranscoder::InputFile::getProperties(), avtranscoder::AudioProperties::getSampleFormatName(), avtranscoder::AudioProperties::getSampleRate(), avtranscoder::InputFile::getStream(), avtranscoder::FileProperties::getStreamPropertiesWithIndex(), avtranscoder::StreamProperties::getStreamType(), and avtranscoder::VideoProperties::getWidth().
Referenced by addTranscodeStream().
|
private |
Get the duration of the stream, in seconds.
Definition at line 501 of file Transcoder.cpp.
References _streamTranscoders.
Referenced by getExpectedOutputDuration(), getMaxTotalDuration(), and getMinTotalDuration().
|
inline |
streamIndex | careful about the order of stream insertion of the Transcoder. |
Definition at line 156 of file Transcoder.hpp.
|
inline |
Return the list of streams added to the transcoder.
Definition at line 150 of file Transcoder.hpp.
|
private |
Set for each StreamTranscoder if it can switch to generator at the end.
Definition at line 559 of file Transcoder.cpp.
References _eProcessMethod, _mainStreamIndex, _outputDuration, _streamTranscoders, avtranscoder::eProcessMethodBasedOnDuration, avtranscoder::eProcessMethodBasedOnStream, avtranscoder::eProcessMethodInfinity, avtranscoder::eProcessMethodLongest, avtranscoder::eProcessMethodShortest, getMaxTotalDuration(), and getMinTotalDuration().
Referenced by process().
|
private |
void avtranscoder::Transcoder::preProcessCodecLatency | ( | ) |
Initialize all added streams, processing codec latency.
Definition at line 223 of file Transcoder.cpp.
References _streamTranscoders, and LOG_DEBUG.
Referenced by process().
ProcessStat avtranscoder::Transcoder::process | ( | IProgress & | progress | ) |
Process all the streams, and ended the process depending on the transcode politic.
progress | choose a progress, or create your own in C++ or in bindings by inherit IProgress class. |
Definition at line 272 of file Transcoder.cpp.
References _outputFile, _streamTranscoders, avtranscoder::IOutputFile::beginWrap(), avtranscoder::eJobStatusCancel, avtranscoder::IOutputFile::endWrap(), fillProcessStat(), getCurrentOutputDuration(), getExpectedOutputDuration(), LOG_DEBUG, LOG_INFO, manageSwitchToGenerator(), preProcessCodecLatency(), processFrame(), and avtranscoder::IProgress::progress().
Referenced by main().
ProcessStat avtranscoder::Transcoder::process | ( | ) |
Call process with no display of progression.
Definition at line 266 of file Transcoder.cpp.
bool avtranscoder::Transcoder::processFrame | ( | ) |
Process the next frame of all streams.
Definition at line 232 of file Transcoder.cpp.
References _streamTranscoders, avtranscoder::StreamTranscoder::eProcessCaseGenerator, LOG_DEBUG, LOG_INFO, and LOG_WARN.
Referenced by process().
void avtranscoder::Transcoder::setProcessMethod | ( | const EProcessMethod | eProcessMethod, |
const size_t | indexBasedStream = 0 , |
||
const double | outputDuration = 0 |
||
) |
Set the transcoding policy.
indexBasedStream | in case of process method eProcessMethodBasedOnStream, stop transcode at the end of the indicated stream. |
outputDuration | in case of process method eProcessMethodBasedOnDuration, stop transcode at the end of the indicated duration. |
Definition at line 326 of file Transcoder.cpp.
References _eProcessMethod, _mainStreamIndex, and _outputDuration.
Referenced by main().
|
private |
Processing policy.
Definition at line 241 of file Transcoder.hpp.
Referenced by getExpectedOutputDuration(), manageSwitchToGenerator(), and setProcessMethod().
|
private |
The list of input files which contain added streams (has ownership)
Definition at line 234 of file Transcoder.hpp.
Referenced by addInputFile(), and ~Transcoder().
|
private |
Index of stream used to stop the process of transcode in case of eProcessMethodBasedOnStream.
Definition at line 243 of file Transcoder.hpp.
Referenced by getExpectedOutputDuration(), manageSwitchToGenerator(), and setProcessMethod().
|
private |
Duration of output media used to stop the process of transcode in case of
Definition at line 244 of file Transcoder.hpp.
Referenced by getExpectedOutputDuration(), manageSwitchToGenerator(), and setProcessMethod().
|
private |
The output media file after process (has link)
Definition at line 233 of file Transcoder.hpp.
Referenced by addDummyStream(), addRewrapStream(), addTranscodeStream(), getCurrentOutputDuration(), and process().
|
private |
Objet to get existing profiles, and add new ones for the Transcoder.
Definition at line 239 of file Transcoder.hpp.
Referenced by add(), addDummyStream(), and addTranscodeStream().
|
private |
All streams of the output media file after process.
Definition at line 236 of file Transcoder.hpp.
Referenced by add(), addDummyStream(), addRewrapStream(), addTranscodeStream(), fillProcessStat(), getCurrentOutputDuration(), getMaxTotalDuration(), getMinTotalDuration(), getStreamDuration(), manageSwitchToGenerator(), preProcessCodecLatency(), process(), and processFrame().
|
private |
Streams allocated inside the Transcoder (has ownership)
Definition at line 237 of file Transcoder.hpp.
Referenced by addDummyStream(), addRewrapStream(), addTranscodeStream(), and ~Transcoder().