Revision 30f06a58 libavformat/matroskaenc.c

View differences:

libavformat/matroskaenc.c
725 725
    ret = mkv_write_chapters(s);
726 726
    if (ret < 0) return ret;
727 727

  
728
    ret = mkv_add_seekhead_entry(mkv->cluster_seekhead, MATROSKA_ID_CLUSTER, url_ftell(pb));
729
    if (ret < 0) return ret;
730

  
731
    mkv->cluster_pos = url_ftell(pb);
732
    mkv->cluster = start_ebml_master(pb, MATROSKA_ID_CLUSTER, 0);
733
    put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, 0);
734
    mkv->cluster_pts = 0;
735

  
736 728
    if (url_is_streamed(s->pb))
737 729
        mkv_write_seekhead(pb, mkv->main_seekhead);
738 730

  
......
849 841
    int duration = pkt->duration;
850 842
    int ret;
851 843

  
852
    // start a new cluster every 5 MB or 5 sec
853
    if (url_ftell(pb) > mkv->cluster_pos + 5*1024*1024 || pkt->pts > mkv->cluster_pts + 5000) {
854
        av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64
855
               " bytes, pts %" PRIu64 "\n", url_ftell(pb), pkt->pts);
856
        end_ebml_master(pb, mkv->cluster);
857

  
844
    if (!mkv->cluster_pos) {
858 845
        ret = mkv_add_seekhead_entry(mkv->cluster_seekhead, MATROSKA_ID_CLUSTER, url_ftell(pb));
859 846
        if (ret < 0) return ret;
860 847

  
......
882 869
        if (ret < 0) return ret;
883 870
    }
884 871

  
872
    // start a new cluster every 5 MB or 5 sec
873
    if (url_ftell(pb) > mkv->cluster_pos + 5*1024*1024 || pkt->pts > mkv->cluster_pts + 5000) {
874
        av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64
875
               " bytes, pts %" PRIu64 "\n", url_ftell(pb), pkt->pts);
876
        end_ebml_master(pb, mkv->cluster);
877
        mkv->cluster_pos = 0;
878
    }
879

  
885 880
    mkv->duration = FFMAX(mkv->duration, pkt->pts + duration);
886 881
    return 0;
887 882
}

Also available in: Unified diff