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