mirror of
https://git.roussel.pro/public-website/singapore_rain_radar.git
synced 2026-02-09 02:20:17 +01:00
cleaned old output on initialization
This commit is contained in:
@@ -50,16 +50,14 @@ function downloadImage(time_string, filepath) {
|
||||
|
||||
export async function initImages(count) {
|
||||
let files = fs.readdirSync('images/raw');
|
||||
for(let file of files) {
|
||||
fs.unlinkSync(`images/raw/${file}`);
|
||||
}
|
||||
let downloaded = 0;
|
||||
let i = 0;
|
||||
while(downloaded < count) {
|
||||
let time_string = getTimeString(i);
|
||||
let filename = `images/raw/${time_string}.png`;
|
||||
if (files.includes(`${time_string}.png`)) {
|
||||
downloaded++;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
await downloadImage(time_string, filename);
|
||||
downloaded++;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { initImages, updateImages } from './downloader.mjs';
|
||||
import { createVideo } from './video.mjs';
|
||||
|
||||
const IMAGE_COUNT = 5;
|
||||
const IMAGE_COUNT = 12;
|
||||
|
||||
initImages(IMAGE_COUNT).then(() => {
|
||||
console.log('Downloaded initial images successfully');
|
||||
|
||||
@@ -37,6 +37,12 @@ async function generateFinalImages() {
|
||||
|
||||
export async function createVideo() {
|
||||
await generateFinalImages();
|
||||
//remove video
|
||||
try {
|
||||
fs.unlinkSync('out/output.mp4');
|
||||
} catch (error) {
|
||||
console.log('No video to delete');
|
||||
}
|
||||
//run the command ffmpeg -framerate 5 -i %d.png -c:v libx264 -r 30 output.mp4
|
||||
return new Promise((resolve, reject) => {
|
||||
exec('ffmpeg -framerate 5 -i images/final/%d.png -c:v libx264 -r 30 out/output.mp4', (err, stdout, stderr) => {
|
||||
|
||||
Reference in New Issue
Block a user