fix(player): keep 4K HEVC playback off the software encoder
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Use an HLS fMP4 profile that copies compatible HEVC video and transcodes only the audio, so servers without hardware acceleration no longer stall on a 4K H.264 transcode. Add an auto/1080p/720p/480p quality selector and restart playback at the same position when the profile changes.
This commit is contained in:
1 parent
a390df82e9
commit
c2ec314b39
7 files changed
+491
-38
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { toNumber } from "lodash";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, {
|
||||
type ChangeEventHandler,
|
||||
useCallback,
|
||||
@@ -18,15 +19,23 @@ import React, {
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import {
|
||||
getAutoSkipSegments,
|
||||
getPlaybackQuality,
|
||||
setAutoSkipSegments,
|
||||
} from "@/utils/storage/player";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
changeAudioTrack,
|
||||
changePlaybackQuality,
|
||||
changeSubtitleTrack,
|
||||
usePlaybackStore,
|
||||
} from "@/utils/store/playback";
|
||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
||||
import {
|
||||
DEFAULT_PLAYBACK_QUALITY,
|
||||
isPlaybackQualityPreset,
|
||||
PLAYBACK_QUALITY_OPTIONS,
|
||||
type PlaybackQualityPreset,
|
||||
} from "@/utils/types/playbackQuality";
|
||||
|
||||
type VideoPlayerSettingsMenuProps = {
|
||||
settingsMenuRef: HTMLButtonElement | null;
|
||||
@@ -42,6 +51,7 @@ const VideoPlayerSettingsMenu = ({
|
||||
}, [settingsMenuRef]);
|
||||
|
||||
const api = useApiInContext((state) => state.api);
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const {
|
||||
mediaSource,
|
||||
@@ -92,6 +102,39 @@ const VideoPlayerSettingsMenu = ({
|
||||
});
|
||||
};
|
||||
|
||||
const [quality, setQuality] = useState<PlaybackQualityPreset>(
|
||||
DEFAULT_PLAYBACK_QUALITY,
|
||||
);
|
||||
const [qualityIsChanging, setQualityIsChanging] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
getPlaybackQuality().then((savedQuality) => {
|
||||
if (!cancelled) setQuality(savedQuality);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleQualityChange: ChangeEventHandler<
|
||||
HTMLInputElement | HTMLTextAreaElement
|
||||
> = (e) => {
|
||||
const nextQuality = e.target.value;
|
||||
if (!api || !isPlaybackQualityPreset(nextQuality)) return;
|
||||
|
||||
setQuality(nextQuality);
|
||||
setQualityIsChanging(true);
|
||||
changePlaybackQuality(nextQuality, api)
|
||||
.then(() => handleClose())
|
||||
.catch((error) => {
|
||||
enqueueSnackbar(`Не удалось изменить качество: ${error}`, {
|
||||
variant: "error",
|
||||
});
|
||||
})
|
||||
.finally(() => setQualityIsChanging(false));
|
||||
};
|
||||
|
||||
const [subtitleIsChanging, startSubtitleChange] = useTransition();
|
||||
const handleSubtitleChange: ChangeEventHandler<
|
||||
HTMLInputElement | HTMLTextAreaElement
|
||||
@@ -154,6 +197,21 @@ const VideoPlayerSettingsMenu = ({
|
||||
horizontal: "right",
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
select
|
||||
label="Качество"
|
||||
variant="outlined"
|
||||
value={quality}
|
||||
onChange={handleQualityChange}
|
||||
fullWidth
|
||||
disabled={qualityIsChanging}
|
||||
>
|
||||
{PLAYBACK_QUALITY_OPTIONS.map((option) => (
|
||||
<MenuItem key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
<TextField
|
||||
select
|
||||
label="Аудио"
|
||||
|
||||
Reference in new issue
Block a user