[BUG] gopro-telemetry function call is blocking every request on my express server
See original GitHub issueDescribe the bug Gopro-telemetry function call is blocking every request on my express server
To Reproduce Juste create a very basic express server like this one:
const express = require('express');
const bodyParser = require('body-parser');
const metadata2json = require('./export')
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(`App is listening on port ${port}.`);
}
);
app.get("/helloworld", async (req, res) => {
console.log("helloworld")
res.send("helloworld")
})
app.get("/extract", async (req, res) => {
await metadata2json('./GH020021.MP4', "TOTO.json")
res.send("finish")
})
As you can see I have tow route, one that will serve as test (‘/helloworld’) and the other one that will extract my data.
Here is my metadata2json function:
const goproTelemetry = require(`gopro-telemetry`);
const gpmfExtract = require('gpmf-extract');
const fs = require('fs');
process.env.FFPROBE_PATH = require('@ffprobe-installer/ffprobe').path;
const ffprobe = require('ffprobe-client');
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(require('@ffmpeg-installer/ffmpeg').path);
const extractGPMF = async videoFile => {
const ffData = await ffprobe(videoFile);
for (let i = 0; i < ffData.streams.length; i++) {
if (ffData.streams[i].codec_tag_string === 'gpmd') {
return await extractGPMFAt(videoFile, i);
}
}
return null;
};
const extractGPMFAt = async (videoFile, stream) => {
let rawData = Buffer.alloc(0);
await new Promise(resolve => {
ffmpeg(videoFile)
.outputOption('-y')
.outputOptions('-codec copy')
.outputOptions(`-map 0:${stream}`)
.outputOption('-f rawvideo')
.pipe()
.on('data', chunk => {
rawData = Buffer.concat([rawData, chunk]);
}).on('end', resolve);
});
return rawData;
};
const metadata2json = async (file, dest) => {
const gpmf = await extractGPMF(file);
const element = {
rawData: gpmf,
timing: {
frameDuration: 0,
start: "",
sample: []
}
};
console.log(element);
let telemetry = await goproTelemetry(element, {promisify: true});
console.log("salut")
fs.writeFile(dest, JSON.stringify(telemetry), err => {
if (err) {
return console.log(err);
}
});
console.log('Telemetry saved as JSON');
console.log(file);
};
module.exports = metadata2json;
When I run this and make a request on /extract and right after on /helloworld I have this output:
> test-express@1.0.0 start /home/basile_lamarque/tmp/test-express
> node index.js
App is listening on port 5000.
{
rawData: <Buffer 44 45 56 43 00 01 1c b8 44 56 49 44 4c 04 00 01 00 00 00 01 44 56 4e 4d 63 0b 00 01 48 45 52 4f 38 20 42 6c 61 63 6b 00 53 54 52 4d 00 01 05 54 53 54 ... 5196778 more bytes>,
timing: { frameDuration: 0, start: '', sample: [] }
}
salut
Telemetry saved as JSON
./GH020021.MP4
helloworld
Expected behaviour
I no clue of what happen, maybe goproTelemetry
is consuming all my thread, I don’t know.
Additional context I have try to add this but it gave me the same result
let telemetry = await goproTelemetry(element, {promisify: true});
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
node.js - nodeJS blocking all requests until it calls back
I am facing the same kind of problem for long time server http request blocks the service for response other client requests. This...
Read more >makaivelli/gopro-telemetry: Small personal project to ...
This project was bootstrapped with Create React App. Below you will find some information on how to perform common tasks. You can find...
Read more >GENERAL CONTRACTING CONDITIONS OF ...
The purchase, acquisition and use of any of goprotelemetryextractor.com (hereinafter, “goprotelemetryextractor.com”) products through the ...
Read more >gopro-telemetry
Parses telemetry from the GPMF track in GoPro cameras (Hero5 and later). Created for Telemetry Overlay and the Telemetry Extractor for GoPro.
Read more >sitemap_8.xml
https://forums.envato.com/t/why-my-website-template-is-rejected/117126 ... .envato.com/t/error-call-to-undefined-function-sovereign-edge-add-meta-box/249629 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for trying that. I will experiment with this as soon as I can. It might take me a while, as I am busy with something urgent. So if someone else is able to make any progress, go ahead and much appreciated
I did some test this morning between the async version with
setImmediate
calls and another version with all the async stuff removed. I did not see any significant difference so I think the pragmatic thing to do is to leave it as it is now if it helps some people… The only downside is that the code is a bit more complicated to read.