summaryrefslogtreecommitdiff
path: root/rotord/src/libavwrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/libavwrapper.cpp')
-rw-r--r--rotord/src/libavwrapper.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp
index ae770c4..fa09b7f 100644
--- a/rotord/src/libavwrapper.cpp
+++ b/rotord/src/libavwrapper.cpp
@@ -296,9 +296,9 @@ bool libav::exporter::encodeFrame(unsigned char *pixels,AVPacket *audio){
return true;
}
-bool libav::exporter::encodeFrame(unsigned char *pixels){
+bool libav::exporter::encodeFrame(unsigned char *pixels,bool keyframe=false){
video_pts = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;
- write_video_frame(oc, video_st, pixels);
+ write_video_frame(oc, video_st, pixels,keyframe);
frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
outputframe++;
return true;
@@ -581,7 +581,7 @@ bool libav::exporter::open_video(AVFormatContext *oc, AVCodec *codec, AVStream *
}
- void libav::exporter::write_video_frame(AVFormatContext *oc, AVStream *st, uint8_t *pixels)
+ void libav::exporter::write_video_frame(AVFormatContext *oc, AVStream *st, uint8_t *pixels, bool keyframe=false)
{
int ret;
@@ -607,6 +607,8 @@ bool libav::exporter::open_video(AVFormatContext *oc, AVCodec *codec, AVStream *
} else {
AVPacket pkt = { 0 };
int got_packet;
+
+ if (keyframe) pkt.flags |= AV_PKT_FLAG_KEY;
ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
if (ret < 0) {