<div dir="ltr">I've made some progress, here is the new code that sort-of works:<div><br></div><div><div>for(i=0;i<77;i++) {</div><div> fflush(stdout);</div><div><br></div><div><span class="" style="white-space:pre"> </span>uint8_t *pPixels = new uint8_t[screenWidth*screenHeight*(32 >> 3)];</div>
<div><span class="" style="white-space:pre"> </span>pPixels = screenCap();<span class="" style="white-space:pre"> //getting the screenshot by the same method posted earlier</span></div><div><br></div><div><span class="" style="white-space:pre"> </span>int nbytes = avpicture_get_size(PIX_FMT_YUV420P, c->width, c->height);</div>
<div><span class="" style="white-space:pre"> </span>uint8_t* outbuffer = (uint8_t*)av_malloc(nbytes*sizeof(uint8_t));</div><div><br></div><div><span class="" style="white-space:pre"> </span>outpic->pts = (int64_t)((float)i * (1000.0/((float)(c->time_base.den))) * 90);</div>
<div><span class="" style="white-space:pre"> </span>avpicture_fill((AVPicture*)inpic, pPixels, PIX_FMT_RGB32, c->width, c->height);<span class="" style="white-space:pre"> </span>// Fill picture with image</div><div>
<span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>avpicture_fill((AVPicture*)outpic, outbuffer, PIX_FMT_YUV420P, c->width, c->height);</div><div><span class="" style="white-space:pre"> </span>av_image_alloc(outpic->data,outpic->linesize,c->width,c->height,c->pix_fmt,1);</div>
<div><br></div><div><span class="" style="white-space:pre"> </span>inpic->data[0] += inpic->linesize[0]*(screenHeight-1);<span class="" style="white-space:pre"> </span>// Flipping frame</div><div><span class="" style="white-space:pre"> </span>inpic->linesize[0] = -inpic->linesize[0];<span class="" style="white-space:pre"> </span>// Flipping frame</div>
<div><span class="" style="white-space:pre"> </span>struct SwsContext* fooContext = sws_getContext(c->width, c->height, PIX_FMT_RGB32, c->width, c->height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);</div>
<div><span class="" style="white-space:pre"> </span>sws_scale(fooContext, inpic->data, inpic->linesize, 0, c->height, outpic->data, outpic->linesize);</div><div><span class="" style="white-space:pre"> </span>printf("Image scaled\n");</div>
<div><br></div><div> // encode the image</div><div> out_size = avcodec_encode_video(c, outbuf, outbuf_size, outpic);</div><div> printf("Encoding frame %3d (size=%5d)\n", i, out_size);</div><div>
fwrite(outbuf, 1, out_size, f);</div><div><span class="" style="white-space:pre"> </span>delete [] pPixels;</div><div>}</div><div><br></div><div style>This is giving me <i>some </i>output, but not quite usable still. <a href="http://i.imgur.com/Hqgta3L.png">Here is a picture</a> of the new code's output video, which shows the console (and should have visual studio behind it). Does this gray background indicate that I'm using the wrong input pixel format for the screenshot?</div>
<div><br></div><div><br></div></div></div>