Compare commits

..

10 Commits

Author SHA1 Message Date
Joe Tretter
d0d3209dcf added two times segment size test file 2022-09-07 16:08:58 -05:00
Joe Tretter
8f65a33ac8 delete invalid chunks in video decoder 2022-09-06 11:19:20 -05:00
Joe Tretter
f8de654574 creation of chunks directory if it doesn't exist and rename the webcam receiver to have a clearar name 2022-09-06 11:12:10 -05:00
Joe Tretter
d65d1800c9 adding video decoder 2022-09-06 11:05:20 -05:00
Joe Tretter
95e7968516 Beautify 2022-09-05 11:24:51 -05:00
Joe Tretter
c904b5ffef rename the receiver... 2022-09-05 10:54:49 -05:00
Joe Tretter
4b4c3fcbd5 Introduce delay before displaying QR code... 2022-09-05 10:53:10 -05:00
Joe Tretter
a4ec1720f0 Merge branch 'main' of ssh://kawomi.com/var/local/git/qrtransfer 2022-09-05 10:36:43 -05:00
Joe Tretter
80d4171cc4 Fix counting of the segments to be easier
Add test for exact test file
2022-09-05 10:36:27 -05:00
Joe Tretter
9dd6b0a838 chang the chunk combiner to start counting at 1 as of recent UI change. 2022-09-05 10:22:46 -05:00
7 changed files with 62 additions and 45 deletions

View File

@@ -2,42 +2,46 @@
<html>
<head>
<title>QRTransfer</title>
<style>
input {
position: absolute;
left: 150px;
}
</style>
<script src="qrenc-4.0.0.js" type="text/javascript"></script>
<script type="text/javascript">
let $ = (ele) => document.getElementById(ele);
let fileData,
let fileDataB64,
chunkSize,
segmentPosition,
dataPosition,
timoutHandle,
activeCanvas = 0; // double buffering.
let serveCodes = () => {
let numChunks = fileData.length / chunkSize;
let currChunk = segmentPosition / chunkSize;
const $ = (ele) => document.getElementById(ele);
const serveCodes = () => {
let numChunks = Math.ceil(fileDataB64.length / chunkSize);
let currChunk = Math.ceil(dataPosition / chunkSize) + 1;
let delay = Number($("delay").value);
let minLeft = ((numChunks - currChunk) * delay) / 1000 / 60;
$("status").innerText = `${currChunk}/${Math.ceil(numChunks)}/${(currChunk / numChunks).toFixed(2)}% (${minLeft.toFixed(2)} minutes left.)`;
displayQR(
currChunk + 1 + "|" + fileData.substring(segmentPosition, segmentPosition + chunkSize),
Number($("qrSize").value),
Number($("ecc").value)
);
segmentPosition += chunkSize;
$("status").innerText = `${currChunk}/${numChunks}/${((currChunk / numChunks) * 100).toFixed(2)}% (${minLeft.toFixed(2)} min left.)`;
displayQR(currChunk + "|" + fileDataB64.substring(dataPosition, dataPosition + chunkSize), Number($("qrSize").value), Number($("ecc").value));
dataPosition += chunkSize;
if (segmentPosition < fileData.length) {
window.setTimeout(serveCodes, delay);
if (dataPosition < fileDataB64.length) {
timoutHandle = window.setTimeout(serveCodes, delay);
}
};
let displayQR = (data, size, ecc) => {
const displayQR = (data, size, ecc) => {
window.scrollTo(0, 0);
var qr = new QR($("qrcanv" + activeCanvas), data, size, size, ecc);
$("qrcanv" + (activeCanvas === 0 ? 1 : 0)).style.display = "none";
$("qrcanv" + activeCanvas).style.display = "block";
activeCanvas = activeCanvas === 0 ? 1 : 0;
};
let getFile = (fileName) => {
const startAction = (fileName) => {
chunkSize = Number($("chunkSize").value);
segmentPosition = Number($("startChunk").value * chunkSize);
dataPosition = Number($("startChunk").value * chunkSize);
var xhr = new XMLHttpRequest();
xhr.open("GET", fileName, true);
@@ -45,13 +49,14 @@
xhr.onload = (e) => {
tgt = e.currentTarget;
if (tgt.status == 200) {
let uInt8Array = new Uint8Array(tgt.response);
let binaryString = new Array(uInt8Array.length);
uInt8Array.map((x, idx) => (binaryString[idx] = String.fromCharCode(x)));
let allCharCodes = new Uint8Array(tgt.response);
let allChars = new Array(allCharCodes.length);
allCharCodes.map((x, idx) => (allChars[idx] = String.fromCharCode(x)));
// it seems that the qr library doesn't support binary data - converting to base64
fileData = window.btoa(binaryString.join(""));
window.scrollTo(0, 0);
serveCodes();
fileDataB64 = window.btoa(allChars.join(""));
timoutHandle && window.clearTimeout(timoutHandle);
timoutHandle = window.setTimeout(serveCodes, 3000);
}
};
xhr.send();
@@ -59,25 +64,15 @@
</script>
</head>
<body>
<center>
<canvas id="qrcanv0"></canvas>
<canvas id="qrcanv1"></canvas>
</center>
<center><canvas id="qrcanv0"></canvas><canvas id="qrcanv1"></canvas></center>
<hr />
Status:<span id="status">...</span>
Status:<span id="status">...</span> <button onclick="startAction($('inputFileName').value)">Start(3 sec delay)</button>
<hr />
Filename:<input type="text" id="inputFileName" value="testInput/5K.dat" />
<br />
ECC (1-4):<input type="number" value="4" id="ecc" />
<br />
Qr-Size:<input type="number" value="800" id="qrSize" />
<br />
Chunk-Size<input type="number" value="1200" id="chunkSize" />
<br />
Start-Chunk:<input type="number" value="0" id="startChunk" />
<br />
Filename:<input type="text" id="inputFileName" value="testInput/5K.dat" /> <br />
ECC (1-4):<input type="number" value="4" id="ecc" /> <br />
Qr-Size:<input type="number" value="800" id="qrSize" /> <br />
Chunk-Size<input type="number" value="1200" id="chunkSize" /> <br />
Start-Chunk:<input type="number" value="0" id="startChunk" /> <br />
Delay:<input type="number" value="1500" id="delay" />
<br />
<button onclick="getFile($('inputFileName').value)">Read</button>
</body>
</html>

View File

@@ -0,0 +1 @@
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

View File

@@ -0,0 +1 @@
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

View File

@@ -1,15 +1,17 @@
#!/bin/bash
rm output.dat
currFN=0
currFN=1
chunkNum=$(ls chunks/*.chunk | wc -l)
echo "processing chunks "
while /bin/true; do
while [ $currFN -le $chunkNum ] ; do
if [ ! -f chunks/${currFN}.chunk ] ; then
echo chunk $currFN is missing!
exit 1
else
echo -n $currFN/
echo -n [$currFN/$chunkNum]
fi
cat chunks/${currFN}.chunk >> output.dat
let currFN=$currFN+1
done
echo DONE.

17
Decoder/extractVideo.sh Executable file
View File

@@ -0,0 +1,17 @@
#/bin/bash
mkdir -p chunks
echo extracting frames
ffmpeg -loglevel 24 -stats -i input.mp4 /tmp/$$.out%05d.png
echo done, processing frames
ls /tmp/$$.out*.png | while read f;do
dta=$(zbarimg -q --raw --nodbus ${f})
chunkNum=${dta/|*/}
chunkData=${dta/*|/}
echo from ${f} received: ${chunkNum}
echo $chunkData | base64 -d > chunks/${chunkNum}.chunk
if [ $? -ne 0 ]; then
echo at ${f} - file decode failed, deleting chunk
rm chunks/${chunkNum}.chunk
fi
done

BIN
Decoder/input.mp4 Normal file

Binary file not shown.

View File

@@ -1,4 +1,5 @@
#/bin/bash
mkdir -p chunks
while /bin/true;do
fswebcam -q -r 800x800 a.png
#dta=$(fswebcam -q -r 1280x720 - | zbarimg -q --raw --nodbus -)