[Libav-user] Streaming YUV file in PIX_FMT_RGBA format to VLC player

Hema A hema.angamuthu at gmail.com
Thu Oct 27 13:50:24 CEST 2011


Hi,

I am trying to stream a YUV file whose pix format is PIX_FMT_RGBA, to a VLC
player. I use H264 codec for encoding using FFMPEG. Earlier i had used YUV
file with PIX_FMT_YUV420P format and i could successfully stream the YUV
video with the same source implementation. Can anybody let me know if the
below code needs any additional change for encoding a YUV file in RGBA
format and does VLC player support playing such files?

I have specified the following in the code;

//Allocate codec context

codec = avcodec_find_encoder(CODEC_ID_H264);

c = mpegtsstream->codec;

//c->profile= FF_PROFILE_H264_BASELINE;

c->coder_type=FF_CODER_TYPE_VLC;

c->bit_rate = 400000;

c->width = 480

c->height = 800

c->time_base= (AVRational){1,10}; //frames per second

c->gop_size = 250; /* emit one intra frame every 250 frames */

c->max_b_frames=0;

c->pix_fmt = PIX_FMT_RGBA;

c->me_range = 16;

c->max_qdiff = 4;

c->qmin = 10;

c->qmax = 35;

c->qcompress = 0.3;

avcodec_open(c, codec);
Created AVFrame, filled the raw data from the YUV file into AVPicture...

frame = avcodec_alloc_frame();

numBytes = avpicture_get_size(PIX_FMT_RGBA, c->width, c->height);
buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
...
...

for(;;)
{

sizein = fread(buffer, 1, numBytes, f);

...

...

avpicture_fill((AVPicture*)frame, buffer, PIX_FMT_RGBA, c->width,
c->height);

frame->interlaced_frame = 1; //if wanted and in video parameters defined

frame->top_field_first = 1;

fd->framebuf_size = avcodec_encode_video(c, fd->frame_buffer, numBytes,
frame);

The encoded buffer will be encapsulted with Mpeg-ts and RTP protocol, and
streamed to the VLC player. I have used av_interleaved_write_frame() for
writing the frames into Mpeg-ts and RTP context.
Thanks in advance,
Hema
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20111027/564bf2a1/attachment.html>


More information about the Libav-user mailing list