put_b(bc, LIBAVFORMAT_IDENT, strlen(LIBAVFORMAT_IDENT));
put_b(bc, LIBAVFORMAT_IDENT "\0", strlen(LIBAVFORMAT_IDENT));  put_v(bc, 0);
static int nut_write_header(AVFormatContext *s){    NUTContext *nut = s->priv_data;    ByteIOContext *bc = &s->pb;    AVCodecContext *codec;    int i;    int stream_length = 0;    for (i = 0; i < s->nb_streams; i++)    {	if (stream_length < (s->streams[i]->duration * (AV_TIME_BASE / 1000)))	    stream_length = s->streams[i]->duration * (AV_TIME_BASE / 1000);    }    put_packetheader(nut, bc, 120);        /* main header */    put_be64(bc, MAIN_STARTCODE);    put_v(bc, 0); /* version */    put_v(bc, s->nb_streams);    put_v(bc, 0); /* file size */    put_v(bc, stream_length); /* len in msec */    put_be32(bc, 0); /* FIXME: checksum */        update_packetheader(nut, bc, 0);        /* stream headers */    for (i = 0; i < s->nb_streams; i++)    {	codec = &s->streams[i]->codec;		put_packetheader(nut, bc, 120);	put_be64(bc, STREAM_STARTCODE);	put_v(bc, s->streams[i]->index);	put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0);	if (codec->codec_tag)	    put_b(bc, &codec->codec_tag, 4);	else if (codec->codec_type == CODEC_TYPE_VIDEO)	{	    int tmp = codec_get_bmp_tag(codec->codec_id);	    put_b(bc, &tmp, 4);//	    put_v(bc, 4); /* len *///	    put_be32(bc, codec_get_bmp_tag(codec->codec_id));	}	else if (codec->codec_type == CODEC_TYPE_AUDIO)	{	    int tmp = codec_get_wav_tag(codec->codec_id);	    put_b(bc, &tmp, 4);//	    put_v(bc, 4); /* len *///	    put_be32(bc, codec_get_wav_tag(codec->codec_id));	}	put_v(bc, codec->bit_rate);	put_v(bc, 0); /* no language code */	put_v(bc, codec->frame_rate_base);	put_v(bc, codec->frame_rate);	put_v(bc, 0); /* timestamp_shift */	put_v(bc, 0); /* shuffle type */	put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */		put_v(bc, 0); /* no codec specific headers */		switch(codec->codec_type)	{	    case CODEC_TYPE_AUDIO:		put_v(bc, codec->sample_rate / (double)(codec->frame_rate_base / codec->frame_rate));		put_v(bc, codec->channels);		put_be32(bc, 0); /* FIXME: checksum */		break;	    case CODEC_TYPE_VIDEO:		put_v(bc, codec->width);		put_v(bc, codec->height);		put_v(bc, 0); /* aspected w */		put_v(bc, 0); /* aspected h */		put_v(bc, 0); /* csp type -- unknown */		put_be32(bc, 0); /* FIXME: checksum */		break;	}        update_packetheader(nut, bc, 0);    }#if 0    /* info header */    put_packetheader(nut, bc, 16+strlen(s->author)+strlen(s->title)+        strlen(s->comment)+strlen(s->copyright));     put_be64(bc, INFO_STARTCODE);    if (s->author[0])    {        put_v(bc, 5); /* type */        put_b(bc, s->author, strlen(s->author));    }    if (s->title[0])    {        put_v(bc, 6); /* type */        put_b(bc, s->title, strlen(s->title));    }    if (s->comment[0])    {        put_v(bc, 7); /* type */        put_b(bc, s->comment, strlen(s->comment));    }    if (s->copyright[0])    {        put_v(bc, 8); /* type */        put_b(bc, s->copyright, strlen(s->copyright));    }    /* encoder */    put_v(bc, 9); /* type */    put_b(bc, LIBAVFORMAT_IDENT, strlen(LIBAVFORMAT_IDENT));    put_be32(bc, 0); /* FIXME: checksum */    update_packetheader(nut, bc, 0);#endif            put_flush_packet(bc);        return 0;}