[Bug]: Stream `audio` index isn't checked to be an audio track

Open Beginner friendly
#113 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Start at src/media/stream.rs:153, where the ?audio=N index is taken from the query and used as-is when building the output stream. Read the surrounding function to see how the stream list and codecpar are already available, then check the requested index's codecpar.codec_type against AVMEDIA_TYPE_AUDIO before using it and fall back to the default audio track otherwise. Done when ?audio= pointing at a video, subtitle or out-of-range stream no longer produces a bogus second track or an AAC transcode failure; exercise it against a file whose video is stream 0, as the reproduction steps describe.

Written by the indexing model from the issue text.

Description

bug

[!NOTE]
This issue was written by Claude (Claude Opus 5.5) from a code review session with @PhrolovaMoe. It was found by reading the code and hasn't been reproduced on a running server.

Version

0.40.0 (feat/desktop, 017a837b)

Area

Streaming / playback

What happened?

?audio=N on /api/media/{id}/stream is used as-is (src/media/stream.rs:153). If N is the video stream, the output gets a second track with video codec parameters as audio. If it's a subtitle or attachment stream, the AAC transcode fails. An out-of-range N fails with a generic error.

Steps to reproduce

Request /api/media/<id>/stream?audio=0 for a file whose video is stream 0.

Expected behavior

Indexes that aren't audio streams are rejected (or fall back to the default audio track).

Suggested fix

Check that codecpar.codec_type == AVMEDIA_TYPE_AUDIO for the requested index before using it.

Dominant language
TypeScript
Stars
4
Forks
1
Avg merge
4h 49m
Merged PRs (30d)
5

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tinystream-dev/tinystream

All issues in tinystream-dev/tinystream

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.