Update to better hand h265 / x265 encoded files.

This commit is contained in:
Brian McGonagill 2026-03-13 08:48:02 -05:00
parent 0e10143b5c
commit cdd27043a2
3 changed files with 101 additions and 12 deletions

View file

@ -272,11 +272,19 @@ function showScanStatus(msg, type) {
function renderFileTable(files) {
let html = '';
files.forEach((f, idx) => {
const sizeFmt = f.size_gb.toFixed(3);
const sizeFmt = f.size_gb.toFixed(3);
const curBitrate = f.bit_rate_mbps ? `${f.bit_rate_mbps} Mbps` : 'Unknown';
const tgtBitrate = f.target_bit_rate_mbps ? `${f.target_bit_rate_mbps} Mbps` : '—';
const codec = f.codec || 'unknown';
const pathDir = f.path.replace(f.name, '');
const codec = (f.codec || 'unknown').toLowerCase();
const pathDir = f.path.replace(f.name, '');
// Normalise codec label and pick a CSS modifier for the badge colour
const isHevc = ['hevc', 'h265', 'x265'].includes(codec);
const isH264 = ['h264', 'avc', 'x264'].includes(codec);
const codecLabel = isHevc ? 'H.265 / HEVC'
: isH264 ? 'H.264 / AVC'
: codec.toUpperCase();
const codecMod = isHevc ? 'hevc' : isH264 ? 'h264' : '';
html += `
<tr id="row-${idx}" data-path="${escHtml(f.path)}">
@ -305,7 +313,7 @@ function renderFileTable(files) {
<span class="bitrate-badge target">${escHtml(tgtBitrate)}</span>
</td>
<td class="col-codec">
<span class="codec-tag">${escHtml(codec)}</span>
<span class="codec-tag ${codecMod}" title="Encoder: ${isHevc ? 'libx265' : 'libx264'}">${escHtml(codecLabel)}</span>
</td>
</tr>`;
});
@ -370,6 +378,7 @@ els.compressBtn.addEventListener('click', async () => {
path: f.path,
size_bytes: f.size_bytes,
target_bit_rate_bps: f.target_bit_rate_bps || 1000000,
codec: f.codec || 'unknown',
})),
suffix,
};