Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
* Added webm extractor
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berger <christian.berger@gu.se>
  • Loading branch information
chrberger committed Aug 28, 2018
1 parent 74fd99f commit e224bee
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 10 deletions.
19 changes: 16 additions & 3 deletions webapp/index.js.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,24 @@ app.post('/convertrec2csv', (req, res) => {
});

app.post('/convertrec2csvpng', (req, res) => {
var process_cluonrec2csv = execSync('if [ "$(docker images -q chalmersrevere/rec2csv-png 2> /dev/null)" == "" ]; then docker build -t chalmersrevere/rec2csv-png https://github.com/chalmers-revere/rec2csv-png.git; fi && rm -f ' + req.body.recordingFile + '.csv.zip && mkdir -p recordings/tmp && if [ -f external.odvd ]; then cp external.odvd recordings/tmp/messages.odvd; else cp opendlv-standard-message-set-v0.9.6.odvd recordings/tmp/messages.odvd; fi && docker run --rm --volumes-from=opendlv-vehicle-view -w /opt/vehicle-view/recordings/tmp chalmersrevere/rec2csv-png --rec=../' + req.body.recordingFile + ' --odvd=messages.odvd && cd recordings/tmp && zip -r9 ../../' + req.body.recordingFile + '.csv.zip *.csv opendlv.proxy.ImageReading* && cd .. && rm -fr tmp && cd ..', { shell: '/bin/bash' });
var process_cluonrec2csvpng = execSync('if [ "$(docker images -q chalmersrevere/rec2csv-png 2> /dev/null)" == "" ]; then docker build -t chalmersrevere/rec2csv-png https://github.com/chalmers-revere/rec2csv-png.git; fi && rm -f ' + req.body.recordingFile + '.csv.zip && mkdir -p recordings/tmp && if [ -f external.odvd ]; then cp external.odvd recordings/tmp/messages.odvd; else cp opendlv-standard-message-set-v0.9.6.odvd recordings/tmp/messages.odvd; fi && docker run --rm --volumes-from=opendlv-vehicle-view -w /opt/vehicle-view/recordings/tmp chalmersrevere/rec2csv-png --rec=../' + req.body.recordingFile + ' --odvd=messages.odvd && cd recordings/tmp && zip -r9 ../../' + req.body.recordingFile + '.csv.zip *.csv opendlv.proxy.ImageReading* && cd .. && rm -fr tmp && cd ..', { shell: '/bin/bash' });

console.log(process_cluonrec2csv.toString());
console.log(process_cluonrec2csvpng.toString());

console.log('[opendlv-vehicle-view] Started cluon-rec2csv, PID: ' + process_cluonrec2csv.pid);
console.log('[opendlv-vehicle-view] Started cluon-rec2csvpng, PID: ' + process_cluonrec2csvpng.pid);
res.send ({
status : "200",
responseType: "string",
response : "success"
});
});

app.post('/convertrec2webm', (req, res) => {
var process_cluonrec2webm = execSync('if [ "$(docker images -q chalmersrevere/rec2csv-png 2> /dev/null)" == "" ]; then docker build -t chalmersrevere/rec2csv-png https://github.com/chalmers-revere/rec2csv-png.git; fi && rm -f ' + req.body.recordingFile + '.webm.zip && mkdir -p recordings/tmp && if [ -f external.odvd ]; then cp external.odvd recordings/tmp/messages.odvd; else cp opendlv-standard-message-set-v0.9.6.odvd recordings/tmp/messages.odvd; fi && docker run --rm --volumes-from=opendlv-vehicle-view -w /opt/vehicle-view/recordings/tmp chalmersrevere/rec2csv-png --rec=../' + req.body.recordingFile + ' --odvd=messages.odvd && docker run --rm --volumes-from=opendlv-vehicle-view -w /opt/vehicle-view/recordings/tmp --entrypoint="" chalmersrevere/rec2csv-png /usr/bin/generate_webm.sh && cd recordings/tmp && zip -r9 ../../' + req.body.recordingFile + '.webm.zip *.webm && cd .. && rm -fr tmp && cd ..', { shell: '/bin/bash' });

console.log(process_cluonrec2webm.toString());

console.log('[opendlv-vehicle-view] Started cluon-rec2csvpng, PID: ' + process_cluonrec2webm.pid);
res.send ({
status : "200",
responseType: "string",
Expand Down
79 changes: 72 additions & 7 deletions webapp/views/recordings.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,17 @@ function deleteExternallySuppliedODVDFile() {
{{#each recfiles}}
<tr>
<td align="center">
<button id="download-rec" type="button" class="fas fa-file-download" style="font-size:20px;color:#3498DB;padding: 5px 30px;" onclick="location.href='{{filename}}'" title="Download {{name}}.">&nbsp;.rec</button>
<button id="download-csv-{{name}}" type="button" class="fas fa-file-archive" style="font-size:20px;color:#3498DB;padding: 5px 30px;" onclick="convertFile('{{filename}}', '{{name}}')" title="Convert {{name}} to separate .csv files using the OpenDLV Standard Message Set and download resulting .csv files as zip file.">&nbsp;.csv</button>
<button id="download-rec" type="button" class="fas fa-file-download" style="font-size:15px;color:#3498DB;padding: 5px 20px;" onclick="location.href='{{filename}}'" title="Download {{name}}.">&nbsp;.rec</button>
<button id="download-csv-{{name}}" type="button" class="fas fa-file-archive" style="font-size:15px;color:#3498DB;padding: 5px 20px;" onclick="convertFile('{{filename}}', '{{name}}')" title="Convert {{name}} to separate .csv files using the OpenDLV Standard Message Set and download resulting .csv files as zip file.">&nbsp;.csv</button>
{{#if ../isX64}}
<button id="download-csvpng-{{name}}" type="button" class="fas fa-file-archive" style="font-size:20px;color:#3498DB;padding: 5px 30px;" onclick="convertFilePNG('{{filename}}', '{{name}}')" title="Convert {{name}} to separate .csv and .png files using the OpenDLV Standard Message Set and download resulting .csv and .png files as zip file.">&nbsp;.csv/.png</button>
<button id="download-csvpng-{{name}}" type="button" class="fas fa-file-archive" style="font-size:15px;color:#3498DB;padding: 5px 20px;" onclick="convertFilePNG('{{filename}}', '{{name}}')" title="Convert {{name}} to separate .csv and .png files using the OpenDLV Standard Message Set and download resulting .csv and .png files as zip file.">&nbsp;.csv/.png</button>
<button id="download-webm-{{name}}" type="button" class="fas fa-film" style="font-size:15px;color:#3498DB;padding: 5px 20px;" onclick="convertFileWEBM('{{filename}}', '{{name}}')" title="Convert video frames from {{name}} to separate .webm files and download resulting .webm files as zip file.">&nbsp;.webm</button>
{{else}}
<button id="download-csvpng-{{name}}" type="button" class="fas fa-file-archive" style="font-size:20px;color:#555;padding: 5px 30px;disabled" title="Converting {{name}} to separate .csv and .png files using the OpenDLV Standard Message Set and download resulting .csv and .png files as zip file not supported on non-x86_64 platforms.">&nbsp;<strike>.csv/.png</strike></button>
<button id="download-csvpng-{{name}}" type="button" class="fas fa-file-archive" style="font-size:15px;color:#555;padding: 5px 20px;disabled" title="Converting {{name}} to separate .csv and .png files using the OpenDLV Standard Message Set and download resulting .csv and .png files as zip file not supported on non-x86_64 platforms.">&nbsp;<strike>.csv/.png</strike></button>
<button id="download-webm-{{name}}" type="button" class="fas fa-film" style="font-size:15px;color:#3498DB;padding: 5px 20px;disabled" onclick="convertFileWEBM('{{filename}}', '{{name}}')" title="Convert video frames from {{name}} to separate .webm files and download resulting .webm files as zip file.">&nbsp;<strike>.webm</strike></button>
{{/if}}
<button id="playFile" type="button" class="far fa-play-circle" style="font-size:20px;color:#555;padding: 5px 30px;" onclick="replayFile('{{filename}}', '{{name}}')" title="Replay {{name}}."></button>
<button id="deleteFile" type="button" class="far fa-trash-alt" style="font-size:20px;color:#555;padding: 5px 30px;" onclick="deleteFile('{{filename}}', '{{name}}')" title="Delete {{name}}."></button>
<button id="playFile" type="button" class="far fa-play-circle" style="font-size:15px;color:#555;padding: 5px 20px;" onclick="replayFile('{{filename}}', '{{name}}')" title="Replay {{name}}."></button>
<button id="deleteFile" type="button" class="far fa-trash-alt" style="font-size:15px;color:#555;padding: 5px 20px;" onclick="deleteFile('{{filename}}', '{{name}}')" title="Delete {{name}}."></button>
</td>
<td align="left">
<div onclick="location.href = '../details?rec={{name}}'" onmouseover="" style="cursor: pointer;">{{name}}</div>
Expand Down Expand Up @@ -403,9 +405,15 @@ function convertFile(filename, name) {
}
{{#if isX64}}
var needsToExtractPNG=false;
var needsToExtractWEBM=false;
var filename_convertFilePNG = "";
var name_convertFilePNG = "";
function convertFilePNG(filename, name) {
needsToExtractPNG = true;
needsToExtractWEBM = false;
filename_convertFilePNG = filename;
name_convertFilePNG = name;
Expand All @@ -421,7 +429,12 @@ function acceptopenh264License() {
toggleMessageViewFromTop();
document.cookie = "hasShownLicenseForopenh264=true";
convertFilePNGInternal(filename_convertFilePNG, name_convertFilePNG);
if (needsToExtractPNG) {
convertFilePNGInternal(filename_convertFilePNG, name_convertFilePNG);
}
if (needsToExtractWEBM) {
convertFileWEBMInternal(filename_convertFileWEBM, name_convertFileWEBM);
}
}
function convertFilePNGInternal(filename, name) {
Expand Down Expand Up @@ -458,6 +471,58 @@ function convertFilePNGInternal(filename, name) {
}
{{/if}}
{{#if isX64}}
var filename_convertFileWEBM = "";
var name_convertFileWEBM = "";
function convertFileWEBM(filename, name) {
needsToExtractPNG = false;
needsToExtractWEBM = true;
filename_convertFileWEBM = filename;
name_convertFileWEBM = name;
if (document.cookie.replace(/(?:(?:^|.*;\s*)hasShownLicenseForopenh264\s*\=\s*([^;]*).*$)|^.*$/, "$1") !== "true") {
toggleMessageViewFromTop();
}
else {
convertFileWEBMInternal(filename_convertFileWEBM, name_convertFileWEBM);
}
}
function convertFileWEBMInternal(filename, name) {
if (confirm("Converting video frames from a .rec file into separate .webm files can take several tenth of minutes! Do you want to continue?")) {
document.getElementById('download-webm-' + name).disabled = true;
document.getElementById('download-webm-' + name).style.color = "#555";
document.body.style.cursor = 'wait';
fetch('/convertrec2webm', { method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({recordingFileToConvert: filename, recordingFile: name })
}
)
.then(function(response) {
if (response.ok) {
window.location = "../" + name + ".webm.zip";
document.getElementById('download-webm-' + name).disabled = false;
document.getElementById('download-webm-' + name).style.color = "#3498DB";
document.body.style.cursor = 'default';
return;
}
document.body.style.cursor = 'default';
alert("Failed to extract .webm files (maybe the message specification file was incomplete?).");
throw new Error('Request failed.');
})
.catch(function(error) {
console.log(error);
});
}
}
{{/if}}
function replayFile(filename, name) {
fetch('/replayrecfile', { method: 'post',
headers: {
Expand Down

0 comments on commit e224bee

Please sign in to comment.