[Libav-user] using avformat with external hardware codec

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


Hello,

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  
(simplified).

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

av_register_all();

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);

av_write_header(os);

while (frames) {
	AVPacket pkt;
	av_init_packet(&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);
}

av_write_trailer(os);


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  
stream?

with best regards
Jan

-- 
Tato zpráva byla vytvořena převratným poštovním klientem Opery:  
http://www.opera.com/mail/


More information about the Libav-user mailing list