while(s->packet_buffer){ int ret; AVPacketList *pktl= s->packet_buffer;   truncate_ts(s->streams[pktl->pkt.stream_index], &pktl->pkt); ret= s->oformat->write_packet(s, &pktl->pkt);  s->packet_buffer= pktl->next;  av_free_packet(&pktl->pkt); av_freep(&pktl);  if(ret<0) return ret; }
int av_write_trailer(AVFormatContext *s){    int ret;    ret = s->oformat->write_trailer(s);    av_freep(&s->priv_data);    return ret;}