How can I force YouTube to convert my video's audio stream to Opus or Vorbis / Youtube Red issue I know the answer, which is probably "there is no way", but bear with me for a moment. 

I am uploading videos to YouTube, and on my Android phone I am downloading them using YouTube Red. I am playing these downloaded videos in the YouTube app in the background, when the screen is off. This works with the vast majority of the videos, except the ones that I am uploading. I did read the recommended upload formats, I tried several codecs, but no luck. My audios stop the second I am shutting off the screen.

What I finally found using youtube-dl -F is that my videos do not have audio-only streams with webm extension, only as m4a (after Youtube processed them). So my question is: what makes Youtube create webm audio files for some videos, but not for the others? Is there a way to force this (I suppose not). Is there a way to suggest it? As I mentioned, I tried a wide variety of codecs - video and audio, and the combinations - when generating my files for the upload.

A sample output for a file that works with Youtube Red playback in background:

format code  extension  resolution note
249          webm       audio only DASH audio   52k , opus @ 50k, 73.58KiB
250          webm       audio only DASH audio   66k , opus @ 70k, 92.62KiB
251          webm       audio only DASH audio  114k , opus @160k, 161.14KiB
171          webm       audio only DASH audio  115k , vorbis@128k, 161.27KiB
140          m4a        audio only DASH audio  127k , m4a_dash container, mp4a.40.2@128k, 180.79KiB


and the output for one file which does not:

format code  extension  resolution note
139          m4a        audio only DASH audio   49k , m4a_dash container, mp4a.40.5@ 48k (22050Hz), 1.20MiB
140          m4a        audio only DASH audio  129k , m4a_dash container, mp4a.40.2@128k (44100Hz), 3.20MiB
YouTube currently does not have any encoding options for content creators. 

As far as why some videos are encoded as webm and others in different container types, I don't believe there is any documentation on that whatsoever. YouTube may be beta-testing specific codecs, to see how codecs perform/stream for end users, or there may be a specific matching system whereas input = specific output attributes. 

When you upload a video to YouTube, the video is re-encoded using a Variable Bitrate at the highest resolution / matching resolution of the original upload. If the uploaded video is larger => 360p then smaller versions are also encoded for multiple streaming options (240p as an example). 

But there is no current way to force the YouTube encoding platform to encode to a specific codec, and even you were able to figure out what input codec would result in a specific desired output codec, it may only be temporary. I only mention this because YouTube has stated it is currently experimenting with new codecs, including closed source proprietary codecs and encoding algorithms... so what works today may not tomorrow.