if(st->codec.codec_type == CODEC_TYPE_AUDIO && pkt->size==0) return 0;
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){    AVPacketList *pktl, **next_point, *this_pktl;    int stream_count=0;    int streams[MAX_STREAMS];    AVStream *st= s->streams[ pkt->stream_index];    compute_pkt_fields2(st, pkt);    if(pkt->dts == AV_NOPTS_VALUE)        return -1;            assert(pkt->destruct != av_destruct_packet); //FIXME    this_pktl = av_mallocz(sizeof(AVPacketList));    this_pktl->pkt= *pkt;    av_dup_packet(&this_pktl->pkt);    next_point = &s->packet_buffer;    while(*next_point){        AVStream *st2= s->streams[ (*next_point)->pkt.stream_index];        int64_t left=  st2->time_base.num * (int64_t)st ->time_base.den;        int64_t right= st ->time_base.num * (int64_t)st2->time_base.den;        if((*next_point)->pkt.dts * left > pkt->dts * right) //FIXME this can overflow            break;        next_point= &(*next_point)->next;    }    this_pktl->next= *next_point;    *next_point= this_pktl;        memset(streams, 0, sizeof(streams));    pktl= s->packet_buffer;    while(pktl){//av_log(s, AV_LOG_DEBUG, "show st:%d dts:%lld\n", pktl->pkt.stream_index, pktl->pkt.dts);        if(streams[ pktl->pkt.stream_index ] == 0)            stream_count++;        streams[ pktl->pkt.stream_index ]++;        pktl= pktl->next;    }    while(s->nb_streams == stream_count){        int ret;        pktl= s->packet_buffer;//av_log(s, AV_LOG_DEBUG, "write st:%d dts:%lld\n", pktl->pkt.stream_index, pktl->pkt.dts);        truncate_ts(s->streams[pktl->pkt.stream_index], &pktl->pkt);        ret= s->oformat->write_packet(s, &pktl->pkt);                s->packet_buffer= pktl->next;                if((--streams[ pktl->pkt.stream_index ]) == 0)            stream_count--;        av_free_packet(&pktl->pkt);        av_freep(&pktl);                if(ret<0)            return ret;    }    return 0;}