@@ -48,9 +48,6 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size
48
48
if ( _codecContext )
49
49
_pixelProperties = PixelProperties ( _codecContext->pix_fmt );
50
50
51
- // Skip decoding for selected frames
52
- _codecContext->skip_frame = AVDISCARD_NONE;
53
-
54
51
if ( level == eAnalyseLevelFirstGop )
55
52
analyseGopStructure ( progress );
56
53
}
@@ -322,14 +319,19 @@ int64_t VideoProperties::getStartTimecode() const
322
319
323
320
std::string VideoProperties::getStartTimecodeString () const
324
321
{
325
- int64_t stratTimeCode = getStartTimecode ();
322
+ int64_t startTimeCode = getStartTimecode ();
326
323
std::ostringstream os;
327
- os << std::setfill ( ' 0' );
328
- os << std::setw (2 ) << ( stratTimeCode >> 19 & 0x1f ) << " :" ; // 5-bit hours
329
- os << std::setw (2 ) << ( stratTimeCode >> 13 & 0x3f ) << " :" ; // 6-bit minutes
330
- os << std::setw (2 ) << ( stratTimeCode >> 6 & 0x3f ) ; // 6-bit seconds
331
- os << ( stratTimeCode & 1 << 24 ? ' ;' : ' :' ); // 1-bit drop flag
332
- os << std::setw (2 ) << ( stratTimeCode & 0x3f ); // 6-bit frames
324
+ if ( startTimeCode == -1 )
325
+ os << " unset" ;
326
+ else
327
+ {
328
+ os << std::setfill ( ' 0' );
329
+ os << std::setw (2 ) << ( startTimeCode >> 19 & 0x1f ) << " :" ; // 5-bit hours
330
+ os << std::setw (2 ) << ( startTimeCode >> 13 & 0x3f ) << " :" ; // 6-bit minutes
331
+ os << std::setw (2 ) << ( startTimeCode >> 6 & 0x3f ) ; // 6-bit seconds
332
+ os << ( startTimeCode & 1 << 24 ? ' ;' : ' :' ); // 1-bit drop flag
333
+ os << std::setw (2 ) << ( startTimeCode & 0x3f ); // 6-bit frames
334
+ }
333
335
return os.str ();
334
336
}
335
337
@@ -493,15 +495,24 @@ bool VideoProperties::hasBFrames() const
493
495
return (bool ) _codecContext->has_b_frames ;
494
496
}
495
497
498
+ // CODEC_FLAG_CLOSED_GOP is superior of INT_MAX, and _codecContext->flags is an int
499
+ // => Need a patch from FFmpeg
500
+ // bool VideoProperties::isClosedGop() const
501
+ // {
502
+ // if( ! _codecContext )
503
+ // throw std::runtime_error( "unknown codec context" );
504
+ // return ( _codecContext->flags & CODEC_FLAG_CLOSED_GOP ) == CODEC_FLAG_CLOSED_GOP;
505
+ // }
506
+
496
507
void VideoProperties::analyseGopStructure ( IProgress& progress )
497
508
{
498
509
if ( _formatContext && _codecContext && _codec )
499
510
{
500
- if ( _codec->capabilities & CODEC_CAP_TRUNCATED )
501
- _codecContext->flags |= CODEC_FLAG_TRUNCATED;
502
-
503
511
if ( _codecContext->width && _codecContext->height )
504
512
{
513
+ // Discard no frame type when decode
514
+ _codecContext->skip_frame = AVDISCARD_NONE;
515
+
505
516
AVPacket pkt;
506
517
507
518
#if LIBAVCODEC_VERSION_MAJOR > 54
@@ -567,7 +578,7 @@ PropertiesMap VideoProperties::getPropertiesAsMap() const
567
578
detail::add ( dataMap, " profile" , getProfile () );
568
579
detail::add ( dataMap, " profileName" , getProfileName () );
569
580
detail::add ( dataMap, " level" , getLevel () );
570
- detail::add ( dataMap, " startTimecode" , getStartTimecode () );
581
+ detail::add ( dataMap, " startTimecode" , getStartTimecodeString () );
571
582
detail::add ( dataMap, " width" , getWidth () );
572
583
detail::add ( dataMap, " height" , getHeight () );
573
584
detail::add ( dataMap, " pixelAspectRatio" , getSar ().num / getSar ().den );
@@ -595,9 +606,10 @@ PropertiesMap VideoProperties::getPropertiesAsMap() const
595
606
for ( size_t frameIndex = 0 ; frameIndex < _gopStructure.size (); ++frameIndex )
596
607
{
597
608
gop += _gopStructure.at ( frameIndex ).first ;
598
- gop += ( _gopStructure. at ( frameIndex ). second ? " * " : " " ) ;
609
+ gop += " " ;
599
610
}
600
611
detail::add ( dataMap, " gop" , gop );
612
+ // detail::add( dataMap, "isClosedGop", isClosedGop() );
601
613
602
614
detail::add ( dataMap, " hasBFrames" , hasBFrames () );
603
615
detail::add ( dataMap, " referencesFrames" , getReferencesFrames () );
0 commit comments