[Libav-user] encoder h264

Francesco Damato francesco.damato7 at gmail.com
Mon Oct 21 12:38:49 CEST 2013


Hi,

thanks for your help.

Your function above, if i understood correctly, read from raw file, put
data into video_buf and at the end returned the number of bytes read. Now i
want to encode, so i must to pass raw data to avcodec_encode_video2
function, that takes input raw video data from frame. So how can i pass
data to this function?? Have i to put the data in data field of AVFrame
Structure?? I hope to be clear.

Regards


2013/10/17 Aravind Madineni <aravind.madineni at lge.com>

> 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 ****
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>


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


More information about the Libav-user mailing list