2016-06-09 12 views
0

Ich arbeite an einem Projekt mit FFMPEg, aber irgendwie kann ich keine Mediendatei erstellen. Ich habe die Parameter, Codec usw. eingestellt, aber wenn ich avformat_write_header aufrufen, funktioniert die App einfach nicht mehr. Hier ist mein Code:Kann nicht schreiben 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); 
+0

Wenn Sie Ihre Anwendung sagen, nicht mehr funktioniert, was meinst du genau? –

+0

Danke, das Problem ist, dass ich cavio_open calcot. Jetzt versuche ich ein png Bild zum Strom hinzuzufügen, aber weiß nicht, wie man Ti in einen verwendbaren Rahmen umwandelt. Kannst du mir ein paar Hinweise geben? –

Antwort