Skip to content

Commit 9635e02

Browse files
author
Clement Champetier
committed
Merge branch 'release/v0.5.6' of https://github.com/mikrosimage/avTranscoder into develop
Conflicts: src/AvTranscoder/decoder/AudioDecoder.cpp src/AvTranscoder/decoder/VideoDecoder.cpp src/AvTranscoder/encoder/AudioEncoder.cpp src/AvTranscoder/encoder/VideoEncoder.cpp src/AvTranscoder/transcoder/StreamTranscoder.cpp
2 parents f44f3c3 + 81e811f commit 9635e02

File tree

10 files changed

+24
-11
lines changed

10 files changed

+24
-11
lines changed

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void AudioDecoder::setupDecoder( const ProfileLoader::Profile& profile )
6060
if( profile.count( constants::avProfileThreads ) )
6161
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
6262
else
63-
codec.getOption( constants::avProfileThreads ).setString( "auto" );
63+
codec.getOption( constants::avProfileThreads ).setInt( codec.getAVCodecContext().thread_count );
6464

6565
// set decoder options
6666
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void VideoDecoder::setupDecoder( const ProfileLoader::Profile& profile )
5858
if( profile.count( constants::avProfileThreads ) )
5959
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
6060
else
61-
codec.getOption( constants::avProfileThreads ).setString( "auto" );
61+
codec.getOption( constants::avProfileThreads ).setInt( codec.getAVCodecContext().thread_count );
6262

6363
// set decoder options
6464
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )

src/AvTranscoder/encoder/AudioEncoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void AudioEncoder::setupEncoder( const ProfileLoader::Profile& profile )
5252
if( profile.count( constants::avProfileThreads ) )
5353
_codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
5454
else
55-
_codec.getOption( constants::avProfileThreads ).setString( "auto" );
55+
_codec.getOption( constants::avProfileThreads ).setInt( _codec.getAVCodecContext().thread_count );
5656

5757

5858
// set encoder options

src/AvTranscoder/encoder/VideoEncoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void VideoEncoder::setupEncoder( const ProfileLoader::Profile& profile )
5353
if( profile.count( constants::avProfileThreads ) )
5454
_codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
5555
else
56-
_codec.getOption( constants::avProfileThreads ).setString( "auto" );
56+
_codec.getOption( constants::avProfileThreads ).setInt( _codec.getAVCodecContext().thread_count );
5757

5858
// set encoder options
5959
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )

src/AvTranscoder/file/InputFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ bool InputFile::readNextPacket( CodedData& data, const size_t streamIndex )
8686
void InputFile::seekAtFrame( const size_t frame )
8787
{
8888
uint64_t position = frame / getFps() * AV_TIME_BASE;
89-
_formatContext.seek( position, AVSEEK_FLAG_BACKWARD );
89+
_formatContext.seek( position, AVSEEK_FLAG_ANY );
9090
}
9191

9292
void InputFile::seekAtTime( const double time )
9393
{
9494
uint64_t position = time * AV_TIME_BASE;
95-
_formatContext.seek( position, AVSEEK_FLAG_BACKWARD );
95+
_formatContext.seek( position, AVSEEK_FLAG_ANY );
9696
}
9797

9898
void InputFile::activateStream( const size_t streamIndex, bool activate )

src/AvTranscoder/file/InputFile.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class AvExport InputFile
4848
bool readNextPacket( CodedData& data, const size_t streamIndex );
4949

5050
/**
51-
* @brief Seek input stream at specified frame
52-
* @note clean also buffers in each InputStream
53-
* @return if next packet was read succefully
51+
* @brief Seek at a specific frame / time (in seconds)
52+
* @note Seek in file by using the default stream (according to ffmpeg)
53+
* @warning If the seek is done to a non key-frame, the decoding will start from the next key-frame
5454
**/
5555
void seekAtFrame( const size_t frame );
5656
void seekAtTime( const double time );

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size
2222
, _pixelProperties()
2323
, _isInterlaced( false )
2424
, _isTopFieldFirst( false )
25+
, _firstGopTimeCode( -1 )
2526
, _gopStructure()
2627
{
2728
if( _formatContext )
@@ -39,7 +40,10 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size
3940
_codec = avcodec_find_decoder( _codecContext->codec_id );
4041

4142
if( _codecContext )
43+
{
4244
_pixelProperties = PixelProperties( _codecContext->pix_fmt );
45+
_firstGopTimeCode = _codecContext->timecode_frame_start;
46+
}
4347

4448
if( level == eAnalyseLevelFirstGop )
4549
analyseGopStructure( progress );
@@ -310,7 +314,7 @@ int64_t VideoProperties::getStartTimecode() const
310314
{
311315
if( ! _codecContext )
312316
throw std::runtime_error( "unknown codec context" );
313-
return _codecContext->timecode_frame_start;
317+
return _firstGopTimeCode;
314318
}
315319

316320
std::string VideoProperties::getStartTimecodeString() const

src/AvTranscoder/mediaProperty/VideoProperties.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ class AvExport VideoProperties : public StreamProperties
110110
bool _isTopFieldFirst;
111111
std::vector< std::pair< char, bool > > _gopStructure;
112112
//@}
113+
114+
/**
115+
* @brief GOP timecode of the first frame
116+
* @note AVCodecContext stores the GOP timecode of the last decoded frame
117+
*/
118+
int64_t _firstGopTimeCode;
113119
};
114120

115121
}

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ void StreamTranscoder::preProcessCodecLatency()
316316
{
317317
processFrame();
318318
}
319+
320+
if( getProcessCase() == eProcessCaseRewrap )
321+
_currentDecoder = NULL;
319322
}
320323

321324
bool StreamTranscoder::processFrame()

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void Transcoder::manageSwitchToGenerator()
506506
_streamTranscoders.at( i )->canSwitchToGenerator( false );
507507
break;
508508
case eProcessMethodBasedOnDuration :
509-
if( _streamTranscoders.at( i )->getDuration() > _outputDuration )
509+
if( _streamTranscoders.at( i )->getDuration() >= _outputDuration )
510510
_streamTranscoders.at( i )->canSwitchToGenerator( false );
511511
else
512512
_streamTranscoders.at( i )->canSwitchToGenerator( true );

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy