[Libav-user] encoder h264

Aravind Madineni aravind.madineni at lge.com
Thu Oct 17 06:28:50 CEST 2013


Pseudo Code

static size_t fill_yuv_image_from_file(AVPicture *pict, int frame_index,int width, int height,FILE *video_dst_filename)
{

   uint8_t *video_buf=NULL;
   int x,y;
   size_t bytesRead;

   video_buf =(uint8_t *)malloc((3*width*height)>>1);
   //Initialize to zero
   memset(video_buf,0,sizeof(uint8_t)* ((3*width*height)>>1));
   bytesRead =fread((uint8_t *)video_buf,sizeof(uint8_t),((3*width*height)>>1),video_dst_filename);
   if(feof(video_dst_filename))
   {
        fprintf(stdout,"\n End of File. BytesRead is :%ld",bytesRead);
        free(video_buf);
        return END_OF_FILE;
   }
   if(bytesRead)
   {

   fprintf(stdout,"\n No Of Video Bytes Read :%ld",bytesRead);
   /* Y */
   for(y =0;y < height ;y++){
        for(x = 0; x < width; x++){
                pict->data[0][y * pict->linesize[0] + x]=*video_buf++;
        }
   }

   /* Cb  */
    for (y = 0; y < height / 2; y++) {
        for (x = 0; x < width / 2; x++) {
            pict->data[1][y * pict->linesize[1] + x] = *video_buf++; //[y*height+x];

        }
   }
   /* Cr */
   for (y = 0; y < height / 2; y++) {
        for (x = 0; x < width / 2; x++) {
          pict->data[2][y * pict->linesize[2] + x] = *video_buf++;  //[y*height+(x+1)];
         }
   }
   video_buf-=((3*width*height)>>1);
   }
   else{
        fprintf(stdout,"\n Video Bytes Read:%ld",bytesRead);
   }
  free(video_buf);
   return bytesRead;
}

From: libav-user-bounces at ffmpeg.org [mailto:libav-user-bounces at ffmpeg.org] On Behalf Of Francesco Damato
Sent: Wednesday, October 16, 2013 8:05 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.
Subject: [Libav-user] encoder h264

Hi,

i am writing a C program (encoder) that use h264 to encode video read from avi or mp4 file; the avcodec_encode_video2 function takes input raw video data from frame, so i demux my files and i obtain a raw video file; now i want encode it, so how can i open the raw file, read the frames and encode them into h264??


I saw the example decoding_encoding.c that generates a video from dummy pictures... but how do I replace this part and read and encode my rawvideo file?

Can you help me, there are other examples or books available?

Thanks!!!

--
Francesco Damato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20131017/bc58b2cc/attachment.html>


More information about the Libav-user mailing list