diff options
Diffstat (limited to 'rotord')
| -rwxr-xr-x | rotord/ofxMovieExporter.cpp | 25 | ||||
| -rwxr-xr-x | rotord/rotor.h | 23 |
2 files changed, 28 insertions, 20 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); //??? } diff --git a/rotord/rotor.h b/rotord/rotor.h index af1bb72..bedf936 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -382,17 +382,18 @@ namespace Rotor { Testcard* clone(map<string,string> &_settings) { return new Testcard(_settings);}; Image *get_output(const Frame_spec &frame){ if (image->setup(frame.w,frame.h)) { - //create testcard - float ws=(255.0f/frame.w); - float hs=(255.0f/frame.h); - for (int i=0;i<frame.h;i++){ - for (int j=0;j<frame.w;j++){ - image->RGBdata[(i*frame.w+j)*3]=(uint8_t)(i*hs); - image->RGBdata[((i*frame.w+j)*3)+1]=(uint8_t)(j*ws); - image->RGBdata[((i*frame.w+j)*3)+2]=(uint8_t)(0); - image->Adata[i*frame.w+j]=(uint8_t)255; - image->Zdata[i*frame.w+j]=(uint16_t)512; //1.0 in fixed point 8.8 bits - } + + } + //always create testcard + float ws=(255.0f/frame.w); + float hs=(255.0f/frame.h); + for (int i=0;i<frame.h;i++){ + for (int j=0;j<frame.w;j++){ + image->RGBdata[(i*frame.w+j)*3]=(uint8_t)((int)((i+(frame.time*25.0f)*hs))%255); + image->RGBdata[((i*frame.w+j)*3)+1]=(uint8_t)((int)((j+(frame.time*100.0f)*hs))%255); + image->RGBdata[((i*frame.w+j)*3)+2]=(uint8_t)(0); + image->Adata[i*frame.w+j]=(uint8_t)255; + image->Zdata[i*frame.w+j]=(uint16_t)512; //1.0 in fixed point 8.8 bits } } return image; |
