9. step 3
set up out format
AVFormatContext avformat_alloc_context
AVOutputFormat av_guess_format
if format did not support, please set up configure file.
10. step 4
we need to prepare some codec
structures.
AVFormatContext
av_new_stream(c, channel)
video audio
AVStream AVStream
video audio
stream->codec
AVCodecContext AVCodecContext
11. step 5
set up video codec
msrAVCodecContextVideo->codec_id = CODEC_ID_MPEG4;
msrAVCodecContextVideo->codec_type = CODEC_TYPE_VIDEO;
msrAVCodecContextVideo->bit_rate= iBitrate;
msrAVCodecContextVideo->width= iWidth;
msrAVCodecContextVideo->height= iHeight;
msrAVCodecContextVideo->time_base.den = iFps;
msrAVCodecContextVideo->time_base.num = 1;
msrAVCodecContextVideo->gop_size= iFps;
msrAVCodecContextVideo->pix_fmt= PIX_FMT_YUV420P;
msrAVCodecContextVideo->max_b_frames=0;
13. step 7
open file descriptor and write header
if(url_fopen(&sAVFormatContext->pb, pathName, URL_WRONLY) < 0)
{
//error handle
}
av_write_header(sAVFormatContext);
the pathName can be following
file://tmp/aaaa
tcp://x99
udp://x88