diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-04-30 15:31:00 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-04-30 15:31:00 +0100 |
| commit | 836848622f85231c3ff6b9af49704fec4c035df4 (patch) | |
| tree | f36cd2e9bd98e2712807c1a5f1be311b5733f6aa /rotord/libavexporter.cpp | |
| parent | caf495afbda7c12da090a9fc7b08c4e7d44420ff (diff) | |
first synced render
Diffstat (limited to 'rotord/libavexporter.cpp')
| -rw-r--r-- | rotord/libavexporter.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/rotord/libavexporter.cpp b/rotord/libavexporter.cpp index 41238e7..d9faa5b 100644 --- a/rotord/libavexporter.cpp +++ b/rotord/libavexporter.cpp @@ -54,11 +54,14 @@ bool libav::Exporter::record(std::string filename){ // * video codecs and allocate the necessary encode buffers. // if (video_st) open_video(oc, video_codec, video_st); - if (audio_st) - size=open_audio(oc, audio_codec, audio_st); - - std::cerr << "opened audio codec with "<<size<<" frame size"<<std::endl; + if (audio_st) { + audioframesize=open_audio(oc, audio_codec, audio_st); + audiostep=((float)audio_st->r_frame_rate.den)/audio_st->r_frame_rate.num; + audiostep=((float)audioframesize)/44100.0f; //where to get the framesize from????? + std::cerr << "opened audio codec with "<<audioframesize<<" frame size and "<<audiostep<<" seconds per frame"<<std::endl; + } + av_dump_format(oc, 0, filename.c_str(), 1); // open the output file, if needed // @@ -138,6 +141,18 @@ bool libav::Exporter::encodeFrame(unsigned char *pixels,AVPacket *audio){ return true; } +bool libav::Exporter::encodeFrame(unsigned char *pixels){ + video_pts = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den; + write_video_frame(oc, video_st, pixels); + frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base); + outputframe++; + return true; +} +bool libav::Exporter::encodeFrame(uint16_t *samples){ + audio_pts = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den; + write_audio_frame(oc, audio_st, samples); + return true; +} void libav::Exporter::finishRecord(){ av_write_trailer(oc); |
