- 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, 16); /* FIXME: estimation */
-
- /* main header */
- put_le64(bc, 1); /* FIXME: unique 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_padding(nut, bc);
- put_le32(bc, 0); /* FIXME: checksum */
-
- /* stream headers */
- for (i = 0; i < s->nb_streams; i++)
- {
- codec = &s->streams[i]->codec;
-
- put_packetheader(nut, bc, 64); /* FIXME: estimation */
- put_le64(bc, 1); /* FIXME: unique 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_le32(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_le32(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_padding(nut, bc);
- put_le32(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_padding(nut, bc);
- put_le32(bc, 0); /* FIXME: checksum */
- break;
- }
- }
-
-#if 0
- /* info header */
- put_packetheader(nut, bc, 16+strlen(s->author)+strlen(s->title)+
- strlen(s->comment)+strlen(s->copyright)); /* FIXME: estimation */
- put_le64(bc, 1); /* FIXME: unique startcode */
- if (s->author[0])
- {
- put_v(bc, 5); /* type */
- put_b(bc, s->author, strlen(s->author));