diff options
| author | Comment <tim@gray.(none)> | 2013-04-17 21:55:04 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-04-17 21:55:04 +0100 |
| commit | bd728800f22d6086ef1c901d7a212d655640c97c (patch) | |
| tree | 3393675cf2b544b2e7b9385ac6c80e05c5aa6e29 /rotord/ofxMovieExporter.cpp | |
| parent | 66d5eec509cf1a5b376f4111b12dc9f31fe968a0 (diff) | |
interleave audio
Diffstat (limited to 'rotord/ofxMovieExporter.cpp')
| -rwxr-xr-x | rotord/ofxMovieExporter.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/rotord/ofxMovieExporter.cpp b/rotord/ofxMovieExporter.cpp index e8a53e6..ef5b783 100755 --- a/rotord/ofxMovieExporter.cpp +++ b/rotord/ofxMovieExporter.cpp @@ -86,8 +86,8 @@ recording = false; numCaptures = 0; -inW=outW; -inH=outH; + inW=outW; + inH=outH; convertCtx = sws_getContext(inW, inH, PIX_FMT_RGB24, outW, outH, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL); @@ -238,10 +238,6 @@ inH=outH; { AVPacket pkt; av_init_packet(&pkt); - //pkt.pts = av_rescale_q(codecCtx->coded_frame->pts, codecCtx->time_base, videoStream->time_base); - //if(codecCtx->coded_frame->key_frame) pkt.flags |= AV_PKT_FLAG_KEY; - int num=videoStream->time_base.num; - int den=videoStream->time_base.den; pkt.pts = (int64_t)frameNum*(frameInterval*(((float)videoStream->time_base.den)/videoStream->time_base.num));//ofGetFrameNum();//codecCtx->coded_frame->pts; pkt.flags |= AV_PKT_FLAG_KEY; pkt.dts = pkt.pts; @@ -250,6 +246,9 @@ inH=outH; pkt.size = outSize; av_write_frame(formatCtx, &pkt); } + + //is it as simple as writing an audio packet for every video packet? + frameNum++; return true; @@ -305,6 +304,10 @@ inH=outH; // set the format codec (the format also has a default codec that can be read from it) outputFormat->video_codec = codec->id; + //---------------------------> + //leaving the audio codec at the default for now + //---------------------------> + ///////////////////////////////////////////////////////////// // allocate the format context formatCtx = avformat_alloc_context(); @@ -314,9 +317,10 @@ inH=outH; ///////////////////////////////////////////////////////////// // set up the video stream videoStream = av_new_stream(formatCtx, 0); + ///////////////////////////////////////////////////////////// - // init codec context + // init codec context for video codecCtx = videoStream->codec; codecCtx->bit_rate = bitRate; codecCtx->width = outW; @@ -325,8 +329,8 @@ inH=outH; codecCtx->time_base.num = 1;//codecCtx->ticks_per_frame; codecCtx->time_base.den = frameRate; videoStream->time_base = codecCtx->time_base; - - + //audioStream->time_base = codecCtx->time_base; //???has the capability of crashing + codecCtx->gop_size = 10; /* emit one intra frame every ten frames */ codecCtx->pix_fmt = PIX_FMT_YUV420P; @@ -361,5 +365,8 @@ inH=outH; //if ( avcodec_open2(codecCtx, codec,&options); // < 0) ofLog(OF_LOG_ERROR, "ofxMovieExproter: Could not open codec"); + + //do all the same for audio? + //audioStream = av_new_stream(formatCtx, 1); //??? } |
