[Libav-user] writing .avi with rawvideo and rgb data
Steffen
Steffen.Roeber at hella.com
Wed Apr 24 15:38:51 CEST 2013
I'm trying to write an uncompressed .avi with pixel format rgb24. This fails:
static void video_encode_example_init(const cImg &i_img)
{
oc = avformat_alloc_context();
oc->oformat = av_guess_format("rawvideo", nullptr, nullptr);
oc->oformat->video_codec = AV_CODEC_ID_RAWVIDEO;
codec = avcodec_find_encoder(oc->oformat->video_codec);
oc->streams[0] = avformat_new_stream(oc, codec);
avcodec_get_context_defaults3(oc->streams[0]->codec, codec);
oc->streams[0]->codec->codec_id = codec->id;
oc->streams[0]->codec->codec_type = codec->type;
oc->streams[0]->codec->width = i_img.getWidth();
oc->streams[0]->codec->height = i_img.getHeight();
oc->streams[0]->codec->time_base.num = 1;
oc->streams[0]->codec->time_base.den = 25;
oc->streams[0]->codec->pix_fmt = codec->pix_fmts[0];
int res = avcodec_open2(oc->streams[0]->codec, codec, NULL);
res = avio_open2(&oc->pb, "d:/temp/test.avi", AVIO_FLAG_WRITE, 0, 0);
// oc->streams[0]->codec->codec_tag = 0; //if I comment this line write
header works.
res = avformat_write_header(oc, 0); //this gives me an error
It seems that the avi encoder does not support rgb24 or rgb32 pixel types.
So what 's the preffered way?
--
View this message in context: http://libav-users.943685.n4.nabble.com/writing-avi-with-rawvideo-and-rgb-data-tp4657369.html
Sent from the libav-users mailing list archive at Nabble.com.
More information about the Libav-user
mailing list