duration = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate);
duration = (1000000.0 * st->codec.frame_rate_base / (float)st->codec.frame_rate);
static int ffm_write_packet(AVFormatContext *s, int stream_index,                            uint8_t *buf, int size, int force_pts){    AVStream *st = s->streams[stream_index];    FFMStream *fst = st->priv_data;    int64_t pts;    uint8_t header[FRAME_HEADER_SIZE];    int duration;    if (st->codec.codec_type == CODEC_TYPE_AUDIO) {        duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0);    } else {        duration = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate);    }    pts = fst->pts;    /* packet size & key_frame */    header[0] = stream_index;    header[1] = 0;    if (st->codec.coded_frame->key_frame) //if st->codec.coded_frame==NULL then there is a bug somewhere else        header[1] |= FLAG_KEY_FRAME;    header[2] = (size >> 16) & 0xff;    header[3] = (size >> 8) & 0xff;    header[4] = size & 0xff;    header[5] = (duration >> 16) & 0xff;    header[6] = (duration >> 8) & 0xff;    header[7] = duration & 0xff;    ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);    ffm_write_data(s, buf, size, pts, 0);    fst->pts += duration;    return 0;}