Hello,

I need to create raw videos in AVI container.
I don't understand how I can achieve that...

This is what I am doing and that doesn't work:

av_register_all();

AVFormatContext* p_oc = av_alloc_format_context();
p_oc->oformat = guess_format( 0, "foo.avi", 0 );
p_oc->oformat->video_codec = CODEC_ID_RAWVIDEO;
p_oc->oformat->flags = AVFMT_RAWPICTURE;

AVStream* st = av_new_stream( p_oc, 0 );
AVCodecContext *c = st->codec;
c->codec_id = CODEC_ID_RAWVIDEO;
c->codec_type = CODEC_TYPE_VIDEO;
c->bit_rate = 400000;
c->width = width;
c->height = height;
c->time_base.den = framerate;
c->time_base.num = 1;
c->gop_size = 1;
c->pix_fmt = PIX_FMT_YUV420P;

av_set_parameters( p_oc, 0 );

AVCodec* codec = avcodec_find_encoder( st->codec->codec_id );
avcodec_open( c, codec );

// pictures allocation

url_fopen( &p_oc->pb, "foo.avi", URL_WRONLY );
av_write_header( p_oc );

while(...)
{
unsigned char* data = //some cool image in YUV
AVPacket pkt;
av_init_packet( &pkt );

pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index = st->index;
pkt.data = (uint8_t *)p_picture;
pkt.size = sizeof(AVPicture);

int ret = av_write_frame( p_oc, &pkt );
}

av_write_trailer( p_oc );

// desallocation



I precise that in my real code, all functions returns are checked and are OK.
When I try to play the video with VLC, something is played (duration is good), 
but nothing is displayed, and I've got plenty of error messages : "rawvideo 
warning: invalid frame size (32 < 460800)"


Could you help me, please?
Thanks in advance,
Chris.
#
" Ce courriel et les documents qui lui sont joints peuvent contenir des 
informations confidentielles ou ayant un caractère privé. S'ils ne vous sont 
pas destinés, nous vous signalons qu'il est strictement interdit de les 
divulguer, de les reproduire ou d'en utiliser de quelque manière que ce soit le 
contenu. Si ce message vous a été transmis par erreur, merci d'en informer 
l'expéditeur et de supprimer immédiatement de votre système informatique ce 
courriel ainsi que tous les documents qui y sont attachés."
******
" This e-mail and any attached documents may contain confidential or 
proprietary information. If you are not the intended recipient, you are 
notified that any dissemination, copying of this e-mail and any attachments 
thereto or use of their contents by any means whatsoever is strictly 
prohibited. If you have received this e-mail in error, please advise the sender 
immediately and delete this e-mail and all attached documents from your 
computer system."
#
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
  • [libav-user] Create raw ... DONGIEUX-AKKA Christophe (SAGEM DEFENSE SECURITE)

Reply via email to