Skip to content

Commit bede28c

Browse files
author
Clement Champetier
committed
VideoProperties: get size from AVPacket if not available in AVFrame
1 parent 79e8bb9 commit bede28c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ size_t VideoProperties::getBitRate() const
405405

406406
if( ! _codecContext->width || ! _codecContext->height )
407407
throw std::runtime_error( "cannot compute bit rate: invalid frame size" );
408-
408+
409409
// discard no frame type when decode
410410
_codecContext->skip_frame = AVDISCARD_NONE;
411411

@@ -429,7 +429,11 @@ size_t VideoProperties::getBitRate() const
429429
avcodec_decode_video2( _codecContext, frame, &gotFrame, &pkt );
430430
if( gotFrame )
431431
{
432+
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 54, 7, 100 )
432433
gopFramesSize += frame->pkt_size;
434+
#else
435+
gopFramesSize += pkt.size;
436+
#endif
433437
++count;
434438
}
435439
}

0 commit comments

Comments
 (0)