Skip to content

Commit

Permalink
stashing work to get logs working
Browse files Browse the repository at this point in the history
  • Loading branch information
thelamer committed Jun 30, 2019
1 parent de371a8 commit 8da1faf
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 17 deletions.
18 changes: 18 additions & 0 deletions commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- category: "H.264 Downsampling"
- name: "720p 4mpbs"
description: "This can be used as a catch all for most H.264 720p encodes, if you want a higher bitrate then modify the 4000k to your suit your needs"
command: |
ffmpeg -i "${INPUTFILE}" \
-vf scale=-1:720 \
-c:v h264 \
-c:a copy \
-b:v 4000k \
"${OUTPUTFILE}"
- category: "H.265 Downsampling"
- category: "H.264 Downsampling Vaapi"
- category: "H.265 Downsampling Vaapi"
- category: "H.264 Downsampling Nvidia"
- category: "H.265 Downsampling Nvidia"
- category: "Audio Processing"
23 changes: 23 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

interval: 60

commands:
- name: "test1"
extension: ".mkv"
command: |
ffmpeg -i "${INPUTFILE}" \
-vf scale=-1:720 \
-c:v h264 \
-c:a copy \
-b:v 4000k \
"${OUTPUTFILE}"
- name: "test2"
extension: ".mkv"
command: |
ffmpeg -i "${INPUTFILE}" \
-vf scale=-1:720 \
-c:v h264 \
-c:a copy \
-b:v 4000k \
"${OUTPUTFILE}"
35 changes: 23 additions & 12 deletions public/ffmpeg-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@ $(document).ready(function(){rendermain()})

//// Main Page rendering ////
function rendermain(){
$('#pagecontent').empty();
$('#pagecontent').append('<center><div class="spinner-border" style="width: 6rem; height: 6rem;"></div></center>');
socket.emit('getmain');
}
socket.on('sendmain', function(rules){
$('#pagecontent').empty();
var editor = [];
$(JSON.parse(rules)).each(function(i,data){
$(rules.commands).each(function(i,data){
var name = data.name;
var extension = data.extension;
var command = data.command;
$('#pagecontent').append('\
<div class="card">\
<div class="card-header">\
Process Rule ' + name + '\
</div>\
<div class="card" id="' + name + '">\
<div class="card-body">\
<form>\
<div class="form-row align-items-center">\
<div class="col-auto">\
<input type="text" class="form-control" value="' + name + '" placeholder="File Extension">\
</div>\
<div class="col-auto">\
<input type="text" class="form-control" value="' + extension + '" placeholder="File Extension">\
</div>\
Expand All @@ -38,11 +39,8 @@ socket.on('sendmain', function(rules){
</label>\
</div>\
</div>\
<div class="col-auto">\
<button class="btn btn-primary mb-2">Save</button>\
</div>\
<div class="col float-right">\
<button class="btn btn-success mb-2 float-right">Run Now</button>\
<button class="btn btn-success mb-2 float-right">Run Single</button>\
</div>\
</div>\
</form>\
Expand All @@ -59,12 +57,25 @@ socket.on('sendmain', function(rules){
editor[i].setOptions({
readOnly: false,
});
editor[i].setValue(data.command, -1);
editor[i].setValue(command, -1);
});
}).promise().done(function(){
$('#pagecontent').append('<center><button type="button" class="btn btn-secondary btn-lg">+</button></center>');
});
});



//// Command Page rendering ////
function rendercommands(){
$('#pagecontent').empty();
$('#pagecontent').append('<center><div class="spinner-border" style="width: 6rem; height: 6rem;"></div></center>');
socket.emit('getcommands');
}
socket.on('sendcommands', function(categories){
console.log(categories);
$('#pagecontent').empty();
var editor = [];
$('#pagecontent').append('<div id="cats"></div>')
$(categories).each(function(i,data){
var cat = data.category;
});
});
9 changes: 9 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
<div class="nav-link" style="cursor:pointer;" onclick="rendercommands()" >Example Commands</div>
</li>
</ul>
<form class="form-inline my-2 my-md-0" onsubmit="return false;">
<select class="custom-select form-control mr-sm-2" id="interval">
<option selected>Never</option>
<option value="30">30 seconds</option>
<option value="60">60 seconds</option>
<option value="300">5 minutes</option>
</select>
<button style="cursor:pointer;" onclick="saveall()" class="btn btn-primary my-2 my-sm-0" type="submit">Save Config</button>
</form>
</div>
</nav>
<br>
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
aiohttp
python-socketio
pyyaml
2 changes: 1 addition & 1 deletion root/etc/services.d/web/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
cd /app/ffmpeg-web
exec \
s6-setuidgid abc nodemon \
--exec python3 server.py > /applogs/app.log
--exec python3 server.py > /applogs/app.log 2>&1
23 changes: 19 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aiohttp import web
import socketio
import json
import yaml
import os

sio = socketio.AsyncServer()
app = web.Application()
Expand All @@ -13,11 +14,25 @@ async def index(request):
app.router.add_get('/', index)
app.router.add_static('/public/', path=str('./public/'))

json = '[{"name":"test1","extension":".mkv","command":"ffmpeg -y -vaapi_device /dev/dri/renderD1339"},{"name":"test2","extension":".mkv","command":"ffmpeg -y -vaapi_device /dev/dri/renderD129"}]'

# Send the current config to the user to render
@sio.on('getmain')
async def message(sid):
await sio.emit('sendmain', json, room=sid)
with open("./config.yml", 'r') as stream:
try:
config = yaml.safe_load(stream)
await sio.emit('sendmain', config, room=sid)
except yaml.YAMLError as e:
print(e)

# Send the current command examples from github to the user to render
@sio.on('getcommands')
async def message(sid):
with open("./commands.yml", 'r') as stream:
try:
commands = yaml.safe_load(stream)
await sio.emit('sendcommands', commands, room=sid)
except yaml.YAMLError as e:
print(e)

if __name__ == '__main__':
web.run_app(app, port=8787)

0 comments on commit 8da1faf

Please sign in to comment.