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';
|
2020-10-12 23:08:55 +01:00
|
|
|
import Dashboard from '../../scripts/clientUtils';
|
2020-10-18 15:18:15 +01:00
|
|
|
import alert from '../../components/alert';
|
2020-07-09 11:22:21 +01:00
|
|
|
|
|
|
|
/* eslint-disable indent */
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function loadPage(page, config, systemInfo) {
|
2020-05-04 12:44:12 +02:00
|
|
|
Array.prototype.forEach.call(page.querySelectorAll('.chkDecodeCodec'), function (c) {
|
2020-07-30 16:07:13 +02:00
|
|
|
c.checked = (config.HardwareDecodingCodecs || []).indexOf(c.getAttribute('data-codec')) !== -1;
|
2019-03-07 21:19:21 +00:00
|
|
|
});
|
2020-05-29 14:06:02 -04:00
|
|
|
page.querySelector('#chkDecodingColorDepth10Hevc').checked = config.EnableDecodingColorDepth10Hevc;
|
|
|
|
page.querySelector('#chkDecodingColorDepth10Vp9').checked = config.EnableDecodingColorDepth10Vp9;
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#chkHardwareEncoding').checked = config.EnableHardwareEncoding;
|
2020-11-12 20:03:38 +08:00
|
|
|
page.querySelector('#chkAllowHevcEncoding').checked = config.AllowHevcEncoding;
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#selectVideoDecoder', page).val(config.HardwareAccelerationType);
|
|
|
|
$('#selectThreadCount', page).val(config.EncodingThreadCount);
|
|
|
|
$('#txtDownMixAudioBoost', page).val(config.DownMixAudioBoost);
|
2020-08-25 01:57:21 +08:00
|
|
|
page.querySelector('#txtMaxMuxingQueueSize').value = config.MaxMuxingQueueSize || '';
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.txtEncoderPath').value = config.EncoderAppPathDisplay || '';
|
|
|
|
$('#txtTranscodingTempPath', page).val(systemInfo.TranscodingTempPath || '');
|
2020-07-24 21:55:33 +08:00
|
|
|
page.querySelector('#txtFallbackFontPath').value = config.FallbackFontPath || '';
|
|
|
|
page.querySelector('#chkEnableFallbackFont').checked = config.EnableFallbackFont;
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtVaapiDevice', page).val(config.VaapiDevice || '');
|
2020-07-25 15:14:57 +08:00
|
|
|
page.querySelector('#chkTonemapping').checked = config.EnableTonemapping;
|
|
|
|
page.querySelector('#txtOpenclDevice').value = config.OpenclDevice || '';
|
|
|
|
page.querySelector('#selectTonemappingAlgorithm').value = config.TonemappingAlgorithm;
|
|
|
|
page.querySelector('#selectTonemappingRange').value = config.TonemappingRange;
|
|
|
|
page.querySelector('#txtTonemappingDesat').value = config.TonemappingDesat;
|
|
|
|
page.querySelector('#txtTonemappingThreshold').value = config.TonemappingThreshold;
|
|
|
|
page.querySelector('#txtTonemappingPeak').value = config.TonemappingPeak;
|
|
|
|
page.querySelector('#txtTonemappingParam').value = config.TonemappingParam || '';
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#selectEncoderPreset').value = config.EncoderPreset || '';
|
|
|
|
page.querySelector('#txtH264Crf').value = config.H264Crf || '';
|
2020-11-14 03:32:25 +08:00
|
|
|
page.querySelector('#txtH265Crf').value = config.H265Crf || '';
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#selectDeinterlaceMethod').value = config.DeinterlaceMethod || '';
|
2020-08-10 22:10:15 +01:00
|
|
|
page.querySelector('#chkDoubleRateDeinterlacing').checked = config.DeinterlaceDoubleRate;
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#chkEnableSubtitleExtraction').checked = config.EnableSubtitleExtraction || false;
|
|
|
|
page.querySelector('#chkEnableThrottling').checked = config.EnableThrottling || false;
|
|
|
|
page.querySelector('#selectVideoDecoder').dispatchEvent(new CustomEvent('change', {
|
2019-03-08 09:25:45 +00:00
|
|
|
bubbles: true
|
2019-11-06 13:43:39 +03:00
|
|
|
}));
|
|
|
|
loading.hide();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSaveEncodingPathFailure(response) {
|
|
|
|
loading.hide();
|
2020-10-18 15:18:15 +01:00
|
|
|
alert(globalize.translate('FFmpegSavePathNotFound'));
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateEncoder(form) {
|
2019-11-06 13:43:39 +03:00
|
|
|
return ApiClient.getSystemInfo().then(function (systemInfo) {
|
2018-10-23 01:05:09 +03:00
|
|
|
return ApiClient.ajax({
|
2020-05-04 12:44:12 +02:00
|
|
|
url: ApiClient.getUrl('System/MediaEncoder/Path'),
|
|
|
|
type: 'POST',
|
2020-08-12 21:17:07 +02:00
|
|
|
data: JSON.stringify({
|
2020-05-04 12:44:12 +02:00
|
|
|
Path: form.querySelector('.txtEncoderPath').value,
|
|
|
|
PathType: 'Custom'
|
2020-08-31 15:48:24 +02:00
|
|
|
}),
|
|
|
|
contentType: 'application/json'
|
2019-11-06 13:43:39 +03:00
|
|
|
}).then(Dashboard.processServerConfigurationUpdateResult, onSaveEncodingPathFailure);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSubmit() {
|
2020-07-11 11:56:57 +01:00
|
|
|
const form = this;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-11 11:56:57 +01:00
|
|
|
const onDecoderConfirmed = function () {
|
2019-11-06 13:43:39 +03:00
|
|
|
loading.show();
|
2020-05-04 12:44:12 +02:00
|
|
|
ApiClient.getNamedConfiguration('encoding').then(function (config) {
|
|
|
|
config.DownMixAudioBoost = $('#txtDownMixAudioBoost', form).val();
|
2020-08-25 01:57:21 +08:00
|
|
|
config.MaxMuxingQueueSize = form.querySelector('#txtMaxMuxingQueueSize').value;
|
2020-05-04 12:44:12 +02:00
|
|
|
config.TranscodingTempPath = $('#txtTranscodingTempPath', form).val();
|
2020-07-24 21:55:33 +08:00
|
|
|
config.FallbackFontPath = form.querySelector('#txtFallbackFontPath').value;
|
2020-08-19 23:02:17 +08:00
|
|
|
config.EnableFallbackFont = form.querySelector('#txtFallbackFontPath').value ? form.querySelector('#chkEnableFallbackFont').checked : false;
|
2020-05-04 12:44:12 +02:00
|
|
|
config.EncodingThreadCount = $('#selectThreadCount', form).val();
|
|
|
|
config.HardwareAccelerationType = $('#selectVideoDecoder', form).val();
|
|
|
|
config.VaapiDevice = $('#txtVaapiDevice', form).val();
|
2020-07-25 15:14:57 +08:00
|
|
|
config.OpenclDevice = form.querySelector('#txtOpenclDevice').value;
|
2020-06-25 16:53:45 +08:00
|
|
|
config.EnableTonemapping = form.querySelector('#chkTonemapping').checked;
|
|
|
|
config.TonemappingAlgorithm = form.querySelector('#selectTonemappingAlgorithm').value;
|
|
|
|
config.TonemappingRange = form.querySelector('#selectTonemappingRange').value;
|
2020-07-25 15:14:57 +08:00
|
|
|
config.TonemappingDesat = form.querySelector('#txtTonemappingDesat').value;
|
|
|
|
config.TonemappingThreshold = form.querySelector('#txtTonemappingThreshold').value;
|
|
|
|
config.TonemappingPeak = form.querySelector('#txtTonemappingPeak').value;
|
2020-08-19 18:00:13 +08:00
|
|
|
config.TonemappingParam = form.querySelector('#txtTonemappingParam').value || '0';
|
2020-05-04 12:44:12 +02:00
|
|
|
config.EncoderPreset = form.querySelector('#selectEncoderPreset').value;
|
|
|
|
config.H264Crf = parseInt(form.querySelector('#txtH264Crf').value || '0');
|
2020-11-14 03:32:25 +08:00
|
|
|
config.H265Crf = parseInt(form.querySelector('#txtH265Crf').value || '0');
|
2020-05-04 12:44:12 +02:00
|
|
|
config.DeinterlaceMethod = form.querySelector('#selectDeinterlaceMethod').value;
|
2020-08-10 22:10:15 +01:00
|
|
|
config.DeinterlaceDoubleRate = form.querySelector('#chkDoubleRateDeinterlacing').checked;
|
2020-05-04 12:44:12 +02:00
|
|
|
config.EnableSubtitleExtraction = form.querySelector('#chkEnableSubtitleExtraction').checked;
|
|
|
|
config.EnableThrottling = form.querySelector('#chkEnableThrottling').checked;
|
|
|
|
config.HardwareDecodingCodecs = Array.prototype.map.call(Array.prototype.filter.call(form.querySelectorAll('.chkDecodeCodec'), function (c) {
|
2019-11-06 13:43:39 +03:00
|
|
|
return c.checked;
|
|
|
|
}), function (c) {
|
2020-05-04 12:44:12 +02:00
|
|
|
return c.getAttribute('data-codec');
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
2020-05-29 14:06:02 -04:00
|
|
|
config.EnableDecodingColorDepth10Hevc = form.querySelector('#chkDecodingColorDepth10Hevc').checked;
|
|
|
|
config.EnableDecodingColorDepth10Vp9 = form.querySelector('#chkDecodingColorDepth10Vp9').checked;
|
2020-05-04 12:44:12 +02:00
|
|
|
config.EnableHardwareEncoding = form.querySelector('#chkHardwareEncoding').checked;
|
2020-11-12 20:03:38 +08:00
|
|
|
config.AllowHevcEncoding = form.querySelector('#chkAllowHevcEncoding').checked;
|
2020-05-04 12:44:12 +02:00
|
|
|
ApiClient.updateNamedConfiguration('encoding', config).then(function () {
|
2019-11-06 13:43:39 +03:00
|
|
|
updateEncoder(form);
|
2020-02-24 22:25:08 +09:00
|
|
|
}, function () {
|
2020-10-18 15:18:15 +01:00
|
|
|
alert(globalize.translate('ErrorDefault'));
|
2020-02-24 22:25:08 +09:00
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
if ($('#selectVideoDecoder', form).val()) {
|
2020-10-18 15:18:15 +01:00
|
|
|
alert({
|
|
|
|
title: globalize.translate('TitleHardwareAcceleration'),
|
|
|
|
text: globalize.translate('HardwareAccelerationWarning')
|
|
|
|
}).then(onDecoderConfirmed);
|
2019-11-06 13:43:39 +03:00
|
|
|
} else {
|
|
|
|
onDecoderConfirmed();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function setDecodingCodecsVisible(context, value) {
|
2020-05-04 12:44:12 +02:00
|
|
|
value = value || '';
|
2020-07-11 11:56:57 +01:00
|
|
|
let any;
|
2020-05-04 12:44:12 +02:00
|
|
|
Array.prototype.forEach.call(context.querySelectorAll('.chkDecodeCodec'), function (c) {
|
2020-07-30 16:07:13 +02:00
|
|
|
if (c.getAttribute('data-types').split(',').indexOf(value) === -1) {
|
2020-05-04 12:44:12 +02:00
|
|
|
dom.parentWithTag(c, 'LABEL').classList.add('hide');
|
2019-11-06 13:43:39 +03:00
|
|
|
} else {
|
2020-05-04 12:44:12 +02:00
|
|
|
dom.parentWithTag(c, 'LABEL').classList.remove('hide');
|
2019-11-06 13:43:39 +03:00
|
|
|
any = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (any) {
|
2020-05-04 12:44:12 +02:00
|
|
|
context.querySelector('.decodingCodecsList').classList.remove('hide');
|
2019-11-06 13:43:39 +03:00
|
|
|
} else {
|
2020-05-04 12:44:12 +02:00
|
|
|
context.querySelector('.decodingCodecsList').classList.add('hide');
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-04-03 00:12:02 +01:00
|
|
|
|
2019-08-16 00:25:31 -07:00
|
|
|
function getTabs() {
|
|
|
|
return [{
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'encodingsettings.html',
|
|
|
|
name: globalize.translate('Transcoding')
|
2019-08-16 00:25:31 -07:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'playbackconfiguration.html',
|
2020-08-16 20:34:39 +09:00
|
|
|
name: globalize.translate('ButtonResume')
|
2019-08-16 00:25:31 -07:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
href: 'streamingsettings.html',
|
|
|
|
name: globalize.translate('TabStreaming')
|
2019-11-06 13:43:39 +03:00
|
|
|
}];
|
2019-08-16 00:25:31 -07:00
|
|
|
}
|
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
$(document).on('pageinit', '#encodingSettingsPage', function () {
|
2020-07-11 11:56:57 +01:00
|
|
|
const page = this;
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#selectVideoDecoder').addEventListener('change', function () {
|
2020-07-30 16:07:13 +02:00
|
|
|
if (this.value == 'vaapi') {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.fldVaapiDevice').classList.remove('hide');
|
|
|
|
page.querySelector('#txtVaapiDevice').setAttribute('required', 'required');
|
2019-11-06 13:43:39 +03:00
|
|
|
} else {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.fldVaapiDevice').classList.add('hide');
|
|
|
|
page.querySelector('#txtVaapiDevice').removeAttribute('required');
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
2020-09-17 20:31:02 +08:00
|
|
|
if (this.value == 'nvenc' || this.value == 'amf') {
|
2020-06-25 16:53:45 +08:00
|
|
|
page.querySelector('.fldOpenclDevice').classList.remove('hide');
|
|
|
|
page.querySelector('#txtOpenclDevice').setAttribute('required', 'required');
|
|
|
|
page.querySelector('.tonemappingOptions').classList.remove('hide');
|
|
|
|
} else {
|
|
|
|
page.querySelector('.fldOpenclDevice').classList.add('hide');
|
|
|
|
page.querySelector('#txtOpenclDevice').removeAttribute('required');
|
|
|
|
page.querySelector('.tonemappingOptions').classList.add('hide');
|
|
|
|
}
|
|
|
|
|
2019-11-06 13:43:39 +03:00
|
|
|
if (this.value) {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.hardwareAccelerationOptions').classList.remove('hide');
|
2019-11-06 13:43:39 +03:00
|
|
|
} else {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('.hardwareAccelerationOptions').classList.add('hide');
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
setDecodingCodecsVisible(page, this.value);
|
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectEncoderPath', page).on('click.selectDirectory', function () {
|
2020-08-14 08:46:34 +02:00
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
|
2020-07-11 11:56:57 +01:00
|
|
|
const picker = new directoryBrowser();
|
2018-10-23 01:05:09 +03:00
|
|
|
picker.show({
|
2019-11-06 13:43:39 +03:00
|
|
|
includeFiles: true,
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('.txtEncoderPath', page).val(path);
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectTranscodingTempPath', page).on('click.selectDirectory', function () {
|
2020-08-14 08:46:34 +02:00
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
|
2020-07-11 11:56:57 +01:00
|
|
|
const picker = new directoryBrowser();
|
2018-10-23 01:05:09 +03:00
|
|
|
picker.show({
|
2019-11-06 13:43:39 +03:00
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtTranscodingTempPath', page).val(path);
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
},
|
2019-11-06 13:43:39 +03:00
|
|
|
validateWriteable: true,
|
2020-05-04 12:44:12 +02:00
|
|
|
header: globalize.translate('HeaderSelectTranscodingPath'),
|
|
|
|
instruction: globalize.translate('HeaderSelectTranscodingPathHelp')
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-07-24 21:55:33 +08:00
|
|
|
$('#btnSelectFallbackFontPath', page).on('click.selectDirectory', function () {
|
2020-11-19 14:08:14 -05:00
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
|
2020-08-19 23:02:17 +08:00
|
|
|
const picker = new directoryBrowser();
|
2020-07-24 21:55:33 +08:00
|
|
|
picker.show({
|
|
|
|
includeDirectories: true,
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
page.querySelector('#txtFallbackFontPath').value = path;
|
|
|
|
}
|
|
|
|
|
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
header: globalize.translate('HeaderSelectFallbackFontPath'),
|
|
|
|
instruction: globalize.translate('HeaderSelectFallbackFontPathHelp')
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('.encodingSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
}).on('pageshow', '#encodingSettingsPage', function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
loading.show();
|
2020-05-04 12:44:12 +02:00
|
|
|
libraryMenu.setTabs('playback', 0, getTabs);
|
2020-07-11 11:56:57 +01:00
|
|
|
const page = this;
|
2020-05-04 12:44:12 +02:00
|
|
|
ApiClient.getNamedConfiguration('encoding').then(function (config) {
|
2019-11-06 13:43:39 +03:00
|
|
|
ApiClient.getSystemInfo().then(function (systemInfo) {
|
2019-03-08 09:15:12 +00:00
|
|
|
loadPage(page, config, systemInfo);
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-07-09 11:22:21 +01:00
|
|
|
|
|
|
|
/* eslint-enable indent */
|