- url_fseek(pb, 5, SEEK_CUR);
- vid->nframes = get_le16(pb);
-
- stream = av_new_stream(s, 0);
- if (!stream)
- return AVERROR(ENOMEM);
- av_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps
- stream->codec->codec_type = CODEC_TYPE_VIDEO;
- stream->codec->codec_id = CODEC_ID_BETHSOFTVID;
- stream->codec->width = get_le16(pb);
- stream->codec->height = get_le16(pb);
- stream->codec->pix_fmt = PIX_FMT_PAL8;
- vid->bethsoft_global_delay = get_le16(pb);
- get_le16(pb);
-
- // done with video codec, set up audio codec
- stream = av_new_stream(s, 0);
- if (!stream)
- return AVERROR(ENOMEM);
- stream->codec->codec_type = CODEC_TYPE_AUDIO;
- stream->codec->codec_id = CODEC_ID_PCM_U8;
- stream->codec->channels = 1;
- stream->codec->sample_rate = 11025;
- stream->codec->bits_per_coded_sample = 8;
- stream->codec->bit_rate = stream->codec->channels * stream->codec->sample_rate * stream->codec->bits_per_coded_sample;
+ avio_skip(pb, 5);
+ vid->nframes = avio_rl16(pb);
+ vid->width = avio_rl16(pb);
+ vid->height = avio_rl16(pb);
+ vid->bethsoft_global_delay = avio_rl16(pb);
+ avio_rl16(pb);
+
+ // wait until the first packet to create each stream
+ vid->video_index = -1;
+ vid->audio_index = -1;
+ vid->sample_rate = DEFAULT_SAMPLE_RATE;
+ s->ctx_flags |= AVFMTCTX_NOHEADER;