Skip to content

Commit aa9bba3

Browse files
author
Clement Champetier
committed
VideoProperties: fix seg fault when analysing the first GOP
The AVFrame should be allocated.
1 parent d86ccf3 commit aa9bba3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <AvTranscoder/properties/util.hpp>
44
#include <AvTranscoder/properties/FileProperties.hpp>
55
#include <AvTranscoder/progress/NoDisplayProgress.hpp>
6+
#include <AvTranscoder/data/decoded/VideoFrame.hpp>
67

78
extern "C" {
89
#include <libavutil/avutil.h>
@@ -341,11 +342,14 @@ size_t VideoProperties::getBitRate() const
341342
// discard no frame type when decode
342343
_codecContext->skip_frame = AVDISCARD_NONE;
343344

344-
AVFrame avFrame;
345345
AVPacket pkt;
346346
av_init_packet(&pkt);
347+
347348
avcodec_open2(_codecContext, _codec, NULL);
348349

350+
VideoFrame frame(VideoFrameDesc(getWidth(), getHeight(), getPixelProperties().getAVPixelFormat()), false);
351+
AVFrame& avFrame = frame.getAVFrame();
352+
349353
int gotFrame = 0;
350354
size_t nbDecodedFrames = 0;
351355
int gopFramesSize = 0;
@@ -565,7 +569,9 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
565569
// Initialize the AVCodecContext to use the given AVCodec
566570
avcodec_open2(_codecContext, _codec, NULL);
567571

568-
AVFrame avFrame;
572+
VideoFrame frame(VideoFrameDesc(getWidth(), getHeight(), getPixelProperties().getAVPixelFormat()), false);
573+
AVFrame& avFrame = frame.getAVFrame();
574+
569575
size_t count = 0;
570576
int gotFrame = 0;
571577
int positionOfFirstKeyFrame = -1;

0 commit comments

Comments
 (0)