Your statement that, videos that play with good volume always play with good volume, has me baffled. That would put issue with the video and maybe not with the device. It would exclude a setting, experiencing this with headphones also seems to point back to the video.
The only thing I can think of at this point would be the codec and the video format. That would be specific to the video, would allow the same video to play normally every time, or play poorly, and would do this both through headphones, the device speaker or through a Bluetooth speaker. To support this I found this result on Google.
Not all videos on YouTube have the same codec format: [1, 2]
- H.264: The default codec for most videos on YouTube. It's widely supported by browsers and devices. [2]
- VP9: Used for higher resolutions and HDR videos. It offers better compression and quality than H.264. [2]
- AV1: Used for videos with very low view counts. [1]
YouTube also supports other video formats, including: [3, 4]
WMV
FLV
MPEG PS
DNxHR
3GPP
CineForm
WebM
While I haven't run into this in some time, I'm assuming YouTube fixed something, but I remember when some videos would pop-up and refuse to play. They have a notification that said something like, this video is not formatted to play on a mobile device, or just say, this video cannot play on a mobile device. Which was always crazy to me since I was watching videos in the YT mobile app. In this case the video plays fine but maybe your codec is broken or needs an update and is causing this sound issue.
The next logical question would be can you fix or update codecs on your Android device, and Gemini says this;
While you can't directly "update" a codec on your Android phone like you might on a computer, you can effectively fix codec issues by updating your media player app which often includes the latest codec support, or by installing a different media player app that supports the codec you need to play a specific video file; essentially, you're relying on the app to handle the codec functionality rather than directly modifying the system codecs on your phone. [1, 2, 3]
How to "fix" a codec issue on Android: [1, 3]
- Update your current media player: Check for updates within your default media player app. [1, 3]
- Install a different media player: If your current app doesn't support the codec you need, download a different media player app known for wide codec compatibility. [1, 2, 3]
- Convert the video file: If you can't find a media player that supports the codec, consider converting the video file to a format compatible with your device using a video conversion tool. [1, 2, 7]
While there are no guarantees B. Diddy's suggestion may be as close to reloading these codecs as one can get if you are unable to find a way to update your player, or apps with players.
Best wishes. Of course let us know what you find, it may help the next person.