HLS try
This commit is contained in:
parent
7d9360576f
commit
9d40f213be
|
|
@ -14,40 +14,11 @@ def get():
|
|||
Returns the page showing camera configuration for all parameters in capturesettings and imgsettings,
|
||||
grouped by section.
|
||||
"""
|
||||
# Load configCamera.json
|
||||
with open('configCamera.json', 'r') as f:
|
||||
config = json.load(f)
|
||||
|
||||
|
||||
grouped_params = []
|
||||
for section in ['capturesettings', 'imgsettings']:
|
||||
section_params = []
|
||||
settings = config['main'].get(section, {})
|
||||
for param_name, param in settings.items():
|
||||
if 'Choices' in param and isinstance(param['Choices'], list) and param['Choices']:
|
||||
choices = [
|
||||
{'value': c.get('id', idx), 'label': c['label']}
|
||||
for idx, c in enumerate(param['Choices'])
|
||||
]
|
||||
if len(choices) > 1:
|
||||
section_params.append({
|
||||
'name': param_name,
|
||||
'label': param.get('Label', param_name.capitalize()),
|
||||
'choices': choices,
|
||||
'current': param.get('Current', '')
|
||||
})
|
||||
if section_params:
|
||||
grouped_params.append({
|
||||
'section': section,
|
||||
'params': section_params
|
||||
})
|
||||
|
||||
import pprint
|
||||
pprint.pprint(grouped_params)
|
||||
|
||||
|
||||
return render_template(
|
||||
'camera.html',
|
||||
grouped_params=grouped_params
|
||||
)
|
||||
'camera.html')
|
||||
|
||||
|
||||
@blueprint.route('/set', methods=['POST'])
|
||||
|
|
@ -68,6 +39,8 @@ def camera_feed():
|
|||
return send_file('static/feed.jpg', mimetype='image/jpeg')
|
||||
|
||||
|
||||
|
||||
|
||||
@blueprint.route('/config', methods=['GET'])
|
||||
def get_camera_config():
|
||||
"""
|
||||
|
|
@ -77,27 +50,30 @@ def get_camera_config():
|
|||
config = json.load(f)
|
||||
|
||||
grouped_params = []
|
||||
for section in ['capturesettings', 'imgsettings']:
|
||||
# Iterate over all sections in config['main']
|
||||
for section, settings in config['main'].items():
|
||||
section_params = []
|
||||
settings = config['main'].get(section, {})
|
||||
for param_name, param in settings.items():
|
||||
if 'Choices' in param and isinstance(param['Choices'], list) and param['Choices']:
|
||||
choices = [
|
||||
{'value': c.get('id', idx), 'label': c['label']}
|
||||
for idx, c in enumerate(param['Choices'])
|
||||
]
|
||||
if len(choices) > 1:
|
||||
if isinstance(settings, dict):
|
||||
for param_name, param in settings.items():
|
||||
if 'Choices' in param and isinstance(param['Choices'], list) and param['Choices']:
|
||||
choices = [
|
||||
{'value': c.get('id', idx), 'label': c['label']}
|
||||
for idx, c in enumerate(param['Choices'])
|
||||
]
|
||||
|
||||
section_params.append({
|
||||
'name': param_name,
|
||||
'label': param.get('Label', param_name.capitalize()),
|
||||
'choices': choices,
|
||||
'current': param.get('Current', '')
|
||||
'name': param_name,
|
||||
'label': param.get('Label', param_name.capitalize()),
|
||||
'choices': choices,
|
||||
'current': param.get('Current', ''),
|
||||
'Type': param.get('Type', 'Text'),
|
||||
'Readonly': param.get('Readonly', 0)
|
||||
})
|
||||
|
||||
if section_params:
|
||||
grouped_params.append({
|
||||
'section': section,
|
||||
'params': section_params
|
||||
})
|
||||
|
||||
return jsonify(grouped_params)
|
||||
|
||||
return jsonify(grouped_params)
|
||||
|
|
@ -10,12 +10,29 @@
|
|||
<div id="camera-config-container"></div>
|
||||
</div>
|
||||
<div class="column is-half has-text-centered">
|
||||
{#
|
||||
<figure class="image is-4by3" style="max-width: 480px; margin: auto;">
|
||||
<img id="camera-preview" src="/camera/feed.jpg?{{ range(1000000)|random }}" alt="Camera Preview"
|
||||
style="border: 1px solid #ccc;">
|
||||
</figure>
|
||||
#}
|
||||
|
||||
<video id="video" controls autoplay></video>
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
||||
<script>
|
||||
if (Hls.isSupported()) {
|
||||
var video = document.getElementById('video');
|
||||
var hls = new Hls({
|
||||
startPosition: -1
|
||||
});
|
||||
|
||||
|
||||
hls.loadSource('/static/stream.m3u8');
|
||||
hls.attachMedia(video);
|
||||
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = '/static/stream.m3u8';
|
||||
}
|
||||
</script>
|
||||
<nav class="level">
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
|
|
@ -112,6 +129,13 @@
|
|||
box.innerHTML = `<h2 class="subtitle has-text-weight-bold">${group.section.replace('settings', ' Settings')}</h2>`;
|
||||
group.params.forEach(param => {
|
||||
let field = document.createElement('div');
|
||||
if (param.type == 'TEXT') {
|
||||
field.className = 'text';
|
||||
field.innerHTML = `
|
||||
<p> ${param.name} </p>
|
||||
`;
|
||||
|
||||
}else {
|
||||
field.className = 'field';
|
||||
field.innerHTML = `
|
||||
<label class="label" for="${param.name}">${param.label}:</label>
|
||||
|
|
@ -130,7 +154,9 @@
|
|||
<button class="button is-small is-primary" type="button" onclick="setConfig('${param.name}')">Set</button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
box.appendChild(field);
|
||||
|
||||
});
|
||||
container.appendChild(box);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue