[FFmpeg-user] Right pixel column is repeated in the left

Drabner drabner at zoobe.com
Wed Nov 2 13:44:48 CET 2011


Hey,

I have a rather weird problem:

I use ffmpeg to convert frames from a video engine to a video. Now in the
engine, everything looks fine.

And basically, the conversion of the frames into the video also works. But
somehow, the rightmost pixel of each line is repeated in the left. This does
not happen in the engine, so it must be something within the ffmpeg code.

Here is the function that writes the frames:

//---------------------------------------------------------
//---------------------------------------------------------
//---------------------------------------------------------
int out_size, ret;
	AVCodecContext *c;
	static struct SwsContext *img_convert_ctx = NULL;

	c = st->codec;


			/* as we only generate a YUV420P picture, we must convert it
			to the codec pixel format if needed */
			if (ptr->img_convert_ctx == NULL) 
			{
				ptr->img_convert_ctx = sws_getContext( ptr->srcWidth, ptr->srcHeight,
					PIX_FMT_ARGB,
					c->width, c->height,
					c->pix_fmt,
					SWS_BICUBIC, NULL, NULL, NULL );
				if (ptr->img_convert_ctx == NULL) 
				{
					av_log(c, AV_LOG_ERROR, "%s","Cannot initialize the conversion
context\n");
					exit(1);
				}
			}
			sws_scale(ptr->img_convert_ctx, ptr->tmp_picture->data,
ptr->tmp_picture->linesize,
				0, ptr->srcHeight, ptr->picture->data, ptr->picture->linesize);


		/* encode the image */
		out_size = avcodec_encode_video( c, ptr->video_outbuf,
ptr->video_outbuf_size, ptr->picture );
		/* if zero size, it means the image was buffered */
		if (out_size > 0) 
		{
			AVPacket pkt;
			av_init_packet(&pkt);
			if (c->coded_frame->pts != AV_NOPTS_VALUE)
				pkt.pts = av_rescale_q(c->coded_frame->pts, c->time_base,
st->time_base);
			if(c->coded_frame->key_frame)
				pkt.flags |= AV_PKT_FLAG_KEY;
			pkt.stream_index= st->index;
			pkt.data= ptr->video_outbuf;
			pkt.size= out_size;

			/* write the compressed frame in the media file */
			ret = av_write_frame(oc, &pkt); 
		} 
		else 
		{
			ret = 0;
		}
//---------------------------------------------------------
//---------------------------------------------------------
//---------------------------------------------------------

As I said, this generally works, except that glitch.
Any ideas what could cause this?

--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Right-pixel-column-is-repeated-in-the-left-tp3972841p3972841.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.


More information about the ffmpeg-user mailing list