Ticket #1732: avienc_show_emtied.diff

File avienc_show_emtied.diff, 1.8 KB (added by Andrew, 4 years ago)
  • libavformat/avienc.c

    diff --git a/libavformat/avienc.c b/libavformat/avienc.c
    index ff25d79..6b011be 100644
    a b static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) 
    523523    AVIStream *avist= s->streams[stream_index]->priv_data; 
    524524    AVCodecContext *enc= s->streams[stream_index]->codec; 
    525525    int size= pkt->size; 
     526    int insert_emptied=0; 
     527    static int total_inserted = 0; // FIXME all stream 
    526528 
    527529//    av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %d\n", pkt->dts, avist->packet_count, stream_index); 
    528530    while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count && enc->codec_id != AV_CODEC_ID_XSUB){ 
    529531        AVPacket empty_packet; 
    530532 
    531         if(pkt->dts - avist->packet_count > 60000){ 
     533        if( (pkt->dts - avist->packet_count) > 60000){ 
    532534            av_log(s, AV_LOG_ERROR, "Too large number of skiped frames %"PRId64"\n", pkt->dts - avist->packet_count); 
    533535            return AVERROR(EINVAL); 
    534536        } 
    static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) 
    538540        empty_packet.data= NULL; 
    539541        empty_packet.stream_index= stream_index; 
    540542        avi_write_packet(s, &empty_packet); 
     543        insert_emptied++; 
    541544//        av_log(s, AV_LOG_DEBUG, "dup %"PRId64" %d\n", pkt->dts, avist->packet_count); 
    542545    } 
     546 
     547    if ( insert_emptied > 0 ) { 
     548       total_inserted += insert_emptied; 
     549       av_log(s, AV_LOG_INFO, "%c: insert %d empty pkt, total empty %d from %d, %d%%\n", 
     550             enc->codec_type == AVMEDIA_TYPE_VIDEO ? 'V' : (enc->codec_type == AVMEDIA_TYPE_AUDIO ? 'A' : '?'), 
     551             insert_emptied, 
     552             total_inserted, avist->packet_count, 
     553             (total_inserted * 100) / avist->packet_count); 
     554    } 
    543555    avist->packet_count++; 
    544556 
    545557    // Make sure to put an OpenDML chunk when the file size exceeds the limits