diff options
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/graph.cpp | 5 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 8 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.h | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 2968c1f..8881a5f 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -116,6 +116,7 @@ bool Graph::video_render(const string &output_filename,const float framerate,int libav::exporter exporter; float spct=100.0f/duration; + Image* i; if (exporter.setup(outW,outH,bitRate,framerate,container,use_fragmentation)) { //codecId, if (exporter.record(output_filename)) { @@ -202,7 +203,7 @@ bool Graph::video_render(const string &output_filename,const float framerate,int //cerr<<"videoloader: "<<vf<<" seconds, vstep "<<vstep<<" ,asking for frame "<<((int)((vf*framerate)+0.5))<<endl - Image* i; + if (usingaudio) { i=video_output->get_image_output(Frame_spec(vf,framerate,duration,outW,outH,a)); } @@ -217,6 +218,8 @@ bool Graph::video_render(const string &output_filename,const float framerate,int if (usingaudio) {delete a;}; } + exporter.encodeFrame(i->RGBdata,true); //final keyframe; + exporter.finishRecord(); gettimeofday(&_end, NULL); 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) { diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h index 275425d..6391af9 100644 --- a/rotord/src/libavwrapper.h +++ b/rotord/src/libavwrapper.h @@ -175,7 +175,7 @@ namespace libav { bool record(std::string filename); bool encodeFrame(unsigned char *pixels, uint16_t *samples); bool encodeFrame(unsigned char *pixels,AVPacket *audiopkt); //is possible to just copy the packets? - bool encodeFrame(unsigned char *pixels); + bool encodeFrame(unsigned char *pixels,bool keyframe=false); bool encodeFrame(uint16_t *samples); void finishRecord(); int get_audio_framesize(){return audioframesize;}; @@ -189,7 +189,7 @@ namespace libav { void write_audio_frame(AVFormatContext *oc, AVStream *st,AVPacket *pkt); void close_audio(AVFormatContext *oc, AVStream *st); - void write_video_frame(AVFormatContext *oc, AVStream *st, uint8_t *pixels); + void write_video_frame(AVFormatContext *oc, AVStream *st, uint8_t *pixels, bool keyframe=false); void close_video(AVFormatContext *oc, AVStream *st); private: |
