Skip to content

Commit 60f5fd7

Browse files
committed
Merge pull request #32 from cchampet/dev_closedGop
Fix GOP structure analysis (and add commented isClosedGop method needing a FFmpeg patch)
2 parents 19738bb + b5b931e commit 60f5fd7

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ VideoProperties::VideoProperties( const AVFormatContext* formatContext, const si
4848
if( _codecContext )
4949
_pixelProperties = PixelProperties( _codecContext->pix_fmt );
5050

51-
// Skip decoding for selected frames
52-
_codecContext->skip_frame = AVDISCARD_NONE;
53-
5451
if( level == eAnalyseLevelFirstGop )
5552
analyseGopStructure( progress );
5653
}
@@ -493,15 +490,24 @@ bool VideoProperties::hasBFrames() const
493490
return (bool) _codecContext->has_b_frames;
494491
}
495492

493+
// CODEC_FLAG_CLOSED_GOP is superior of INT_MAX, and _codecContext->flags is an int
494+
// => Need a patch from FFmpeg
495+
//bool VideoProperties::isClosedGop() const
496+
//{
497+
// if( ! _codecContext )
498+
// throw std::runtime_error( "unknown codec context" );
499+
// return ( _codecContext->flags & CODEC_FLAG_CLOSED_GOP ) == CODEC_FLAG_CLOSED_GOP;
500+
//}
501+
496502
void VideoProperties::analyseGopStructure( IProgress& progress )
497503
{
498504
if( _formatContext && _codecContext && _codec )
499505
{
500-
if( _codec->capabilities & CODEC_CAP_TRUNCATED )
501-
_codecContext->flags|= CODEC_FLAG_TRUNCATED;
502-
503506
if( _codecContext->width && _codecContext->height )
504507
{
508+
// Discard no frame type when decode
509+
_codecContext->skip_frame = AVDISCARD_NONE;
510+
505511
AVPacket pkt;
506512

507513
#if LIBAVCODEC_VERSION_MAJOR > 54
@@ -595,9 +601,10 @@ PropertiesMap VideoProperties::getPropertiesAsMap() const
595601
for( size_t frameIndex = 0; frameIndex < _gopStructure.size(); ++frameIndex )
596602
{
597603
gop += _gopStructure.at( frameIndex ).first;
598-
gop += ( _gopStructure.at( frameIndex ).second ? "*" : " " );
604+
gop += " ";
599605
}
600606
detail::add( dataMap, "gop", gop );
607+
//detail::add( dataMap, "isClosedGop", isClosedGop() );
601608

602609
detail::add( dataMap, "hasBFrames", hasBFrames() );
603610
detail::add( dataMap, "referencesFrames", getReferencesFrames() );

src/AvTranscoder/mediaProperty/VideoProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class AvExport VideoProperties
6262
double getDuration() const; ///< in seconds
6363

6464
bool hasBFrames() const;
65+
//bool isClosedGop() const;
6566

6667
//@{
6768
// Warning: Can acces these data when analyse first gop

0 commit comments

Comments
 (0)