From 01446a5627e0a4f8daf6d29e04d488b07d4b88de Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 1 Oct 2013 03:55:11 +0100 Subject: very painful debugging --- rotord/src/libavwrapper.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'rotord/src') diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index b39428a..04e4366 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -136,7 +136,6 @@ bool libav::exporter::setup(int w,int h, int bitRate, int frameRate, std::string bool libav::exporter::record(std::string filename){ - printf("exporter 1 - using filename '%s'.\n",filename.c_str()); // allocate the output media context // avformat_alloc_output_context2(&oc, NULL, NULL, filename.c_str()); @@ -197,18 +196,15 @@ bool libav::exporter::record(std::string filename){ // Now that all the parameters are set, we can open the audio and // * video codecs and allocate the necessary encode buffers. // - printf("exporter 2.\n"); + if (video_st) open_video(oc, video_codec, video_st); - printf("exporter 3.\n"); if (audio_st) { - printf("exporter 4.\n"); audioframesize=open_audio(oc, audio_codec, audio_st); audiostep=((float)audioframesize)/(audio_st->codec->sample_rate); std::cerr << "opened audio codec with "<codec; + printf("open video 2.\n"); + // open the codec // mutex.lock(); + printf("open video 3.\n"); ret = avcodec_open2(c, codec, NULL); //OPTIONS CAN GO HERE + printf("open video 4.\n"); mutex.unlock(); if (ret < 0) { //fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret)); exit(1); } - + printf("open video 5.\n"); // allocate and init a re-usable frame // frame = avcodec_alloc_frame(); + printf("open video 6.\n"); // moved to constructor and freeing in destructor -- stills crashes the same if (!frame) { //fprintf(stderr, "Could not allocate video frame\n"); exit(1); } + printf("open video 7.\n"); // Allocate the encoded raw picture. // ret = avpicture_alloc(&dst_picture, c->pix_fmt, c->width, c->height); if (ret < 0) { @@ -447,6 +451,7 @@ void libav::exporter::open_video(AVFormatContext *oc, AVCodec *codec, AVStream * exit(1); } + printf("open video 8.\n"); // If the output format is not YUV420P, then a temporary YUV420P // * picture is needed too. It is then converted to the required // * output format. // @@ -459,11 +464,13 @@ void libav::exporter::open_video(AVFormatContext *oc, AVCodec *codec, AVStream * } } - + printf("open video 9.\n"); // copy data and linesize picture pointers to frame // *((AVPicture *)frame) = dst_picture; + printf("open video 10.\n"); + outPixels = (uint8_t*)av_malloc(avpicture_get_size(PIX_FMT_YUV420P, st->codec->width,st->codec->height)); } -- cgit v1.2.3