Hi,
I found, the problems: the bitrate was to low, I changed it to
width*height*4*framerate.
I also deleted this line : p_oc->oformat->flags = AVFMT_RAWPICTURE;
I changed the while loop:
while(...)
{
unsigned char* data = //some cool image in YUV
/* encode the image */
out_size = avcodec_encode_video( c, p_video_outbuf,
m_video_outbuf_size, p_picture );
/* if zero size, it means the image was buffered */
if ( out_size > 0 )
{
AVPacket pkt;
av_init_packet( &pkt );
pkt.pts = av_rescale_q( c->coded_frame->pts, c->time_base,
st->time_base );
if( c->coded_frame->key_frame )
{
pkt.flags |= PKT_FLAG_KEY;
}
pkt.stream_index = p_video_st->index;
pkt.data = p_video_outbuf;
pkt.size = out_size;
/* write the compressed frame in the media file */
ret = av_write_frame( p_oc, &pkt );
}
}
So this is now OK for storing raw RGB data in an AVI container.
But now I have another problem: I want to store raw GRAY16 data in an AVI
container. So I changed "c->pix_fmt = PIX_FMT_YUV420P;" to "c->pix_fmt =
PIX_FMT_GRAY16LE;"
When I play the file, VLC tells me: "rawvideo warning: invalid frame size
(614400 < 921600)". So obviously VLC is waiting for 3 bytes long pixels whereas
GRAY16 is 2 bytes long.
Do you know why?
________________________________________
De : [email protected] [[email protected]] de la
part de DONGIEUX-AKKA Christophe (SAGEM DEFENSE SECURITE)
[[email protected]]
Date d'envoi : jeudi 19 août 2010 18:29
À : [email protected]
Objet : [libav-user] Create raw videos in AVI container
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
#
" 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