int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov)
static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov)
int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov){    int pos, size = 8, i;    pos = url_ftell(pb);    put_be32(pb, 0); /* size placeholder*/    put_tag(pb, "moov");    mov->timescale = globalTimescale;    for (i=0; i<MAX_STREAMS; i++) {        if(mov->tracks[i].entry > 0) {            if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) {                mov->tracks[i].timescale = globalTimescale;                mov->tracks[i].sampleDelta = mov->tracks[i].frameDuration =                    globalTimescale*mov->tracks[i].enc->frame_rate_base/mov->tracks[i].enc->frame_rate;            }            else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) {                /* If AMR, track timescale = 8000, AMR_WB = 16000 */                if(mov->tracks[i].enc->codec_id == CODEC_ID_AMR_NB) {                    mov->tracks[i].frameDuration = 20;                    mov->tracks[i].sampleDelta = 160;                    mov->tracks[i].timescale = 8000;                }                else {                    mov->tracks[i].timescale = globalTimescale;                    mov->tracks[i].frameDuration =                    globalTimescale*mov->tracks[i].enc->frame_rate_base/mov->tracks[i].enc->frame_rate;                }            }            mov->tracks[i].time = mov->time;            mov->tracks[i].trackID = i+1;        }    }    size += mov_write_mvhd_tag(pb, mov);    //size += mov_write_iods_tag(pb, mov);    for (i=0; i<MAX_STREAMS; i++) {        if(mov->tracks[i].entry > 0) {            size += mov_write_trak_tag(pb, &(mov->tracks[i]));        }    }    writeSize (pb, pos, size);    return size;}