serenity-rs / songbird

An async Rust library for the Discord voice API
ISC License
384 stars 110 forks source link

Input: Fix audio stream selection for video files. #150

Closed FelixMcFelix closed 2 years ago

FelixMcFelix commented 2 years ago

youtube-dl has a tendency to return mp4 files containing video and audio data vs yt-dlp. Naturally, the default stream in such cases will be the video data, so we fail to create a decoder.

This PR changes LiveInput::promote to first attempt to instantiate a decoder for the default track. If this fails to do so, then we reattempt this for all available tracks until one can be found. Previously, this method chose the default (or first available) track ID, and then failed if that track could not be decoded even if a compatible stream existed.

This was tested using cargo make ready, as well as manually verifying and adding a test case with a simple mp4 file.