diff --git a/src/components/downloadOptionsDialog/downloadOptionsDialog.js b/src/components/downloadOptionsDialog/downloadOptionsDialog.js index a6f9bb0882..647cd34c8a 100644 --- a/src/components/downloadOptionsDialog/downloadOptionsDialog.js +++ b/src/components/downloadOptionsDialog/downloadOptionsDialog.js @@ -13,29 +13,31 @@ let currentItem; let currentApiClient; function getBitrateOptionsForResolutionAndCodec(resolution, codec) { - // Codec efficiency factors based on reference tables + // Codec efficiency factors based on real-world performance const codecFactors = { 'h264': 1.0, 'hevc': 0.6, // 40% more efficient 'vp9': 0.6, // 40% more efficient - 'av1': 0.5 // 50% more efficient + 'av1': 0.55 // 45% more efficient }; - // Base bitrate ranges for H.264 (30fps SDR) + // Base bitrate ranges for H.264 (updated for 2025 standards) const baseRanges = { - '3840': { min: 28000000, max: 50000000, label: '4K' }, // 4K - '2560': { min: 13500000, max: 28000000, label: '1440p' }, // 1440p - '1920': { min: 6000000, max: 13500000, label: '1080p' }, // 1080p - '1280': { min: 3000000, max: 6000000, label: '720p' }, // 720p - '640': { min: 365000, max: 730000, label: '480p' }, // 480p + '3840': { min: 25000000, max: 80000000, label: '4K' }, // 25-80 Mbps + '2560': { min: 12000000, max: 35000000, label: '1440p' }, // 12-35 Mbps + '1920': { min: 5000000, max: 16000000, label: '1080p' }, // 5-16 Mbps + '1280': { min: 2500000, max: 8000000, label: '720p' }, // 2.5-8 Mbps + '640': { min: 1000000, max: 2500000, label: '480p' }, // 1-2.5 Mbps 'original': { min: 50000000, max: 120000000, label: 'Original' } }; if (resolution === 'original') { return [ - { bitrate: 120000000, name: 'Maximum' }, + { bitrate: 120000000, name: 'Extreme Quality' }, + { bitrate: 100000000, name: 'Maximum' }, { bitrate: 80000000, name: 'High' }, - { bitrate: 50000000, name: 'Medium' } + { bitrate: 60000000, name: 'Medium' }, + { bitrate: 50000000, name: 'Standard' } ]; } @@ -44,11 +46,15 @@ function getBitrateOptionsForResolutionAndCodec(resolution, codec) { const min = Math.round(range.min * factor); const max = Math.round(range.max * factor); - const recommended = Math.round((min + max) / 2); + const step = (max - min) / 5; + // Generate 6 quality levels return [ { bitrate: max, name: `Maximum (${range.label})` }, - { bitrate: recommended, name: `Recommended (${range.label})` }, + { bitrate: Math.round(max - step), name: `Very High (${range.label})` }, + { bitrate: Math.round(max - step * 2), name: `High (${range.label})` }, + { bitrate: Math.round(max - step * 3), name: `Medium (${range.label})` }, + { bitrate: Math.round(max - step * 4), name: `Low (${range.label})` }, { bitrate: min, name: `Minimum (${range.label})` } ]; } @@ -69,7 +75,7 @@ function populateQualityOptions(dlg, item) { const options = getBitrateOptionsForResolutionAndCodec(resolution, codec); selectQuality.innerHTML = options.map((option, index) => { - const selected = index === 1 ? ' selected' : ''; // Select "Recommended" + const selected = index === 2 ? ' selected' : ''; // Select "High" (3rd option) const mbps = (option.bitrate / 1000000).toFixed(1); return ``; }).join(''); @@ -95,36 +101,49 @@ function populateAudioTracks(dlg, item) { } function getRecommendedAudioBitrate(codec, channels) { - // Recommended bitrates based on codec and channel count + // Recommended bitrates based on codec and channel count (2025 standards) const bitrates = { 'aac': { - 2: 192000, // Stereo - 6: 448000, // 5.1 - 8: 640000 // 7.1 + 2: 192000, // Stereo - transparent quality + 6: 256000, // 5.1 - Netflix/streaming standard + 8: 384000 // 7.1 - high quality }, 'ac3': { - 2: 192000, - 6: 448000, // Dolby Digital standard - 8: 640000 + 2: 192000, // Stereo + 6: 448000, // 5.1 - Dolby Digital standard (fixed at 448k) + 8: 640000 // 7.1 - Dolby Digital spec maximum }, 'eac3': { - 2: 192000, - 6: 448000, - 8: 768000 + 2: 224000, // Stereo - DD+ improved quality + 6: 384000, // 5.1 - DD+ standard + 8: 768000 // 7.1 - DD+ maximum }, 'opus': { - 2: 128000, - 6: 320000, - 8: 450000 + 2: 128000, // Stereo - excellent quality (Opus is very efficient) + 6: 256000, // 5.1 - high quality + 8: 384000 // 7.1 - very high quality }, 'mp3': { - 2: 320000, - 6: 320000, - 8: 320000 + 2: 192000, // Stereo - "very high quality" (320k is overkill) + 6: 192000, // Downmix to stereo (MP3 doesn't support multichannel) + 8: 192000 // Downmix to stereo } }; - return bitrates[codec]?.[channels] || bitrates[codec]?.[2] || 320000; + return bitrates[codec]?.[channels] || bitrates[codec]?.[2] || 192000; +} + +function getMaxAudioBitrate(codec) { + // Maximum sensible bitrates per codec + const maxBitrates = { + 'aac': 512000, // AAC practical max for 7.1 + 'ac3': 640000, // AC3 spec maximum + 'eac3': 1536000, // E-AC3 spec maximum (Atmos capable) + 'opus': 510000, // Opus practical max (very efficient) + 'mp3': 320000 // MP3 spec maximum + }; + + return maxBitrates[codec] || 640000; } function updateAudioBitrateOptions(dlg) { @@ -145,16 +164,7 @@ function updateAudioBitrateOptions(dlg) { audioBitrateContainer.style.display = 'block'; } - // Codec-specific maximum bitrates (in bps) - const codecMaxBitrates = { - 'mp3': 320000, // MP3 spec maximum - 'aac': 640000, // Practical max for multi-channel AAC - 'ac3': 640000, // Dolby Digital maximum - 'eac3': 768000, // Dolby Digital Plus practical max - 'opus': 512000 // Opus practical max (very efficient) - }; - - const maxBitrate = codecMaxBitrates[codec] || 768000; + const maxBitrate = getMaxAudioBitrate(codec); const recommendedBitrate = getRecommendedAudioBitrate(codec, channels); // Filter and update bitrate options based on codec diff --git a/src/components/downloadOptionsDialog/downloadOptionsDialog.template.html b/src/components/downloadOptionsDialog/downloadOptionsDialog.template.html index adfc8f2457..aa19b73a11 100644 --- a/src/components/downloadOptionsDialog/downloadOptionsDialog.template.html +++ b/src/components/downloadOptionsDialog/downloadOptionsDialog.template.html @@ -62,17 +62,23 @@