[FFmpeg-devel] ffmpeg4iphone creating mp4 video from video frame

Daniel Sof dsoffer86
Wed Jun 16 19:01:02 CEST 2010



> So the biplanar format is PIX_FMT_NV12? if swscale says swScaler: nv12 is not supported as input pixel format
> Cannot initialize the conversion context, guess there is no way to convert it using swscale?

>NV12 is supported as input and output for swscale. What revision are
>you using? It'd be nice if you could provide us a sample if swscale
>really doesn't support it.

>And please don't top-post (google for "top-post" if you don't know
>what it means).

I am using revision 16838 of ffmpeg4iphone...here is the piece of code where i try to do the conversion...im trying? to use output_example.c to encode some video but all i get is a garbled up frame, which i think is beause i dont have the right pixel format...i changed alloc_picture to return the frame, thanks for the input....
static AVFrame *alloc_picture(int pix_fmt, int width, int height)
{
??? AVFrame *picture;
??? AVFrame *tmp;
??? uint8_t *picture_buf;
??? int size;
??? 
??? picture = avcodec_alloc_frame();
??? tmp= avcodec_alloc_frame();
??? if (!picture)
??????? return NULL;
??? size = avpicture_get_size(pix_fmt, width, height);
??? picture_buf = av_malloc(size);
??? if (!picture_buf) {
??????? av_free(picture);
??????? return NULL;
??? }
??? 
?//picture in NV12 format (which i was told was biplanar YUV)
??? avpicture_fill((AVPicture *)tmp, (uint8_t *)videoPixels,
?????????????????? PIX_FMT_NV12, width, height);
//gonna try to convert it to YUV20
??? avpicture_fill((AVPicture *)picture, picture_buf,
????????????????? PIX_FMT_YUV420P, width, height);
??? 
??? ? static struct SwsContext *img_convert_ctx;
??? if (img_convert_ctx == NULL) {
??? ??? img_convert_ctx = sws_getContext(width, height,
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?PIX_FMT_NV12,
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?width, height,
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?PIX_FMT_YUV420P,
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?sws_flags, NULL, NULL, NULL);
??? ??? if (img_convert_ctx == NULL) {
??? ??? ??? fprintf(stderr, "Cannot initialize the conversion context\n");
??? ??? ??? exit(1);
??? ??? }
??? }

??? sws_scale(img_convert_ctx, tmp->data, tmp->linesize,
??? ??? ??? ? 0, height, picture->data, picture->linesize);

?
??? return picture;
}

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel



      



More information about the ffmpeg-devel mailing list