mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-12-01 04:38:35 -05:00
Adds a curated, per-encoder parameter-template library to ZoneMinder:
- Monitor edit page: a new Template row above the EncoderParameters
textarea offers per-encoder templates (Balanced / Archival / Low
Power / Low CPU). Apply merges the template's params into the
textarea, preserving user-only keys. Advisory lint flags option
keys that aren't recognised for the selected encoder. Switching
encoders offers a same-name template on the new encoder via a
native confirm.
- Options page: a new Encoder Templates tab with full CRUD —
list / edit / copy / delete — backed by a new CakePHP REST API
at /api/encoder_templates.
- Storage: a new EncoderTemplates DB table seeded with 14 shipped
defaults across libx264 / libx265 / h264_nvenc / hevc_nvenc /
h264_vaapi / hevc_vaapi. The table is mutable; ZM upgrades do not
re-seed user-edited rows.
- valid_keys (the lint allow-list) stays in PHP code as ffmpeg
vocabulary, not user data.
- Default params explicitly include pix_fmt to avoid the yuvj420p
HEVC HW-decode rejection issue we hit earlier.
No C++ change. The textarea content is parsed by the existing
av_dict_parse_string call in src/zm_videostore.cpp.
version.txt -> 1.39.6.
Specs: docs/superpowers/specs/2026-05-0{1,2}-*.md
Plans: docs/superpowers/plans/2026-05-0{1,2}-*.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
99 lines
4.1 KiB
PHP
99 lines
4.1 KiB
PHP
<?php
|
|
//
|
|
// ZoneMinder Options - Encoder Templates tab
|
|
// Editor for the EncoderTemplates DB table.
|
|
//
|
|
require_once('includes/EncoderTemplates.php');
|
|
|
|
$encoderFilter = isset($_REQUEST['encoderFilter']) ? validHtmlStr($_REQUEST['encoderFilter']) : '';
|
|
$canEdit = canEdit('System');
|
|
$dict = ZM\EncoderTemplates::all();
|
|
|
|
// Hardcoded encoder list — same as monitor.php
|
|
$encoders = array(
|
|
'' => translate('AllEncoders'),
|
|
'libx264' => 'libx264',
|
|
'libx265' => 'libx265',
|
|
'h264_nvenc' => 'h264_nvenc',
|
|
'hevc_nvenc' => 'hevc_nvenc',
|
|
'h264_vaapi' => 'h264_vaapi',
|
|
'hevc_vaapi' => 'hevc_vaapi',
|
|
);
|
|
?>
|
|
<div id="options">
|
|
<h2><?php echo translate('EncoderTemplates') ?></h2>
|
|
<p><?php echo translate('EncoderTemplatesDescription') ?></p>
|
|
|
|
<div class="col">
|
|
<label for="encoderFilter"><?php echo translate('FilterByEncoder') ?></label>
|
|
<?php echo htmlSelect('encoderFilter', $encoders, $encoderFilter, array('id'=>'encoderFilter')) ?>
|
|
</div>
|
|
|
|
<div class="col button-block">
|
|
<div id="contentButtons">
|
|
<button type="button" id="NewEncoderTemplateBtn"<?php if (!$canEdit) echo ' disabled="disabled"' ?>><?php echo translate('AddNewEncoderTemplate') ?></button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="wrapper-scroll-table">
|
|
<div class="col">
|
|
<table id="contentTable" class="table table-striped"
|
|
data-show-export="true"
|
|
data-show-columns="true"
|
|
data-cookie="true"
|
|
data-cookie-id-table="zmEncoderTemplatesTable"
|
|
data-cookie-expire="2y"
|
|
>
|
|
<thead class="thead-highlight">
|
|
<tr>
|
|
<th data-sortable="true" class="colId"><?php echo translate('Id') ?></th>
|
|
<th data-sortable="true" class="colEncoder"><?php echo translate('Encoder') ?></th>
|
|
<th data-sortable="true" class="colName"><?php echo translate('Name') ?></th>
|
|
<th data-sortable="true" class="colParams"><?php echo translate('Params') ?></th>
|
|
<th class="colActions"><?php echo translate('Actions') ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
foreach ($dict as $enc => $entry) {
|
|
foreach ($entry['templates'] as $tmpl) {
|
|
$paramsLines = [];
|
|
foreach ($tmpl['params'] as $k => $v) {
|
|
$paramsLines[] = $k.'='.$v;
|
|
}
|
|
$paramsFull = implode("\n", $paramsLines);
|
|
$paramsShort = mb_strimwidth(implode(' ', $paramsLines), 0, 60, '…');
|
|
?>
|
|
<tr data-tid="<?php echo $tmpl['id'] ?>" data-encoder="<?php echo validHtmlStr($enc) ?>" data-name="<?php echo validHtmlStr($tmpl['name']) ?>">
|
|
<td class="colId"><?php echo $tmpl['id'] ?></td>
|
|
<td class="colEncoder"><?php echo validHtmlStr($enc) ?></td>
|
|
<td class="colName"><?php echo validHtmlStr($tmpl['name']) ?></td>
|
|
<td class="colParams" title="<?php echo validHtmlStr($paramsFull) ?>"><?php echo validHtmlStr($paramsShort) ?></td>
|
|
<td class="colActions">
|
|
<button type="button" class="btn-edit" data-tid="<?php echo $tmpl['id'] ?>"<?php if (!$canEdit) echo ' disabled="disabled"' ?>><?php echo translate('Edit') ?></button>
|
|
<button type="button" class="btn-copy" data-tid="<?php echo $tmpl['id'] ?>"<?php if (!$canEdit) echo ' disabled="disabled"' ?>><?php echo translate('Copy') ?></button>
|
|
<button type="button" class="btn-delete" data-tid="<?php echo $tmpl['id'] ?>"<?php if (!$canEdit) echo ' disabled="disabled"' ?>><?php echo translate('Delete') ?></button>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Edit modal placeholder; populated client-side by options-encoder-templates.js -->
|
|
<div id="encoderTemplateModalContainer"></div>
|
|
|
|
<script nonce="<?php echo $cspNonce ?>">
|
|
window.ZM_ENCODER_TEMPLATES = <?php echo json_encode($dict, JSON_UNESCAPED_SLASHES); ?>;
|
|
window.addEventListener('DOMContentLoaded', function() {
|
|
$j('#contentTable').bootstrapTable({icons: icons}).show();
|
|
});
|
|
</script>
|
|
<script src="<?php echo cache_bust('skins/classic/views/js/monitor-encoder-templates.js') ?>"></script>
|
|
<script src="<?php echo cache_bust('skins/classic/views/js/options-encoder-templates.js') ?>"></script>
|