+ getYoutubeDLVideoFormat () {
+ /**
+ * list of format selectors in order or preference
+ * see https://github.com/ytdl-org/youtube-dl#format-selection
+ *
+ * case #1 asks for a mp4 using h264 (avc1) and the exact resolution in the hope
+ * of being able to do a "quick-transcode"
+ * case #2 is the first fallback. No "quick-transcode" means we can get anything else (like vp9)
+ * case #3 is the resolution-degraded equivalent of #1, and already a pretty safe fallback
+ *
+ * in any case we avoid AV1, see https://github.com/Chocobozzz/PeerTube/issues/3499
+ **/
+ const resolution = this.enabledResolutions.length === 0
+ ? VideoResolution.H_720P
+ : Math.max(...this.enabledResolutions)
+
+ return [
+ `bestvideo[vcodec^=avc1][height=${resolution}]+bestaudio[ext=m4a]`, // case #1
+ `bestvideo[vcodec!*=av01][vcodec!*=vp9.2][height=${resolution}]+bestaudio`, // case #2
+ `bestvideo[vcodec^=avc1][height<=${resolution}]+bestaudio[ext=m4a]`, // case #3
+ `bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio`,
+ 'best[vcodec!*=av01][vcodec!*=vp9.2]', // case fallback for known formats
+ 'best' // Ultimate fallback
+ ].join('/')
+ }