0
我正在使用FFMPEg進行項目,但不知何故我無法創建任何媒體文件。我已經設置了參數,編解碼器等,但是當我打電話給avformat_write_header時,應用程序停止工作。 這裏是我的代碼:不能修改標題FFMPEG
AVOutputFormat *fmt;
AVCodecContext *codecctx;
AVFormatContext *fmtctx;
fmt=av_guess_format(NULL,filename,NULL);
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;
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);
AVStream *VideoStream = avformat_new_stream(fmtctx,codec);
avformat_write_header(fmtctx,NULL);
當你說你的應用程序停止工作你是什麼意思是什麼呢? –
謝謝,問題是我霧cal to cal avio_open。現在我試圖添加一個PNG圖像到流中,但不知道如何將ti轉換爲可用的Frame。你能給我一些提示嗎? –