AVCodecContext *codecctx; AVFormatContext *fmtctx; fmt=av_guess_format(NULL,filename,NULL); if(!fmt) printf("Das Format kann nicht erkannt werden. MPEG wird verwendet"); AVCodec *codec = avcodec_find_encoder(fmt->video_codec); codecctx = avcodec_alloc_context3(codec); codecctx->codec_id = fmt->video_codec; codecctx->codec_type = AVMEDIA_TYPE_VIDEO; codecctx->gop_size = 12; codecctx->bit_rate = WIDTH*HEIGHT*4; codecctx->width = WIDTH; codecctx->height = HEIGHT; codecctx->time_base.den = 2; // Framerate kann man nachträglich verändern. 0.2 hier bedeutet dass jedes Bild für 5 Sekunden erscheint. codecctx->time_base.num =1; //codecctx->time_base =(AVRational){1,FPS}; codecctx->max_b_frames=1; codecctx->pix_fmt= STREAM_PIX_FMT; fmtctx = avformat_alloc_context(); fmtctx->oformat = fmt; fmtctx->video_codec_id = fmt->video_codec; avcodec_open2(codecctx, codec, NULL); if(avcodec_open2(codecctx, codec, NULL)<0) printf("Codec nicht geoeffnet"); AVStream *VideoStream = avformat_new_stream(fmtctx,0); VideoStream->codecpar->codec_id=fmt->video_codec; VideoStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; VideoStream->codecpar->format = STREAM_PIX_FMT; VideoStream->codecpar->width=WIDTH; VideoStream->codecpar->height=HEIGHT; VideoStream->time_base.den=0.2; VideoStream->time_base.num=1; avformat_write_header(fmtctx,0);
fmtctx
Quote:Media file handle, must be allocated with avformat_alloc_context(). Its oformat field must be set to the desired output format; Its pb field must be set to an already opened AVIOContext.
pb
avcodec_open2
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)