summaryrefslogtreecommitdiff
path: root/rotord/libavexporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/libavexporter.cpp')
-rw-r--r--rotord/libavexporter.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/rotord/libavexporter.cpp b/rotord/libavexporter.cpp
index ed69cec..41238e7 100644
--- a/rotord/libavexporter.cpp
+++ b/rotord/libavexporter.cpp
@@ -111,6 +111,33 @@ bool libav::Exporter::encodeFrame(unsigned char *pixels,uint16_t *samples){
return true;
}
+bool libav::Exporter::encodeFrame(unsigned char *pixels,AVPacket *audio){
+ // Compute current audio and video time. //
+ if (audio_st)
+ audio_pts = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
+ else
+ audio_pts = 0.0;
+
+ if (video_st)
+ video_pts = (double)video_st->pts.val * video_st->time_base.num /
+ video_st->time_base.den;
+ else
+ video_pts = 0.0;
+
+ // write interleaved audio and video frames //
+ if (!video_st || (video_st && audio_st && audio_pts < video_pts)) {
+ write_audio_frame(oc, audio_st, audio);
+ } else {
+ write_video_frame(oc, video_st, pixels);
+
+ frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
+ }
+
+ //std::cerr << "encoded frame " << outputframe << std::endl;
+ outputframe++;
+
+ return true;
+}
void libav::Exporter::finishRecord(){
av_write_trailer(oc);
@@ -126,4 +153,4 @@ void libav::Exporter::finishRecord(){
// free the stream //
avformat_free_context(oc);
-} \ No newline at end of file
+}