diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-04-23 14:01:06 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-04-23 14:01:06 +0100 |
| commit | 1e26d66c3a7be31a9dd214b587488dfe3ed69b4b (patch) | |
| tree | 036dbb6a151a6388fbfd4554cecf3469d97520f8 /rotord/libavexporter.cpp | |
| parent | 4b3aad507aaf75263f5b8c719768b24ba688c31e (diff) | |
writing audio but sped up for some reason
Diffstat (limited to 'rotord/libavexporter.cpp')
| -rw-r--r-- | rotord/libavexporter.cpp | 29 |
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 +} |
