- if (pkt.stream_index >= MAX_STREAMS ||
- format_ctx->streams[pkt.stream_index]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
+
+ AVStream *stream = format_ctx->streams[pkt->stream_index];
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+ audio_stream_to_video_stream_idx.count(pkt->stream_index)) {
+ if ((pkt->size % (sizeof(uint32_t) * 2)) != 0) {
+ fprintf(stderr, "Audio stream %u had a packet of strange length %d, ignoring.\n",
+ pkt->stream_index, pkt->size);
+ } else {
+ // TODO: Endianness?
+ const uint32_t *begin = (const uint32_t *)pkt->data;
+ const uint32_t *end = (const uint32_t *)(pkt->data + pkt->size);
+ pending_audio[audio_stream_to_video_stream_idx[pkt->stream_index]].assign(begin, end);
+ }
+ }
+
+ if (pkt->stream_index >= MAX_STREAMS ||
+ stream->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {