From 3bbaa159a64b4d1108fb3242bc40b3ffb7215f30 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sat, 18 Apr 2020 19:22:36 +0800 Subject: [PATCH] improve hevc detection logic --- src/App.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index ba6fd62c..8cf9f3cf 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -97,10 +97,13 @@ const dragPreventer = ev => { ev.preventDefault(); }; +// With these codecs, the player will not give a playback error, but instead only play audio function doesPlayerSupportFile(streams) { - // TODO improve, whitelist supported codecs instead - return !streams.find(s => ['hevc', 'prores'].includes(s.codec_name)); - // return true; + const videoStreams = streams.filter(s => s.codec_type === 'video'); + // Don't check audio formats, assume all is OK + if (videoStreams.length === 0) return true; + // If we have at least one video that is NOT of the unsupported formats, assume the player will be able to play it natively + return videoStreams.some(s => !['hevc', 'prores'].includes(s.codec_name)); } const ffmpegExtractWindow = 60; @@ -1121,6 +1124,7 @@ const App = memo(() => { const existing = getHtml5ifiedPath(cod, fp, speed); const ret = existing && await exists(existing); if (ret) { + console.log('Found existing friendly file', existing); setHtml5FriendlyPath(existing); showUnsupportedFileMessage(); }