[Libav-user] Converting YUV 2 MPEG4
muratc15-ffmpeg at yahoo.de
muratc15-ffmpeg at yahoo.de
Thu Aug 4 10:26:18 CEST 2011
Hello Matt, Hello people,
thank you for your hint. I am trying this, but I have problems creating the required paramters. Here is my code:
void YUVtoRGB_Converter::YUV2MP4ES(const uint8_t *YUVbuf, uint8_t *MP4buf, int MP4bufSize)
{
AVCodec *codec;
AVCodecContext *c= NULL;
//uint8_t *extradata;
//int extradata_size;
int i, out_size, size, x, y, outbuf_size;
AVFrame *picture;
uint8_t *outbuf;
unsigned char *picture_buf;
//printf("Video encoding\n");
av_register_all();
/* find the mpeg4 video encoder */
codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
c = avcodec_alloc_context3(codec);
picture= avcodec_alloc_frame();
/* put sample parameters */
c->bit_rate = 400000;
/* resolution must be a multiple of two */
c->width = CAM_RESOLUTION_WIDTH;
c->height = CAM_RESOLUTION_HEIGHT;
/* frames per second */
//c->time_base= (AVRational){1,25};
c->time_base.num = 1;
c->time_base.den = FRAMERATE;
c->gop_size = 10; /* emit one intra frame every ten frames */
c->max_b_frames=1;
c->pix_fmt = PIX_FMT_YUV420P;
/* open it */
if (avcodec_open(c, codec) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
/// --> here creating the required parameters
AVFormatContext *t = avformat_alloc_context();
AVDictionary **opt = NULL; // <-- this is the problem i think
f = fopen("test", "a+b");
if (!f) {
fprintf(stderr, "could not open %s\n", "test");
exit(1);
}
if (this->fileExists == false) {
// here throws exception
// Access violation reading location from 0xAddress
avformat_write_header(t, opt);
this->fileExists = true;
}
//.... and so on.
How can I get the "AVDictionary **opt" parameter properly?
Thank you in advice.
Cheers
Murat
--- Matthew Einhorn <moiein2000 at gmail.com> schrieb am Mi, 3.8.2011:
> Von: Matthew Einhorn <moiein2000 at gmail.com>
> Betreff: Re: [Libav-user] Converting YUV 2 MPEG4
> An: "This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter." <libav-user at ffmpeg.org>
> Datum: Mittwoch, 3. August, 2011 14:50 Uhr
> On Wed, Aug 3, 2011 at 9:37 AM,
> <muratc15-ffmpeg at yahoo.de>
> wrote:
> > Hello boys and girls,
> >
> > I want to convert a YUV signal from my POE-camera into
> a MPEG4 stream, for which I have used the libavcodec.lib
> library of yours.
> >
> > I am confused with the file-format headers for the
> target video file. For an instance :
> > out_size = avcodec_encode_video(c, outbuf,
> outbuf_size,
> > outpic);
> > Is there no mpeg4 specific file format header
> required, in the beginning of the video file? Or is the
> library function handling this internally?
> >
> I use avformat_write_header() before starting to write
> frames and
> av_write_trailer() afterwords. I think this should do what
> you want.
>
> Matt
>
>
> > Cheers Murat
> >
> > _______________________________________________
> > Libav-user mailing list
> > Libav-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/libav-user
> >
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
More information about the Libav-user
mailing list