Understood. If your aim is to avoid VP9 because of reasons like hardware decoding support, but still want to ensure you get audio with your videos, you'll have to adjust your approach given the constraint of avoiding +bestaudio/best which automatically selects the best audio without influencing the video codec choice.
The challenge here is that YouTube separates video and audio streams for high-quality formats, and by specifying bestvideo without a corresponding audio stream, you're essentially instructing youtube-dl or yt-dlp (and by extension, MPV) to ignore the audio.
Given your situation, here are a couple of strategies you might consider:
Strategy 1: Specifying AVC1 Codec with Audio
If the main goal is to stick to the AVC1 codec for video but ensure audio is included—without inadvertently opting into VP9 video streams—you can try being more explicit about the audio codec you're willing to accept. This might not directly prevent VP9, but you can specify preferences that are more likely to pair with AVC/h.264 video:
ytdl-format=bestvideo[height<=?1080][fps<=?30][vcodec=avc1]+bestaudio[acodec=aac]/best
This command attempts to:
- Choose the best video stream that is 1080p or less, 30 fps or less, specifically using the AVC1 codec.
- Pair it with the best audio stream using the AAC codec, which is a common audio codec used by YouTube.
- Fall back to the best overall if the specific criteria can't be met.
Strategy 2: Using Format Codes
This strategy involves a bit of research but can be very effective in controlling the exact formats you get. YouTube assigns format codes to each of its video and audio streams. By using youtube-dl or yt-dlp directly, you can list the available formats for a particular video with:
youtube-dl -F [video URL]
or for yt-dlp:
yt-dlp -F [video URL]
Once you've identified the format codes for the streams you're interested in (e.g., a specific AVC1 video format and its corresponding best audio format), you can directly specify those in your MPV configuration. For example:
ytdl-format=137+140
Here, 137 could be an example of a 1080p AVC1 video format code, and 140 could be an AAC audio format code. Replace these with the actual format codes based on your requirements and the specific videos you're viewing.
Additional Consideration: Using Scripts or Advanced Options with yt-dlp
Given the complexities in handling various formats and codecs, especially when trying to automate or generalize preferences across different videos, some users opt to utilize more advanced features of yt-dlp (a fork of youtube-dl that's actively maintained and often preferred for its enhancements). This could include writing scripts that parse format options and select based on custom criteria, or exploring yt-dlp's --merge-output-format and postprocessor options to refine how audio and video are combined.
Remember, keeping your media players (MPV), youtube-dl or yt-dlp, and any associated scripts or configurations up to date is crucial for ensuring compatibility and taking advantage of the latest features and fixes.