justadudewhohacks / justadudewhohacks/opencv4nodejs

VideoWriter didn't write the Video File

Open
#441 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5.1k
Forks
826
PR merge metrics
No merged PRs in 30d

Description

I try to save frames as video using ocv.VideoWriter. I have script like this :
```
function writeVid(){
// year_month_date_hour_minutes_second_ms_time.mp4
var date = new Date();
var file_name = path.resolve(`./web/video/${date.getYear()+1900}_${date.getMonth()+1}_${date.getDate()}_${date.getHours()}_${date.getMinutes()}_${date.getSeconds()}_${date.getMilliseconds()}_${date.getTime()}.avi`);
if(fs.existsSync(file_name)) fs.unlinkSync(file_name);
global.save_file = new ocv.VideoWriter(file_name, ocv.VideoWriter.fourcc("X264"), 4, new ocv.Size(global._frm.sizes[0], global._frm.sizes[1]));
global._wrtVid_timer = setInterval(function(){
save_file.write(global._frm);
console.log("write img");
if(date.getHours() != new Date().getHours()){
clearInterval(global._wrtVid_timer);
save_file.release();
writeVid();
}
}, 1000);
console.log("saving video to " + file_name);
}
global._timerwait = setInterval(function(){
if(global._frm != undefined){
writeVid();
clearInterval(global._timerwait);
}
},1);
```
When i run it. It reach `console.log("write img");` but i can't find the file.

How could I save the frames into video?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.