Thanks. I fixed it with your solution. And I'm facing another problem. I need to display the frame, without SDL. I want to render it using opengl. Does anybody have experience on drawing AVPicture with gl?
Thanks. On Sun, Aug 23, 2009 at 7:13 AM, Mike Plummer <[email protected]> wrote: > 1. You need a context > > pCodex is the codec you want to scale something by(input video) > > These are the dst parameteres (our resulting video) > nVidWidth, nVidHeight, PIX_FMT_RGB24 > > pSWSContext = sws_getContext(pCodecCtx->width, pCodecCtx->height, > pCodecCtx->pix_fmt, nVidWidth, nVidHeight, PIX_FMT_RGB24, SWS_BILINEAR, 0, > 0, 0); > > 2. scale the decoded video into the rgb video buffer > > //Scale the raw data/convert it to our video buffer... > sws_scale(pSWSContext, pRAWFrame->data, pRAWFrame->linesize, 0, > pCodecCtx->height, pRGBFrame->data, pRGBFrame->linesize); > > 3. free context when done or video size result changes. > av_free > > 4. done. > > -Michael > ________________________________________ > From: [email protected] [[email protected]] On > Behalf Of Mike Chen [[email protected]] > Sent: Friday, August 21, 2009 9:48 PM > To: Libav* user questions and discussions > Subject: [BULK] [libav-user] How to use sws_scale in place of img_convert? > > I'm following the tutorial on ffmpeg's documentation. > In tutorial01.c I couldn't compile because img_convert is deprecated. > > Can some one show me how to rewrite the function with sws_scale? > > Code were: > > int frameFinished;AVPacket > <http://www.dranger.com/ffmpeg/data.html#AVPacket> packet; > > i=0; > while(av_read_frame > <http://www.dranger.com/ffmpeg/functions.html#av_read_frame>(pFormatCtx, > &packet)>=0) { > // Is this a packet from the video stream? > if(packet.stream_index==videoStream) { > // Decode video frame > avcodec_decode_video > <http://www.dranger.com/ffmpeg/functions.html#avcodec_decode_video > >(pCodecCtx, > pFrame, &frameFinished, > packet.data, packet.size); > > // Did we get a video frame? > if(frameFinished) { > // Convert the image from its native format to RGB > img_convert > <http://www.dranger.com/ffmpeg/functions.html#img_convert>((AVPicture > <http://www.dranger.com/ffmpeg/data.html#AVPicture> *)pFrameRGB, > PIX_FMT_RGB24, > (AVPicture > <http://www.dranger.com/ffmpeg/data.html#AVPicture>*)pFrame, > pCodecCtx->pix_fmt, > pCodecCtx->width, pCodecCtx->height); > > // Save the frame to disk > if(++i<=5) > SaveFrame(pFrameRGB, pCodecCtx->width, > pCodecCtx->height, i); > } > } > > // Free the packet that was allocated by av_read_frame > <http://www.dranger.com/ffmpeg/functions.html#av_read_frame> > av_free_packet > <http://www.dranger.com/ffmpeg/functions.html#av_free_packet>(&packet); > } > > //This line: > > img_convert <http://www.dranger.com/ffmpeg/functions.html#img_convert > >((AVPicture > <http://www.dranger.com/ffmpeg/data.html#AVPicture> *)pFrameRGB, > PIX_FMT_RGB24, > (AVPicture > <http://www.dranger.com/ffmpeg/data.html#AVPicture>*)pFrame, > pCodecCtx->pix_fmt, > pCodecCtx->width, pCodecCtx->height); > _______________________________________________ > libav-user mailing list > [email protected] > https://lists.mplayerhq.hu/mailman/listinfo/libav-user > _______________________________________________ > libav-user mailing list > [email protected] > https://lists.mplayerhq.hu/mailman/listinfo/libav-user > _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
