[Ffmpeg-devel] Fwd: How to encode video?

Cool_Zer0 c00jz3r0
Wed Feb 14 11:58:40 CET 2007


On 2/14/07, Michael Niedermayer <michaelni at gmx.at> wrote:
>
> Hi
>
> On Wed, Feb 14, 2007 at 10:11:07AM +0000, Cool_Zer0 wrote:
> > I've sent this mail to the users lists but I think that the the devel
> list
> > is more appropriated...
> >
> > ---------- Forwarded message ----------
> > From: Cool_Zer0 <c00jz3r0 at gmail.com>
> > Date: Feb 14, 2007 9:56 AM
> > Subject: How to encode video?
> > To: FFmpeg user questions and RTFMs <ffmpeg-user at mplayerhq.hu>
> >
> > Hi there,
> >
> > I'm trying to encode video to H.263 format...
> >
> > I'm making this:
> >
> > void video_encode(unsigned char* frame_rgb, int frame_rgb_size) {
> >    int r = avcodec_encode_video(enc_context, frame_rgb, frame_rgb_size,
> > encoded_frame);
> >    ...
> >
> > }
> >
> > Something is missing here...
>
> yes
>
>
> > How can the encoder know that the frame_rgb contains a raw RGB frame?
>
> AVCodecContext.pix_fmt documented in avcodec.h and surely also in the
> resulting doxygen output
> furthermore h.263 as writen in the h.263 spec and h263_encoder.pix_fmts
> does support ONLY YUV420 not rgb so this wont help you anyway you will
> have to pass yuv420 to it
>
>
> > Next... encoded_frame->data is a array of 4 positions... When
> > avcodec_encode_video() returns the first 3 positions of the array are
> set...
> > How can I save the frames to disk?
>
> well, before using a function a programmer should look at the docs, if he
> cant find any docs, he looks at the source or header files, you just pass
> random (and wrong) things as arguments to the function which confuses you
> not surprisngly, i suggest you look at apiexample.c
>
>
> >
> > I've been looking for some documentation but I can't find anything
> related
> > to encoding video...
>
> apiexample.c
> ffmpeg.c
> mencoder libmpcodecs/ve_lavc.c
> the doxygen generated docs
> and the source both in .c and .h files of the functions you use





So...
To encode a frame I need to:

- Convert RGB24 frame to YUV420P (probably using img_convert())
- Encode the YUV420P frame with avcodec_encode_video()

Right?


So... I suppose that I only will have the problem to feed the RGB24
AVFrame...




More information about the ffmpeg-devel mailing list