Last active
August 5, 2020 03:17
-
-
Save ejfox/2ac9fc80384918f30b0f781add06dc86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { load } = require("@alex.garcia/observable-prerender"); | |
const puppeteer = require("puppeteer"); | |
async function main() { | |
let mapWidth = 1920 | |
let mapHeight = 1080 | |
// let startDate = "20200301" | |
let startDate = "20200122" | |
const browser = await puppeteer.launch({ | |
defaultViewport: { | |
width: mapWidth, | |
height: mapHeight, | |
deviceScaleFactor: 1 | |
}, | |
// args: [`--window-size=${mapWidth},${mapHeight}`], | |
}); | |
const notebook = await load( | |
"@codingwithfire/cmu-covidcast-api-map-maker-dot-density", | |
["map", "ny", "ca", "tx", "fl"], | |
{ browser } | |
); | |
await notebook.redefine("date", startDate); | |
const days = await notebook.value("days"); | |
console.log("going to work on", days.length, "days") | |
const outputFolder = 'output10' | |
// const signals = await notebook.value("sensors"); | |
// const signalMap = await notebook.value("signalMap") | |
// const signalID = await notebook.value("signal") | |
// const signal = signalMap[signalID] | |
// for await (let signal of signals) { | |
// // console.log("rendering signal", signal.name) | |
await notebook.redefine("peoplePerPoint", 1); | |
let dayNum = 0 | |
for await (let day of days) { | |
// console.log("rendering", dayNum, day) | |
await notebook.redefine("mapWidth", mapWidth); | |
await notebook.redefine("mapHeight", mapHeight); | |
await notebook.redefine("date", day); | |
// await notebook.redefine("signal", signal.key); | |
await notebook.screenshot("map", `${outputFolder}/cases_${("000" + dayNum).slice(-3)}.png`); | |
await notebook.screenshot("ny", `${outputFolder}/cases-ny_${("000" + dayNum).slice(-3)}.png`); | |
await notebook.screenshot("ca", `${outputFolder}/cases-ca_${("000" + dayNum).slice(-3)}.png`); | |
await notebook.screenshot("fl", `${outputFolder}/cases-fl_${("000" + dayNum).slice(-3)}.png`); | |
await notebook.screenshot("tx", `${outputFolder}/cases-tx_${("000" + dayNum).slice(-3)}.png`); | |
// await notebook.svg("map", `${county.name}.svg`); | |
dayNum++ | |
} | |
console.log(`ffmpeg -framerate 12 -i ${outputFolder}/cases_%03d.png -c:v libx264 -pix_fmt yuv420p ${outputFolder}/cases.mp4; `) | |
//console.log(`ffmpeg -framerate 15 -i output/${signal.key}/${signal.id}_%03d.png -vf "minterpolate=fps=25:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1" -c:v libx264 -pix_fmt yuv420p output/${signal.key}/${signal.id}.mp4`) | |
// } | |
//ffmpeg -framerate 2 -i output3/doctor-visits_%03d.png -c:v libx264 -pix_fmt yuv420p output3/doctor-visits.mp4 | |
await notebook.browser.close(); | |
} | |
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "prerender", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@alex.garcia/observable-prerender": "0.0.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment