[Libav-user] decoding mp4 questions

wm4 nfxjfg at googlemail.com
Sat Jun 14 13:05:13 CEST 2014


On Sat, 14 Jun 2014 11:40:03 +0100
Adam Billyard <adambillyard at googlemail.com> wrote:

> Hi All,
> 
> 
> All the examples I can find of using swscale to convert an AVFrame from YUV to RGB, use the *CodecContext* width and height:
> 
> eg
> 
>  sws_getContext(pCodecCtx->width, pCodecCtx->height, 
>                         pCodecCtx->pix_fmt, 
>                          dst_width, dst_height, PIX_FMT_RGB24, SWS_BILINEAR, 
>                         NULL, NULL, NULL);

All ffmpeg examples I've seen were either outdated or broken. Nowadays
you should just use the AVFrame parameters.

> 
> But when I decode a 1024x768 mp4 movie, the CodecContext->width is 8 and height 1024..  Is that expected?

No, that seems unusual. Normally the codec context should have the
parameters of the last AVFrame returned, I think. Maybe something fishy
is going on.

> So I have been using:
> 
> sws_getContext(frame->width, frame->height, pCodecCtx->pix_fmt,
> 			 dst_width, dst_height, PIX_FMT_RGB24, SWS_BILINEAR,
>                          NULL, NULL, NULL);
> 
> 
> ie after decoding an AVFrame, I use its (now known) size to get my sws context.  Is this correct?

Yes. Also, sws_getContext is deprecated.

> 
> Lastly, I find this works fine for .mov and .avi containers, but for .mp4 movies, it all runs but looks like I'm just getting chroma with extra crud of missing/stale macroblocks..
> 
> Video of me pointing at an iPad screen looks like this:
> http://i614.photobucket.com/albums/tt229/ElektraGlide/ScreenShot2014-06-14at113519_zps126c6638.png
> 
> Any ideas?

No. Does playback with ffplay work? Also, mov and mp4 are the same
format.


More information about the Libav-user mailing list