Please don't top post on this list. On Thu, 2010-12-16 at 17:07 +0200, Aaron L. wrote: > On Thu, Dec 16, 2010 at 3:55 PM, Tomas Härdin <[email protected]>wrote: > > > On Thu, 2010-12-16 at 15:41 +0200, Aaron L. wrote: > > > Hi all, > > > > > > I am trying to encode preview frames from a camera on an android device > > to > > > mpeg 4 > > > > > > i set the desired codec format like this to get 420 YUV: > > > m_codec->pix_fmt = PIX_FMT_YUV420P > > > > > > the problem is the preview frames from android are linepack and not > > planar > > > > > > (its not a huge block of U followed by a huge block of V - instead its > > > UVUVUVUVUV under the big Y section) > > > > Sounds like PIX_FMT_NV12. > > > > > As a result my generated movie is mostly grey with a faint red and green > > > stripes > > > > > > > > > my question is: is there a format I can use instead of PIX_FMT_YUV420P > > which > > > will allow me to use line pack preview frames or must i convert first > > from > > > linepack to planar ... > > > > No need to do any conversion. Just set up your AVFrames correctly. > > avpicture_fill() would probably be enough in your case. Or it might > > assume it's one byte Y plane followed by an U/V plane. In that case > > you'll need to set up the data pointers and linesizes (aka strides) > > yourself. > > > > /Tomas > > > Hi, > > thanks for the help, reading the description of PIX_FMT_NV12 it now seems > obvious but I just never heard Line Pack refered to as NV. > > After changing from YUV420 to NV12 now when I try to call avcodec_open it > returns -1 (it was working just fine for YUV420). Is there some additional > option in the build configuration I need to enable for NV12 ? > > codec = avcodec_find_encoder(CODEC_ID_MPEG4); > > if (!codec) { > __android_log_print(ANDROID_LOG_DEBUG,"AML", "codec not found..."); > return -1; > } > > m_codec= avcodec_alloc_context(); > m_picture= avcodec_alloc_frame(); > > /* put sample parameters */ > m_codec->bit_rate = 400000; > /* resolution must be a multiple of two */ > m_codec->width = width; //800;//352; > m_codec->height = height; //480;//288; > /* frames per second */ > //c->time_base= (AVRational){1,25}; > m_codec->time_base.num = 1; > m_codec->time_base.den = 25; > m_codec->gop_size = 10; /* emit one intra frame every ten frames */ > m_codec->max_b_frames=1; > m_codec->pix_fmt = PIX_FMT_NV12; > > /* open it */ > int openresult = 0; > if ((openresult = avcodec_open(m_codec, codec)) < 0) { > __android_log_print(ANDROID_LOG_DEBUG,"AML", "could not open codec > %d",openresult); > return -2; > } > > > > or am I missing something painfully obvious in the codec parameters ??? > > > thanks, > > Aaron
The mpeg4 encoder only supports PIX_FMT_YUV420P so you need to use libswscale to convert your NV12 frames to YUV420P. See libavformat/output-example.c /Tomas
signature.asc
Description: This is a digitally signed message part
_______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
