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

Alex Cohn alexcohn at netvision.net.il
Thu Oct 27 18:50:00 CEST 2011


On Thu, Oct 27, 2011 at 14:16, Hema A <hema.angamuthu at gmail.com> wrote:
> To add on, currently the image that is streamed in PIX_FMT_RGBA format is
> not clear. It has green strips and we can observe the frames very faintly in
> the background.

it could happen that the RGBA label was given by mistake. Try to look
at the frames as if they were YUV420P.

Alex

> Thanks,
> Hema
> On Thu, Oct 27, 2011 at 5:20 PM, Hema A <hema.angamuthu at gmail.com> wrote:
>>
>> 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;
>>
>> a
>>
>> vcodec_open(c, codec);
>> Created
>> AVFrame, filled the raw data from the YUV file into AVPicture...
>>
>> frame = avcodec_alloc_frame();
>>
>> n
>>
>> umBytes = 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
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>


More information about the Libav-user mailing list