Some cleanup in triggers page

This commit is contained in:
Ziver Koc 2021-02-17 22:43:33 +01:00
parent 0a1ce4fe60
commit 28bc108921
2 changed files with 11 additions and 106 deletions

View file

@ -12,8 +12,8 @@
{{#flows}} {{#flows}}
<div class="col-md-12"> <div class="col-md-12">
<div class="panel panel-default drop-shadow"> <div class="panel panel-default drop-shadow">
<div class="panel-heading clearfix"> <div class="panel-heading clearfix" style="padding: 4px 15px;">
<b>{{.getName()}}</b> <b class="panel-title">{{.getName()}}</b>
<div class="pull-right"> <div class="pull-right">
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" style="padding: 1px 20px;" <button type="button" class="btn btn-default btn-xs" data-toggle="modal" style="padding: 1px 20px;"
data-target="#flowModal" data-target="#flowModal"
@ -51,8 +51,8 @@
{{#.getTriggers()}} {{#.getTriggers()}}
<tr><td> <tr><td>
<div class="panel panel-default drop-shadow {{#.evaluate()}}panel-success{{/.evaluate()}}"> <div class="panel panel-default drop-shadow {{#.evaluate()}}panel-success{{/.evaluate()}}">
<div class="panel-heading" style="padding: 2px 15px;"> <div class="panel-heading clearfix" style="padding: 2px 15px;">
<small>{{.getObjectClass()}}</small> <small class="pull-left">{{.getObjectClass()}}</small>
<form method="POST"> <form method="POST">
<input type="hidden" name="trigger-id" value="{{.getId()}}"> <input type="hidden" name="trigger-id" value="{{.getId()}}">
@ -65,10 +65,10 @@
{{#.getObjectConfigurator().getConfiguration()}} {{#.getObjectConfigurator().getConfiguration()}}
data-{{.getName()}}="{{.getString()}}" data-{{.getName()}}="{{.getString()}}"
{{/.getObjectConfigurator().getConfiguration()}} > {{/.getObjectConfigurator().getConfiguration()}} >
<span class="glyphicon glyphicon-pencil"></span> <small class="glyphicon glyphicon-pencil"></small>
</button> </button>
<button type="submit" class="btn btn-danger btn-xs" name="action" value="remove_trigger"> <button type="submit" class="btn btn-danger btn-xs" name="action" value="remove_trigger">
<span class="glyphicon glyphicon-trash"></span> <small class="glyphicon glyphicon-trash"></small>
</button> </button>
</div> </div>
</form> </form>
@ -84,6 +84,7 @@
<!-- /TRIGGERS --> <!-- /TRIGGERS -->
</td> </td>
<td class="text-center text-vert-middle"> <td class="text-center text-vert-middle">
<span class="glyphicon glyphicon-arrow-right"></span><br />
<span class="glyphicon glyphicon-arrow-right"></span><br /> <span class="glyphicon glyphicon-arrow-right"></span><br />
<span class="glyphicon glyphicon-arrow-right"></span> <span class="glyphicon glyphicon-arrow-right"></span>
</td> </td>
@ -93,8 +94,8 @@
{{#.getActions()}} {{#.getActions()}}
<tr><td> <tr><td>
<div class="panel panel-default drop-shadow"> <div class="panel panel-default drop-shadow">
<div class="panel-heading" style="padding: 2px 15px;"> <div class="panel-heading clearfix" style="padding: 2px 15px;">
<small>{{.getObjectClass()}}</small> <small class="pull-left">{{.getObjectClass()}}</small>
<form method="POST"> <form method="POST">
<input type="hidden" name="action-id" value="{{.getId()}}"> <input type="hidden" name="action-id" value="{{.getId()}}">
@ -107,10 +108,10 @@
{{#.getObjectConfigurator().getConfiguration()}} {{#.getObjectConfigurator().getConfiguration()}}
data-{{.getName()}}="{{.getString()}}" data-{{.getName()}}="{{.getString()}}"
{{/.getObjectConfigurator().getConfiguration()}} > {{/.getObjectConfigurator().getConfiguration()}} >
<span class="glyphicon glyphicon-pencil"></span> <small class="glyphicon glyphicon-pencil"></small>
</button> </button>
<button type="submit" class="btn btn-danger btn-xs" name="action" value="remove_action"> <button type="submit" class="btn btn-danger btn-xs" name="action" value="remove_action">
<span class="glyphicon glyphicon-trash"></span> <small class="glyphicon glyphicon-trash"></small>
</button> </button>
</div> </div>
</form> </form>

View file

@ -1,96 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2021 Ziver Koc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package se.hal.plugin.nvr;
import com.github.manevolent.ffmpeg4j.FFmpeg;
import com.github.manevolent.ffmpeg4j.FFmpegException;
import com.github.manevolent.ffmpeg4j.FFmpegIO;
import com.github.manevolent.ffmpeg4j.FFmpegInput;
import com.github.manevolent.ffmpeg4j.filter.audio.AudioFilter;
import com.github.manevolent.ffmpeg4j.filter.audio.FFmpegAudioResampleFilter;
import com.github.manevolent.ffmpeg4j.filter.video.FFmpegVideoRescaleFilter;
import com.github.manevolent.ffmpeg4j.filter.video.VideoFilter;
import com.github.manevolent.ffmpeg4j.source.AudioSourceSubstream;
import com.github.manevolent.ffmpeg4j.source.VideoSourceSubstream;
import com.github.manevolent.ffmpeg4j.stream.output.FFmpegTargetStream;
import com.github.manevolent.ffmpeg4j.stream.source.FFmpegSourceStream;
import com.github.manevolent.ffmpeg4j.transcoder.Transcoder;
import zutil.log.CompactLogFormatter;
import zutil.log.LogUtil;
import java.io.FileOutputStream;
import java.util.logging.Level;
public class RecorderFFmpeg4J {
public static void main(String[] args) throws Exception {
LogUtil.setGlobalLevel(Level.ALL);
LogUtil.setGlobalFormatter(new CompactLogFormatter());
FFmpegIO input = FFmpegIO.openNativeUrlInput("rtsp://admin:TCZRTY@192.168.10.223:554/H.264");
FFmpegIO output = FFmpegIO.openOutputStream(new FileOutputStream("./video.mp4"), FFmpegIO.DEFAULT_BUFFER_SIZE);
// Open input
FFmpegSourceStream sourceStream = new FFmpegInput(input).open(FFmpeg.getInputFormatByName("h264"));
sourceStream.registerStreams(); // Read the file header, and register substreams in FFmpeg4j
FFmpegTargetStream targetStream = new FFmpegTargetStream(
"h264", // Output format
output,
new FFmpegTargetStream.FFmpegNativeOutput()
);
// Audio
AudioSourceSubstream inoutAudioSubstream =
(AudioSourceSubstream)
sourceStream.getSubstreams().stream().filter(x -> x instanceof AudioSourceSubstream)
.findFirst().orElse(null);
AudioFilter audioFilter = new FFmpegAudioResampleFilter(
inoutAudioSubstream.getFormat(),
null,
FFmpegAudioResampleFilter.DEFAULT_BUFFER_SIZE
);
// Video
VideoSourceSubstream inputVideoSubstream =
(VideoSourceSubstream)
sourceStream.getSubstreams().stream().filter(x -> x instanceof VideoSourceSubstream)
.findFirst().orElse(null);
VideoFilter videoFilter = new FFmpegVideoRescaleFilter(
inputVideoSubstream.getFormat(),
null,
sourceStream.getPixelFormat()
);
if (targetStream.getSubstreams().size() <= 0)
throw new FFmpegException("No substreams to record");
Transcoder.convert(sourceStream, targetStream, audioFilter, videoFilter, 2D);
}
}