Skip to content

Init to preprocessCodecLatency #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/AvTranscoder/file/OutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,10 @@ void OutputFile::setProfile( const ProfileLoader::Profile& profile )

double OutputFile::getProgressDuration()
{
AVStream* firstOutputStream = _formatContext->streams[0];
if( firstOutputStream == NULL )
if( _formatContext->nb_streams == 0 )
throw std::runtime_error( "at least one stream must be set to get the progress duration" );
double duration = av_q2d( firstOutputStream->time_base ) * firstOutputStream->cur_dts;
return duration;
AVStream* firstOutputStream = _formatContext->streams[0];
return av_q2d( firstOutputStream->time_base ) * firstOutputStream->cur_dts;
}

}
2 changes: 1 addition & 1 deletion src/AvTranscoder/transcoder/StreamTranscoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ StreamTranscoder::~StreamTranscoder()
delete _inputEssence;
}

void StreamTranscoder::init()
void StreamTranscoder::preProcessCodecLatency()
{
// rewrap case: no need to take care of the latency of codec
if( ! _inputEssence )
Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/transcoder/StreamTranscoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class AvExport StreamTranscoder
~StreamTranscoder();

/**
* @brief Init before encoding to pre-process frames necessary to delete the latency.
* @brief Pre-process codec latency.
* @note This can be called several times with no side effects.
* @note Can take a little bit of time.
*/
void init();
void preProcessCodecLatency();

/**
* @brief process a single frame for the current stream
Expand Down
9 changes: 5 additions & 4 deletions src/AvTranscoder/transcoder/Transcoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ void Transcoder::add( StreamTranscoder& stream )
_streamTranscoders.push_back( &stream );
}

void Transcoder::init()
void Transcoder::preProcessCodecLatency()
{
for( size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex )
{
if( _verbose )
std::cout << "init stream " << streamIndex << std::endl;
_streamTranscoders.at( streamIndex )->init();
_streamTranscoders.at( streamIndex )->preProcessCodecLatency();
}
}

Expand Down Expand Up @@ -285,10 +285,11 @@ void Transcoder::process( IProgress& progress )

if( _verbose )
std::cout << "begin transcoding" << std::endl;
init();


_outputFile.beginWrap();

preProcessCodecLatency();

double totalDuration = getTotalDurationFromProcessMethod();

size_t frame = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/AvTranscoder/transcoder/Transcoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ class AvExport Transcoder
void add( StreamTranscoder& streamTranscoder);

/**
* @brief Initialize all streams added, by ensure process necessary frames in case of latency.
* @brief Initialize all added streams, processing codec latency.
* @note This can be called several times with no side effects.
* @note Can take a little bit of time.
*/
void init();
void preProcessCodecLatency();

/**
* @brief Process the next frame of all streams.
Expand Down
4 changes: 2 additions & 2 deletions test/pyTest/testSetFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def testSetVideoFrame():
videoEssence = transcoder.getStreamTranscoder( 0 ).getCurrentEssence()

# start process
transcoder.init()
ouputFile.beginWrap()
transcoder.preProcessCodecLatency()

# process 255 frames
for i in range(0,255):
Expand Down Expand Up @@ -88,8 +88,8 @@ def testSetAudioFrame():
audioEssence = transcoder.getStreamTranscoder( 0 ).getCurrentEssence()

# start process
transcoder.init()
ouputFile.beginWrap()
transcoder.preProcessCodecLatency()

# process 255 frames
for i in range(0,255):
Expand Down
4 changes: 0 additions & 4 deletions test/pyTest/testTranscoderDummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def testTranscodeDummyAudio():
audioCodec.setAudioParameters( audioDesc )
transcoder.add( "", 0, "wave24b48kmono", audioCodec )

transcoder.init()

ouputFile.beginWrap()
transcoder.processFrame()
ouputFile.endWrap()
Expand All @@ -116,8 +114,6 @@ def testTranscodeDummyVideo():
videoCodec.setImageParameters( imageDesc )
transcoder.add( "", 0, "dnxhd120", videoCodec )

transcoder.init()

ouputFile.beginWrap()
transcoder.processFrame()
ouputFile.endWrap()
Expand Down