- for (const resolution of resolutions) {
- if (configResolutions[resolution + 'p'] === true && videoFileResolution > resolution) {
- resolutionsEnabled.push(resolution)
- }
+ for (const resolution of availableResolutions) {
+ // Resolution not enabled
+ if (configResolutions[resolution + 'p'] !== true) continue
+ // Too big resolution for input file
+ if (input < resolution) continue
+ // We only want lower resolutions than input file
+ if (strictLower && input === resolution) continue
+ // Audio resolutio but no audio in the video
+ if (resolution === VideoResolution.H_NOVIDEO && !hasAudio) continue
+
+ resolutionsEnabled.add(resolution)
+ }
+
+ if (includeInput) {
+ // Always use an even resolution to avoid issues with ffmpeg
+ resolutionsEnabled.add(toEven(input))