[Libav-user] using avformat with external hardware codec

Jan Pohanka xhpohanka at gmail.com
Wed Aug 8 11:31:47 CEST 2012


I'd like to use avformat library to format the h264 stream which I get  
 from the hardware codec on my SoC to some container (mkv, 3gp, ...). What  
parameters need to be set avformat? I have tried following code  

AVFormatContext *os;
AVOutputFormat *fmt;
AVStream *video_st;


fmt = av_guess_format("matroska", NULL, NULL);
os = avformat_alloc_context();
os->oformat = fmt;
strncpy(os->filename, "test.mkv", 32);

video_st = av_new_stream(os, 0);
video_st->codec->codec_id = CODEC_ID_H264;
video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO;

avio_open(&os->pb, "test.mkv", URL_WRONLY);


while (frames) {
	AVPacket pkt;
	pkt.data = enc_buf->user_addr;
	pkt.size = enc_buf->bytes_used;
	pkt.pts = env->frame_cnt;
	pkt.stream_index = 0;
	av_interleaved_write_frame(os, &pkt);


Unfortunately this ends with SIGFPE arithmetic exception.
I think I can create a "dummy" avcodec codec and use it to fill the  
contents of video_st->codec, but I'd rather to go without such workaround.  
Maybe the parameters can be read from the first frame of the raw h264  

with best regards

Tato zpráva byla vytvořena převratným poštovním klientem Opery:  

More information about the Libav-user mailing list