static int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track)
{
    MOV_stts_t *stts_entries;
    uint32_t entries = -1;
    uint32_t atom_size;
    int i;
    if (track->enc->codec_type == CODEC_TYPE_AUDIO && !track->audio_vbr) {
        stts_entries = av_malloc(sizeof(*stts_entries));
        stts_entries[0].count = track->sampleCount;
        stts_entries[0].duration = 1;
        entries = 1;
    } else {
        stts_entries = av_malloc(track->entry * sizeof(*stts_entries));
        for (i=0; i<track->entry; i++) {
            int64_t duration = i + 1 == track->entry ?
                track->trackDuration - track->cluster[i].dts + track->cluster[0].dts :
                track->cluster[i+1].dts - track->cluster[i].dts;
            if (i && duration == stts_entries[entries].duration) {
                stts_entries[entries].count++;
            } else {
                entries++;
                stts_entries[entries].duration = duration;
                stts_entries[entries].count = 1;
            }
        }
        entries++;
    }
    atom_size = 16 + (entries * 8);
    put_be32(pb, atom_size);
    put_tag(pb, "stts");
    put_be32(pb, 0);
    put_be32(pb, entries);
    for (i=0; i<entries; i++) {
        put_be32(pb, stts_entries[i].count);
        put_be32(pb, stts_entries[i].duration);
    }
    av_free(stts_entries);
    return atom_size;
}
['static int mov_write_stts_tag(ByteIOContext *pb, MOVTrack* track)\n{\n    MOV_stts_t *stts_entries;\n    uint32_t entries = -1;\n    uint32_t atom_size;\n    int i;\n    if (track->enc->codec_type == CODEC_TYPE_AUDIO && !track->audio_vbr) {\n        stts_entries = av_malloc(sizeof(*stts_entries));\n        stts_entries[0].count = track->sampleCount;\n        stts_entries[0].duration = 1;\n        entries = 1;\n    } else {\n        stts_entries = av_malloc(track->entry * sizeof(*stts_entries));\n        for (i=0; i<track->entry; i++) {\n            int64_t duration = i + 1 == track->entry ?\n                track->trackDuration - track->cluster[i].dts + track->cluster[0].dts :\n                track->cluster[i+1].dts - track->cluster[i].dts;\n            if (i && duration == stts_entries[entries].duration) {\n                stts_entries[entries].count++;\n            } else {\n                entries++;\n                stts_entries[entries].duration = duration;\n                stts_entries[entries].count = 1;\n            }\n        }\n        entries++;\n    }\n    atom_size = 16 + (entries * 8);\n    put_be32(pb, atom_size);\n    put_tag(pb, "stts");\n    put_be32(pb, 0);\n    put_be32(pb, entries);\n    for (i=0; i<entries; i++) {\n        put_be32(pb, stts_entries[i].count);\n        put_be32(pb, stts_entries[i].duration);\n    }\n    av_free(stts_entries);\n    return atom_size;\n}']