Apdejt (mp4 generiranje, razne fore)
parent
c2f41eec97
commit
c3b30dd59f
24
izberi.html
24
izberi.html
|
@ -66,7 +66,7 @@
|
|||
animation-timing-function: linear;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
border: 8px solid black;
|
||||
border: 8px solid white;
|
||||
border-right-color: transparent;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
|
@ -84,7 +84,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div style="font-size: 1.2rem">
|
||||
Katero število med 1 in 1000 imaš v mislih?
|
||||
Izberi trejler (1 do 1000):
|
||||
<input id="stevilo" type="text" style="font-size: 1.2rem;background:black;color:white;border-radius:2px;" />
|
||||
<button id="gumb" style="font-size: 1.2rem;color:white;background:black;border:1px solid white;border-radius:2px;">klik</button>
|
||||
</div>
|
||||
|
@ -93,7 +93,7 @@
|
|||
<video style="width: 100%; margin-top: .5rem;" id="televizija" controls>
|
||||
Žal gostujoč kos tehnike ni adekvaten.
|
||||
</video>
|
||||
<div class="loading-spinner" style="display: none" id="loader"></div>
|
||||
<div class="loading-spinner" style="display: none;" id="loader"></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -103,6 +103,8 @@
|
|||
var loader = document.getElementById("loader");
|
||||
var st = 0;
|
||||
|
||||
var loading = null;
|
||||
|
||||
function pridobiPosnetek() {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("GET", "/nepovednik/nepoved/" + st, true);
|
||||
|
@ -111,15 +113,12 @@
|
|||
var resp = this.responseText;
|
||||
|
||||
if (resp === "zacetek" || resp === "cakaj") {
|
||||
setTimeout(pridobiPosnetek, 3000);
|
||||
loading = setTimeout(pridobiPosnetek, 3000);
|
||||
} else {
|
||||
loader.style.display = "none";
|
||||
//var src = document.createElement("source");
|
||||
//src.src = resp;
|
||||
//src.type = "video/webm";
|
||||
//tv.appendChild(src);
|
||||
tv.src = '/nepovednik' + resp;
|
||||
tv.play();
|
||||
loading = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -134,16 +133,15 @@
|
|||
if (isNaN(st) || st < 0 || st > 1000) {
|
||||
stel.style.backgroundColor = "darksalmon";
|
||||
} else {
|
||||
if (loading) return;
|
||||
stel.style.backgroundColor = "transparent";
|
||||
loader.style.display = "block";
|
||||
tv.pause();
|
||||
tv.src = null;
|
||||
pridobiPosnetek();
|
||||
}
|
||||
}
|
||||
|
||||
function klik(e) {
|
||||
console.log("kliK!");
|
||||
if (e.keyCode == 13) {
|
||||
proziPosnetek();
|
||||
}
|
||||
|
@ -151,6 +149,12 @@
|
|||
|
||||
stel.onkeypress = klik;
|
||||
|
||||
// Prvi posnetek je random
|
||||
var initNum = Math.ceil(Math.random() * 1000);
|
||||
st = initNum;
|
||||
stel.value = initNum;
|
||||
pridobiPosnetek();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
for i in $(seq 1 1000); do
|
||||
if [ ! -e nepovedi/$i.mp4 ] || [ ! -e nepovedi/$i.webm ]; then
|
||||
echo $i
|
||||
fi
|
||||
done
|
|
@ -45,11 +45,14 @@ const generator = new MersenneTwister(stTrejlerja);
|
|||
let videi = [];
|
||||
let stevec = 0;
|
||||
|
||||
fs.readdirSync(videiDir).map(file => {
|
||||
ffmpeg.ffprobe(videiDir + file, (err, metadata) => {
|
||||
function readFolder (path) {
|
||||
fs.readdirSync(path).map(file => {
|
||||
//console.log(file);
|
||||
if (fs.lstatSync(path + file).isFile()) {
|
||||
ffmpeg.ffprobe(path + file, (err, metadata) => {
|
||||
videi.push({
|
||||
name: file.substr(0, file.length - 3),
|
||||
path: videiDir + file,
|
||||
path: path + file,
|
||||
length: metadata.streams[0].duration
|
||||
});
|
||||
|
||||
|
@ -59,10 +62,22 @@ fs.readdirSync(videiDir).map(file => {
|
|||
});
|
||||
|
||||
stevec += 1;
|
||||
});
|
||||
} else {
|
||||
readFolder(path + file + '/');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function imeKosa(st) {
|
||||
return stTrejlerja + '_' + st + '.webm';
|
||||
readFolder(videiDir);
|
||||
|
||||
function imeKosa(st, apple = false) {
|
||||
let ext = '.webm';
|
||||
|
||||
if (apple) {
|
||||
ext = '.mp4';
|
||||
}
|
||||
|
||||
return stTrejlerja + '_' + st + ext;
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,7 +98,7 @@ function razsekaj(videi) {
|
|||
trajanje = parseFloat((trenutniV.length - zacetek).toFixed(2));
|
||||
}
|
||||
|
||||
let cmd = "ffmpeg -y -ss " + toHHMMSS(zacetek) + " -i " + trenutniV.path.replace(/([\s()&])/g, "\\$1") + " -t " + toHHMMSS(trajanje) + " -vcodec libvpx -cpu-used -5 -deadline realtime -acodec libvorbis -max_muxing_queue_size 400 ./kosi/" + imeKosa(stKosov);
|
||||
let cmd = "ffmpeg -y -ss " + toHHMMSS(zacetek) + " -i " + trenutniV.path.replace(/([\s()&'])/g, "\\$1") + " -t " + toHHMMSS(trajanje) + " -vcodec libvpx -cpu-used -5 -deadline realtime -vf scale=1280:720 -ac 1 -acodec libvorbis -ab 192k -ar 44100 -max_muxing_queue_size 400 ./kosi/" + imeKosa(stKosov);
|
||||
exec(cmd, function (error, stdout, stderr) {
|
||||
if (error !== null) {
|
||||
console.log("Napaka!", error);
|
||||
|
@ -93,7 +108,26 @@ function razsekaj(videi) {
|
|||
|
||||
stKoncanih += 1;
|
||||
|
||||
if ((dolzina > dolzinaT) && (stKoncanih === (stKosov - 1))) {
|
||||
if ((dolzina > dolzinaT) && (stKoncanih === (stKosov - 1)*2)) {
|
||||
console.log("konvertirani vsi.");
|
||||
console.log("polna dolzina: " + dolzina);
|
||||
console.log("dajmo jih zlepit. (" + (stKosov - 1) + ")");
|
||||
zlepi();
|
||||
}
|
||||
});
|
||||
|
||||
let cmd_apple = "ffmpeg -y -ss " + toHHMMSS(zacetek) + " -i " + trenutniV.path.replace(/([\s()&'])/g, "\\$1") + " -t " + toHHMMSS(trajanje) + " -vcodec libx264 -b 850k -vf scale=1280:720 -acodec aac -ar 44100 -ab 128k ./kosi/" + imeKosa(stKosov, true);
|
||||
//console.log(cmd_apple);
|
||||
exec(cmd_apple, function (error, stdout, stderr) {
|
||||
if (error !== null) {
|
||||
console.log("Napaka!", error);
|
||||
console.log(stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
stKoncanih += 1;
|
||||
|
||||
if ((dolzina > dolzinaT) && (stKoncanih === (stKosov - 1)*2)) {
|
||||
console.log("konvertirani vsi.");
|
||||
console.log("polna dolzina: " + dolzina);
|
||||
console.log("dajmo jih zlepit. (" + (stKosov - 1) + ")");
|
||||
|
@ -107,6 +141,8 @@ function razsekaj(videi) {
|
|||
}
|
||||
|
||||
function zlepi() {
|
||||
let lepila = 2;
|
||||
|
||||
let cmd = 'mkvmerge -o ./nepovedi/' + stTrejlerja + '.webm ./kosi/' + imeKosa(1);
|
||||
for (let i = 2; i < stKosov; i++) {
|
||||
cmd += ' + ./kosi/' + imeKosa(i);
|
||||
|
@ -124,10 +160,45 @@ function zlepi() {
|
|||
console.log("Koncano!");
|
||||
|
||||
for(let j = 1; j < stKosov; j++) {
|
||||
//fs.unlinkSync('./kosi/' + imeKosa(j));
|
||||
fs.unlinkSync('./kosi/' + imeKosa(j));
|
||||
}
|
||||
|
||||
lepila -= 1;
|
||||
|
||||
if (lepila == 0) {
|
||||
fs.unlinkSync(najava);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
let cmd_apple = 'MP4Box -force-cat -add ./kosi/' + imeKosa(1, true);
|
||||
for (let i = 2; i < stKosov; i++) {
|
||||
cmd_apple += ' -cat ./kosi/' + imeKosa(i, true);
|
||||
}
|
||||
cmd_apple += ' -new ./nepovedi/' + stTrejlerja + '.mp4';
|
||||
|
||||
exec(cmd_apple, function (error, stdout, stderr) {
|
||||
if (error !== null) {
|
||||
console.log("problem pri lepljenju.");
|
||||
console.log(error);
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("Koncano!");
|
||||
|
||||
for(let j = 1; j < stKosov; j++) {
|
||||
fs.unlinkSync('./kosi/' + imeKosa(j, true));
|
||||
}
|
||||
|
||||
lepila -= 1;
|
||||
|
||||
if (lepila == 0) {
|
||||
fs.unlinkSync(najava);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue