pkt.size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, buffer );
// Write the compressed frame in the media file
- pkt.pts= c->coded_frame->pts;
+ if ( c->coded_frame )
+ pkt.pts= c->coded_frame->pts;
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index= audio_st->index;
pkt.data= audio_outbuf;
- if ( av_write_frame( oc, &pkt ) != 0)
+ if ( av_interleaved_write_frame( oc, &pkt ) != 0)
fprintf(stderr, "Error while writing audio frame\n");
}
else
AVPacket pkt;
av_init_packet( &pkt );
- pkt.pts= c->coded_frame->pts;
+ if ( c->coded_frame )
+ pkt.pts= c->coded_frame->pts;
if(c->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index= video_st->index;
pkt.size= out_size;
// write the compressed frame in the media file
- ret = av_write_frame(oc, &pkt);
+ ret = av_interleaved_write_frame(oc, &pkt);
}
}
frame_count++;