summaryrefslogtreecommitdiff
path: root/rotord/libavexporter.cpp
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-04-22 19:21:42 +0100
committerComment <tim@gray.(none)>2013-04-22 19:21:42 +0100
commit4b3aad507aaf75263f5b8c719768b24ba688c31e (patch)
tree602d4d2dc89d3e39c5b76d112452e0249d3ab7f5 /rotord/libavexporter.cpp
parentb05e391e126f2bba2a4bd2915786d93731d2dbc9 (diff)
audio output corruption
Diffstat (limited to 'rotord/libavexporter.cpp')
-rw-r--r--rotord/libavexporter.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/rotord/libavexporter.cpp b/rotord/libavexporter.cpp
index 3e977a1..ed69cec 100644
--- a/rotord/libavexporter.cpp
+++ b/rotord/libavexporter.cpp
@@ -1,6 +1,7 @@
#include "libavexporter.h"
-bool libav::exporter::setup(int w,int h, int bitRate, int frameRate, std::string container){
+
+bool libav::Exporter::setup(int w,int h, int bitRate, int frameRate, std::string container){
// Initialize libavcodec, and register all codecs and formats. //
av_register_all();
@@ -13,7 +14,7 @@ bool libav::exporter::setup(int w,int h, int bitRate, int frameRate, std::string
return true;
}
-bool libav::exporter::record(std::string filename){
+bool libav::Exporter::record(std::string filename){
// allocate the output media context //
avformat_alloc_output_context2(&oc, NULL, NULL, filename.c_str());
@@ -54,7 +55,9 @@ bool libav::exporter::record(std::string filename){
if (video_st)
open_video(oc, video_codec, video_st);
if (audio_st)
- open_audio(oc, audio_codec, audio_st);
+ size=open_audio(oc, audio_codec, audio_st);
+
+ std::cerr << "opened audio codec with "<<size<<" frame size"<<std::endl;
av_dump_format(oc, 0, filename.c_str(), 1);
@@ -81,7 +84,7 @@ bool libav::exporter::record(std::string filename){
return true;
}
-bool libav::exporter::encodeFrame(unsigned char *pixels){
+bool libav::Exporter::encodeFrame(unsigned char *pixels,uint16_t *samples){
// 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;
@@ -94,10 +97,6 @@ bool libav::exporter::encodeFrame(unsigned char *pixels){
else
video_pts = 0.0;
- uint16_t *samples = av_malloc(audio_input_frame_size *
- av_get_bytes_per_sample(audio_st->codec->sample_fmt) *
- audio_st->codec->channels); //dummy audio
-
// write interleaved audio and video frames //
if (!video_st || (video_st && audio_st && audio_pts < video_pts)) {
write_audio_frame(oc, audio_st, samples);
@@ -107,14 +106,12 @@ bool libav::exporter::encodeFrame(unsigned char *pixels){
frame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
}
- av_free(samples);
-
//std::cerr << "encoded frame " << outputframe << std::endl;
outputframe++;
return true;
}
-void libav::exporter::finishRecord(){
+void libav::Exporter::finishRecord(){
av_write_trailer(oc);
// Close each codec. //