Hello, Andrey ,
 
Thanks for your reply
 
See avformat_new_stream(). Call it for each elementary stream you have,
 
on the output file context.
 
I’ve already tried to do that with video thread only. But I receive an error while calling av_write_frame…
 
av_write_frame (Unhandled exception at 0x76ff15de in ***.exe: 0xC0000094: Integer division by zero.).
 
I’d better show you here the code fragment (without error processing)
 
const char *sFileOutput = "d://video_stream.avi";
 
ofmt = av_guess_format(NULL, sFileOutput, NULL);
 
ofcx = avformat_alloc_context();
 
ofcx->oformat = ofmt;
 
memcpy(ofcx->filename, sFileOutput, sizeof(ofcx->filename));
 
if( avio_open2( &ofcx->pb, sFileOutput, AVIO_FLAG_WRITE, NULL, NULL ) < 0){…}
 
ocodec = avcodec_find_decoder(CODEC_ID_H264);
 
ost = avformat_new_stream(ofcx, ocodec);
 
occx = ost->codec;
 
occx->codec_id = CODEC_ID_H264;
 
occx->codec_type = AVMEDIA_TYPE_VIDEO;
 
avcodec_get_context_defaults3(occx, ocodec);
 
if (avcodec_open2(ost->codec, ocodec, NULL) < 0) {…}
 
if(avio_open2( &ofcx->pb, sFileOutput, AVIO_FLAG_WRITE, NULL, NULL )) {…}
 
avformat_write_header( ofcx, NULL );
 
av_dump_format(ofcx     , 0, ofcx->filename,      1 );
 
ix = 0;
 
 
av_init_packet( &pkt );
 
// m_sFrameBuf – This is a frame formed from the data received from the Ethernet

av_packet_from_data(&pkt, (uint8_t*) &m_sFrameBuf, m_nFpameSize);
 
pkt.stream_index = 0;//ost->id;
 
pkt.pts = ix++;
 
pkt.dts = pkt.pts;
 
av_write_frame( ofcx, &pkt ); // in this point error -  Unhandled exception at 0x76ff15de in ***.exe: 0xC0000094: Integer division by zero
 
av_free_packet( &pkt );
 
 
When I read data from file I copy context and it’s ok
 
 
avcodec_copy_context( ost->codec, iccx );
 
ost->sample_aspect_ratio.num = iccx->sample_aspect_ratio.num;
 
ost->sample_aspect_ratio.den = iccx->sample_aspect_ratio.den;
 
ost->r_frame_rate = ist->r_frame_rate;
 
ost->time_base = av_inv_q( ost->r_frame_rate );
 
ost->codec->time_base = ost->time_base;
 
Where is a mistake?
 
--
 Ekaterina
 
 
 
 
 
 
 
 
 
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to