2020-08-14 08:46:34 +02:00
|
|
|
import 'jquery';
|
|
|
|
import loading from '../../components/loading/loading';
|
|
|
|
import globalize from '../../scripts/globalize';
|
|
|
|
import dom from '../../scripts/dom';
|
|
|
|
import libraryMenu from '../../scripts/libraryMenu';
|
2022-04-10 02:22:13 -04:00
|
|
|
import Dashboard from '../../utils/dashboard';
|
2020-10-18 15:18:15 +01:00
|
|
|
import alert from '../../components/alert';
|
2020-07-09 11:22:21 +01:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function loadPage(page, config, systemInfo) {
|
|
|
|
Array.prototype.forEach.call(page.querySelectorAll('.chkDecodeCodec'), function (c) {
|
|
|
|
c.checked = (config.HardwareDecodingCodecs || []).indexOf(c.getAttribute('data-codec')) !== -1;
|
|
|
|
});
|
|
|
|
page.querySelector('#chkDecodingColorDepth10Hevc').checked = config.EnableDecodingColorDepth10Hevc;
|
|
|
|
page.querySelector('#chkDecodingColorDepth10Vp9').checked = config.EnableDecodingColorDepth10Vp9;
|
|
|
|
page.querySelector('#chkEnhancedNvdecDecoder').checked = config.EnableEnhancedNvdecDecoder;
|
|
|
|
page.querySelector('#chkSystemNativeHwDecoder').checked = config.PreferSystemNativeHwDecoder;
|
|
|
|
page.querySelector('#chkIntelLpH264HwEncoder').checked = config.EnableIntelLowPowerH264HwEncoder;
|
|
|
|
page.querySelector('#chkIntelLpHevcHwEncoder').checked = config.EnableIntelLowPowerHevcHwEncoder;
|
|
|
|
page.querySelector('#chkHardwareEncoding').checked = config.EnableHardwareEncoding;
|
|
|
|
page.querySelector('#chkAllowHevcEncoding').checked = config.AllowHevcEncoding;
|
|
|
|
$('#selectVideoDecoder', page).val(config.HardwareAccelerationType);
|
|
|
|
$('#selectThreadCount', page).val(config.EncodingThreadCount);
|
|
|
|
page.querySelector('#chkEnableAudioVbr').checked = config.EnableAudioVbr;
|
|
|
|
$('#txtDownMixAudioBoost', page).val(config.DownMixAudioBoost);
|
|
|
|
$('#selectStereoDownmixAlgorithm').val(config.DownMixStereoAlgorithm || 'None');
|
|
|
|
page.querySelector('#txtMaxMuxingQueueSize').value = config.MaxMuxingQueueSize || '';
|
|
|
|
page.querySelector('.txtEncoderPath').value = config.EncoderAppPathDisplay || '';
|
|
|
|
$('#txtTranscodingTempPath', page).val(systemInfo.TranscodingTempPath || '');
|
|
|
|
page.querySelector('#txtFallbackFontPath').value = config.FallbackFontPath || '';
|
|
|
|
page.querySelector('#chkEnableFallbackFont').checked = config.EnableFallbackFont;
|
|
|
|
$('#txtVaapiDevice', page).val(config.VaapiDevice || '');
|
|
|
|
page.querySelector('#chkTonemapping').checked = config.EnableTonemapping;
|
|
|
|
page.querySelector('#chkVppTonemapping').checked = config.EnableVppTonemapping;
|
|
|
|
page.querySelector('#selectTonemappingAlgorithm').value = config.TonemappingAlgorithm;
|
2023-04-14 18:50:24 +08:00
|
|
|
page.querySelector('#selectTonemappingMode').value = config.TonemappingMode;
|
2023-04-19 01:56:05 -04:00
|
|
|
page.querySelector('#selectTonemappingRange').value = config.TonemappingRange;
|
|
|
|
page.querySelector('#txtTonemappingDesat').value = config.TonemappingDesat;
|
|
|
|
page.querySelector('#txtTonemappingPeak').value = config.TonemappingPeak;
|
|
|
|
page.querySelector('#txtTonemappingParam').value = config.TonemappingParam || '';
|
|
|
|
page.querySelector('#txtVppTonemappingBrightness').value = config.VppTonemappingBrightness;
|
|
|
|
page.querySelector('#txtVppTonemappingContrast').value = config.VppTonemappingContrast;
|
|
|
|
page.querySelector('#selectEncoderPreset').value = config.EncoderPreset || '';
|
|
|
|
page.querySelector('#txtH264Crf').value = config.H264Crf || '';
|
|
|
|
page.querySelector('#txtH265Crf').value = config.H265Crf || '';
|
|
|
|
page.querySelector('#selectDeinterlaceMethod').value = config.DeinterlaceMethod || '';
|
|
|
|
page.querySelector('#chkDoubleRateDeinterlacing').checked = config.DeinterlaceDoubleRate;
|
|
|
|
page.querySelector('#chkEnableSubtitleExtraction').checked = config.EnableSubtitleExtraction || false;
|
|
|
|
page.querySelector('#chkEnableThrottling').checked = config.EnableThrottling || false;
|
2023-06-15 20:30:56 +02:00
|
|
|
page.querySelector('#chkEnableSegmentDeletion').checked = config.EnableSegmentDeletion || false;
|
|
|
|
page.querySelector('#txtThrottleDelaySeconds').value = config.ThrottleDelaySeconds || '';
|
|
|
|
page.querySelector('#txtSegmentKeepSeconds').value = config.SegmentKeepSeconds || '';
|
2023-04-19 01:56:05 -04:00
|
|
|
page.querySelector('#selectVideoDecoder').dispatchEvent(new CustomEvent('change', {
|
|
|
|
bubbles: true
|
|
|
|
}));
|
|
|
|
loading.hide();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function onSaveEncodingPathFailure() {
|
|
|
|
loading.hide();
|
|
|
|
alert(globalize.translate('FFmpegSavePathNotFound'));
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function updateEncoder(form) {
|
|
|
|
return ApiClient.getSystemInfo().then(function () {
|
|
|
|
return ApiClient.ajax({
|
|
|
|
url: ApiClient.getUrl('System/MediaEncoder/Path'),
|
|
|
|
type: 'POST',
|
|
|
|
data: JSON.stringify({
|
|
|
|
Path: form.querySelector('.txtEncoderPath').value,
|
|
|
|
PathType: 'Custom'
|
|
|
|
}),
|
|
|
|
contentType: 'application/json'
|
|
|
|
}).then(Dashboard.processServerConfigurationUpdateResult, onSaveEncodingPathFailure);
|
|
|
|
});
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function onSubmit() {
|
|
|
|
const form = this;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
const onDecoderConfirmed = function () {
|
|
|
|
loading.show();
|
|
|
|
ApiClient.getNamedConfiguration('encoding').then(function (config) {
|
|
|
|
config.EnableAudioVbr = form.querySelector('#chkEnableAudioVbr').checked;
|
|
|
|
config.DownMixAudioBoost = $('#txtDownMixAudioBoost', form).val();
|
|
|
|
config.DownMixStereoAlgorithm = $('#selectStereoDownmixAlgorithm', form).val() || 'None';
|
|
|
|
config.MaxMuxingQueueSize = form.querySelector('#txtMaxMuxingQueueSize').value;
|
|
|
|
config.TranscodingTempPath = $('#txtTranscodingTempPath', form).val();
|
|
|
|
config.FallbackFontPath = form.querySelector('#txtFallbackFontPath').value;
|
|
|
|
config.EnableFallbackFont = form.querySelector('#txtFallbackFontPath').value ? form.querySelector('#chkEnableFallbackFont').checked : false;
|
|
|
|
config.EncodingThreadCount = $('#selectThreadCount', form).val();
|
|
|
|
config.HardwareAccelerationType = $('#selectVideoDecoder', form).val();
|
|
|
|
config.VaapiDevice = $('#txtVaapiDevice', form).val();
|
|
|
|
config.EnableTonemapping = form.querySelector('#chkTonemapping').checked;
|
|
|
|
config.EnableVppTonemapping = form.querySelector('#chkVppTonemapping').checked;
|
|
|
|
config.TonemappingAlgorithm = form.querySelector('#selectTonemappingAlgorithm').value;
|
2023-04-14 18:50:24 +08:00
|
|
|
config.TonemappingMode = form.querySelector('#selectTonemappingMode').value;
|
2023-04-19 01:56:05 -04:00
|
|
|
config.TonemappingRange = form.querySelector('#selectTonemappingRange').value;
|
|
|
|
config.TonemappingDesat = form.querySelector('#txtTonemappingDesat').value;
|
|
|
|
config.TonemappingPeak = form.querySelector('#txtTonemappingPeak').value;
|
|
|
|
config.TonemappingParam = form.querySelector('#txtTonemappingParam').value || '0';
|
|
|
|
config.VppTonemappingBrightness = form.querySelector('#txtVppTonemappingBrightness').value;
|
|
|
|
config.VppTonemappingContrast = form.querySelector('#txtVppTonemappingContrast').value;
|
|
|
|
config.EncoderPreset = form.querySelector('#selectEncoderPreset').value;
|
|
|
|
config.H264Crf = parseInt(form.querySelector('#txtH264Crf').value || '0', 10);
|
|
|
|
config.H265Crf = parseInt(form.querySelector('#txtH265Crf').value || '0', 10);
|
|
|
|
config.DeinterlaceMethod = form.querySelector('#selectDeinterlaceMethod').value;
|
|
|
|
config.DeinterlaceDoubleRate = form.querySelector('#chkDoubleRateDeinterlacing').checked;
|
|
|
|
config.EnableSubtitleExtraction = form.querySelector('#chkEnableSubtitleExtraction').checked;
|
|
|
|
config.EnableThrottling = form.querySelector('#chkEnableThrottling').checked;
|
2023-06-15 20:30:56 +02:00
|
|
|
config.EnableSegmentDeletion = form.querySelector('#chkEnableSegmentDeletion').checked;
|
2023-06-20 12:46:38 +02:00
|
|
|
config.ThrottleDelaySeconds = parseInt(form.querySelector('#txtThrottleDelaySeconds').value || '0', 10);
|
|
|
|
config.SegmentKeepSeconds = parseInt(form.querySelector('#txtSegmentKeepSeconds').value || '0', 10);
|
2023-04-19 01:56:05 -04:00
|
|
|
config.HardwareDecodingCodecs = Array.prototype.map.call(Array.prototype.filter.call(form.querySelectorAll('.chkDecodeCodec'), function (c) {
|
|
|
|
return c.checked;
|
|
|
|
}), function (c) {
|
|
|
|
return c.getAttribute('data-codec');
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
config.EnableDecodingColorDepth10Hevc = form.querySelector('#chkDecodingColorDepth10Hevc').checked;
|
|
|
|
config.EnableDecodingColorDepth10Vp9 = form.querySelector('#chkDecodingColorDepth10Vp9').checked;
|
|
|
|
config.EnableEnhancedNvdecDecoder = form.querySelector('#chkEnhancedNvdecDecoder').checked;
|
|
|
|
config.PreferSystemNativeHwDecoder = form.querySelector('#chkSystemNativeHwDecoder').checked;
|
|
|
|
config.EnableIntelLowPowerH264HwEncoder = form.querySelector('#chkIntelLpH264HwEncoder').checked;
|
|
|
|
config.EnableIntelLowPowerHevcHwEncoder = form.querySelector('#chkIntelLpHevcHwEncoder').checked;
|
|
|
|
config.EnableHardwareEncoding = form.querySelector('#chkHardwareEncoding').checked;
|
|
|
|
config.AllowHevcEncoding = form.querySelector('#chkAllowHevcEncoding').checked;
|
|
|
|
ApiClient.updateNamedConfiguration('encoding', config).then(function () {
|
|
|
|
updateEncoder(form);
|
|
|
|
}, function () {
|
|
|
|
alert(globalize.translate('ErrorDefault'));
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if ($('#selectVideoDecoder', form).val()) {
|
|
|
|
alert({
|
|
|
|
title: globalize.translate('TitleHardwareAcceleration'),
|
|
|
|
text: globalize.translate('HardwareAccelerationWarning')
|
|
|
|
}).then(onDecoderConfirmed);
|
|
|
|
} else {
|
|
|
|
onDecoderConfirmed();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
return false;
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function setDecodingCodecsVisible(context, value) {
|
|
|
|
value = value || '';
|
|
|
|
let any;
|
|
|
|
Array.prototype.forEach.call(context.querySelectorAll('.chkDecodeCodec'), function (c) {
|
|
|
|
if (c.getAttribute('data-types').split(',').indexOf(value) === -1) {
|
|
|
|
dom.parentWithTag(c, 'LABEL').classList.add('hide');
|
2019-11-06 13:43:39 +03:00
|
|
|
} else {
|
2023-04-19 01:56:05 -04:00
|
|
|
dom.parentWithTag(c, 'LABEL').classList.remove('hide');
|
|
|
|
any = true;
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
2019-04-03 00:12:02 +01:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (any) {
|
|
|
|
context.querySelector('.decodingCodecsList').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
context.querySelector('.decodingCodecsList').classList.add('hide');
|
2019-08-16 00:25:31 -07:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
}
|
2019-08-16 00:25:31 -07:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function getTabs() {
|
|
|
|
return [{
|
|
|
|
href: '#/encodingsettings.html',
|
|
|
|
name: globalize.translate('Transcoding')
|
|
|
|
}, {
|
|
|
|
href: '#/playbackconfiguration.html',
|
|
|
|
name: globalize.translate('ButtonResume')
|
|
|
|
}, {
|
|
|
|
href: '#/streamingsettings.html',
|
|
|
|
name: globalize.translate('TabStreaming')
|
|
|
|
}];
|
|
|
|
}
|
2021-01-29 18:42:01 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
let systemInfo;
|
|
|
|
function getSystemInfo() {
|
|
|
|
return systemInfo ? Promise.resolve(systemInfo) : ApiClient.getPublicSystemInfo().then(
|
|
|
|
info => {
|
|
|
|
systemInfo = info;
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
$(document).on('pageinit', '#encodingSettingsPage', function () {
|
|
|
|
const page = this;
|
|
|
|
getSystemInfo();
|
|
|
|
page.querySelector('#selectVideoDecoder').addEventListener('change', function () {
|
|
|
|
if (this.value == 'vaapi') {
|
|
|
|
page.querySelector('.fldVaapiDevice').classList.remove('hide');
|
|
|
|
page.querySelector('#txtVaapiDevice').setAttribute('required', 'required');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.fldVaapiDevice').classList.add('hide');
|
|
|
|
page.querySelector('#txtVaapiDevice').removeAttribute('required');
|
|
|
|
}
|
2021-12-24 01:31:12 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (this.value == 'amf' || this.value == 'nvenc' || this.value == 'qsv' || this.value == 'vaapi' || this.value == 'videotoolbox') {
|
|
|
|
page.querySelector('.fld10bitHevcVp9HwDecoding').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.fld10bitHevcVp9HwDecoding').classList.add('hide');
|
|
|
|
}
|
2021-01-25 03:39:53 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (this.value == 'amf' || this.value == 'nvenc' || this.value == 'qsv' || this.value == 'vaapi') {
|
|
|
|
page.querySelector('.tonemappingOptions').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.tonemappingOptions').classList.add('hide');
|
|
|
|
}
|
2021-01-26 03:14:47 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (this.value == 'qsv' || this.value == 'vaapi') {
|
|
|
|
page.querySelector('.fldIntelLp').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.fldIntelLp').classList.add('hide');
|
|
|
|
}
|
2021-12-24 01:31:12 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (systemInfo.OperatingSystem.toLowerCase() === 'linux' && (this.value == 'qsv' || this.value == 'vaapi')) {
|
|
|
|
page.querySelector('.vppTonemappingOptions').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.vppTonemappingOptions').classList.add('hide');
|
|
|
|
}
|
2021-12-24 01:31:12 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (this.value == 'qsv') {
|
|
|
|
page.querySelector('.fldSysNativeHwDecoder').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.fldSysNativeHwDecoder').classList.add('hide');
|
|
|
|
}
|
2020-06-25 16:53:45 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (this.value == 'nvenc') {
|
|
|
|
page.querySelector('.fldEnhancedNvdec').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.fldEnhancedNvdec').classList.add('hide');
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (this.value) {
|
|
|
|
page.querySelector('.hardwareAccelerationOptions').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.hardwareAccelerationOptions').classList.add('hide');
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
setDecodingCodecsVisible(page, this.value);
|
|
|
|
});
|
|
|
|
$('#btnSelectEncoderPath', page).on('click.selectDirectory', function () {
|
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
|
|
|
const picker = new DirectoryBrowser();
|
|
|
|
picker.show({
|
|
|
|
includeFiles: true,
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
$('.txtEncoderPath', page).val(path);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2023-04-19 01:56:05 -04:00
|
|
|
|
|
|
|
picker.close();
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
$('#btnSelectTranscodingTempPath', page).on('click.selectDirectory', function () {
|
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
|
|
|
const picker = new DirectoryBrowser();
|
|
|
|
picker.show({
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
$('#txtTranscodingTempPath', page).val(path);
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true,
|
|
|
|
header: globalize.translate('HeaderSelectTranscodingPath'),
|
|
|
|
instruction: globalize.translate('HeaderSelectTranscodingPathHelp')
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
$('#btnSelectFallbackFontPath', page).on('click.selectDirectory', function () {
|
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
|
|
|
const picker = new DirectoryBrowser();
|
|
|
|
picker.show({
|
|
|
|
includeDirectories: true,
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
page.querySelector('#txtFallbackFontPath').value = path;
|
|
|
|
}
|
2020-07-24 21:55:33 +08:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
header: globalize.translate('HeaderSelectFallbackFontPath'),
|
|
|
|
instruction: globalize.translate('HeaderSelectFallbackFontPathHelp')
|
2020-07-24 21:55:33 +08:00
|
|
|
});
|
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
$('.encodingSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
}).on('pageshow', '#encodingSettingsPage', function () {
|
|
|
|
loading.show();
|
|
|
|
libraryMenu.setTabs('playback', 0, getTabs);
|
|
|
|
const page = this;
|
|
|
|
ApiClient.getNamedConfiguration('encoding').then(function (config) {
|
|
|
|
ApiClient.getSystemInfo().then(function (fetchedSystemInfo) {
|
|
|
|
loadPage(page, config, fetchedSystemInfo);
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
2020-07-09 11:22:21 +01:00
|
|
|
|