

OutPacket.data = NULL // packet data will be allocated by the encoderĪvcodec_encode_video2(outAVCodecContext, &outPacket ,outFrame, &got_picture) If( value data, pAVFrame->linesize,0, pAVCodecContext->height, outFrame->data,outFrame->linesize) Value = avcodec_decode_video2( pAVCodecContext, pAVFrame, &frameFinished, pAVPacket ) If(pAVPacket->stream_index = VideoStreamIndx) While( av_read_frame( pAVFormatContext, pAVPacket ) >= 0 ) Uint8_t *video_outbuf = (uint8_t*)av_malloc(nbytes) Ĭoutdata, outFrame->linesize, video_outbuf, AV_PIX_FMT_YUV420P, outAVCodecContext->width,outAVCodecContext->height,1 ) // returns : the size in bytes required for src sample code to record the computer screen !Ĭoutpix_fmt,outAVCodecContext->width,outAVCodecContext->height,32) Start capturing the frames and store it in a file.įinally, release the allocated resources once completed !.īelow code is written in c++ and uses linux(ubuntu) platform video format is in mp4 format. Now go for regular video parameters initialization and memory allocation. Mention the posistion to capture the video in screen (Eg. Use x11grab(for linux OS) in av_find_input_format


Watch the screen recorded video demo using FFMPEG : įollow the steps to record the screen in video using FFmpeg and other libraries. FFmpeg can be used to capture the screen.
