Skip to content

Commit

Permalink
Nonfunctional (but compiler-friendly) kludge for video recording with…
Browse files Browse the repository at this point in the history
… ffmpeg 3.0
  • Loading branch information
SwooshyCueb committed Apr 27, 2016
1 parent a3a07d2 commit 502de18
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/common/ffmpeg.cpp
Expand Up @@ -394,13 +394,17 @@ MediaRecorder::~MediaRecorder()
Stop();
}

// Still needs updating for avcodec_encode_video2
MediaRet MediaRecorder::AddFrame(const u8 *vid)
{
if(!oc || !vid_st)
return MRET_OK;

AVCodecContext *ctx = vid_st->codec;
AVPacket pkt;
#if LIBAVCODEC_VERSION_MAJOR > 56
int ret, got_packet = 0;
#endif

// strip borders. inconsistent between depths for some reason
// but fortunately consistent between gb/gba.
Expand Down Expand Up @@ -438,7 +442,20 @@ MediaRet MediaRecorder::AddFrame(const u8 *vid)
pkt.data = f->data[0];
pkt.size = linesize * ctx->height;
} else {
#if LIBAVCODEC_VERSION_MAJOR > 56
pkt.data = video_buf;
pkt.size = VIDEO_BUF_LEN;
f->format = ctx->pix_fmt;
f->width = ctx->width;
f->height = ctx->height;
ret = avcodec_encode_video2(ctx, &pkt, f, &got_packet);
if(!ret && got_packet && ctx->coded_frame) {
ctx->coded_frame->pts = pkt.pts;
ctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
}
#else
pkt.size = avcodec_encode_video(ctx, video_buf, VIDEO_BUF_LEN, f);
#endif
if(!pkt.size)
return MRET_OK;
if(ctx->coded_frame && ctx->coded_frame->pts != AV_NOPTS_VALUE)
Expand Down

0 comments on commit 502de18

Please sign in to comment.