<span lang="">
<p><font face="verdana,sans-serif">Hi,</font></p>
<p><font face="verdana,sans-serif">I am trying to stream a YUV file whose pix format is <font size="2"><font size="2">PIX_FMT_RGBA</font></font></font></p></span><font size="2"><font size="2"><span lang="EN"><font face="verdana,sans-serif">, to a VLC player. I use H264 codec for encoding using FFMPEG. Earlier i had used YUV file with </font></span></font></font><font size="2"><font size="2" face="verdana,sans-serif">PIX_FMT_YUV420P</font></font><font size="2"><font size="2"><font face="verdana,sans-serif"> 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? </font>
<p><font face="verdana,sans-serif">I have specified the following in the code;</font></p></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">//Allocate codec context</font></p>
<p><font face="verdana,sans-serif">codec = avcodec_find_encoder(CODEC_ID_</font></p></font></font><font size="2"><font size="2" face="verdana,sans-serif">H264</font></font><font size="2"><font size="2"><font face="verdana,sans-serif">);</font>
<p><font face="verdana,sans-serif">c = mpegtsstream->codec; </font></p>
<p><font face="verdana,sans-serif">//c->profile= FF_PROFILE_H264_BASELINE; </font></p></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">c</font></p></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">->coder_type=FF_CODER_TYPE_VLC;</font>
<p><font face="verdana,sans-serif">c->bit_rate = 400000;</font></p>
<p><font face="verdana,sans-serif">c->width = </font></p></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">480</font></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">c->height = </font></p></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">800</font></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">c->time_base= (AVRational){1,10}; //frames per second</font></p>
<p><font face="verdana,sans-serif">c->gop_size = 250; /* emit one intra frame every 250 frames */</font></p></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">c</font></p></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">->max_b_frames=0;</font>
<p><font face="verdana,sans-serif">c->pix_fmt = PIX_FMT_</font></p></font></font><font size="2"><font size="2" face="verdana,sans-serif">RGBA</font></font><font size="2"><font size="2"><font face="verdana,sans-serif">;</font>
<p><font face="verdana,sans-serif">c->me_range = 16;</font></p>
<p><font face="verdana,sans-serif">c->max_qdiff = 4;</font></p></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">c</font></p></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">->qmin = 10;</font>
<p><font face="verdana,sans-serif">c->qmax = 35;</font></p>
<p><font face="verdana,sans-serif">c->qcompress = 0.3;</font></p></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">a</font></p></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">vcodec_open(c, codec);</font></font></font><font size="2"><font size="2">
<div><font face="verdana,sans-serif">Created </font></div></font></font><font face="verdana,sans-serif"><font size="2"><font size="2">AVFrame</font></font><font size="2"><font size="2">, filled the raw data from the YUV file into AVPicture...</font></font></font>
<div> </div>
<div><font size="2"><font size="2" face="verdana,sans-serif">frame = avcodec_alloc_frame(); </font></font></div><font size="2"><font size="2">
<p><font face="verdana,sans-serif">n</font></p></font></font><font face="verdana,sans-serif"><font size="2"><font size="2">umBytes = avpicture_get_size(PIX_FMT_</font></font><font size="2"><font size="2">RGBA</font></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">, c->width, c->height); </font>
<div><font face="verdana,sans-serif">buffer = (uint8_t *)av_malloc(numBytes*sizeof(uint8_t)); </font></div>
<div><font face="Verdana">.</font></div></font></font><font size="2"><font size="2"><font face="verdana,sans-serif">..</font></font></font>
<div><font size="2"><font size="2"><font face="verdana,sans-serif">...</font></font></font></div>
<div> </div>
<div><font size="2"><font size="2"><font face="verdana,sans-serif">for(;;)</font></font></font></div>
<div><font size="2"><font size="2"><font face="verdana,sans-serif">{</font></font></font></div>
<p><font face="verdana,sans-serif">sizein = fread(buffer, 1, numBytes, f);</font></p>
<p><font size="2"><font size="2"><font face="verdana,sans-serif">...</font></font></font></p>
<p><font face="verdana,sans-serif">...</font></p><font size="2"><font size="2">
<p><font face="verdana,sans-serif">avpicture_fill((AVPicture*)frame, buffer, PIX_FMT_</font></p></font></font><font size="2"><font size="2" face="verdana,sans-serif">RGBA</font></font><font size="2"><font size="2"><font face="verdana,sans-serif">, c->width, c->height); </font>
<p><font face="verdana,sans-serif">frame->interlaced_frame = 1; //if wanted and in video parameters defined</font></p>
<p><font face="verdana,sans-serif">frame->top_field_first = 1;</font></p>
<p><font face="verdana,sans-serif">fd->framebuf_size = avcodec_encode_video(c, fd->frame_buffer, numBytes, frame);</font></p></font></font><font size="2"><font size="2">
<p><font face="verdana,sans-serif">The encoded buffer will be encapsulted with Mpeg-ts and RTP protocol, and streamed to the VLC player. I have used </font></p></font></font><font size="2"><font size="2" face="verdana,sans-serif">av_interleaved_write_frame</font></font><font size="2"><font size="2"><font face="verdana,sans-serif">() for writing the frames into Mpeg-ts and RTP context.</font>
<div><font face="verdana,sans-serif">Thanks in advance,</font></div>
<div><font face="verdana,sans-serif">Hema</font></div></font></font>