polotno-node
Advanced tools
Comparing version 2.9.36 to 2.9.37
{ | ||
"name": "polotno-node", | ||
"version": "2.9.36", | ||
"version": "2.9.37", | ||
"description": "Polotno workflow from NodeJS", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
"pngjs": "^7.0.0", | ||
"polotno": "^2.11.4", | ||
"polotno": "^2.11.5", | ||
"react": "^18.3.1", | ||
@@ -32,0 +32,0 @@ "react-dom": "^18.3.1", |
# Polotno-node | ||
Export Polotno JSON into images and pdf files. NodeJS package to work with [Polotno Store API](https://polotno.dev/). | ||
Should work fine with lambda functions as well. | ||
Export Polotno JSON into images and pdf files. NodeJS package to work with [Polotno SDK](https://polotno.com/). | ||
> **🚀 Optimize Your Workflow with Cloud Render API!** | ||
> | ||
> Instead of managing your own server infrastructure with `polotno-node`, consider using our [Cloud Render API](https://polotno.com/cloud-render). It provides all the powerful export capabilities of Polotno with none of the server maintenance. Seamlessly convert your designs into images, PDFs, and videos at scale, with the reliability and speed of cloud-based rendering. | ||
> | ||
> **Get started now and focus on what truly matters—creating stunning designs!** | ||
## Usage | ||
@@ -7,0 +12,0 @@ |
@@ -60,3 +60,3 @@ const fs = require('fs'); | ||
const convertVideo = async (url, tempFolder) => { | ||
const convertVideo = async (url, tempFolder, skipWebm) => { | ||
const shortUrl = url.slice(0, 50) + '...'; | ||
@@ -67,11 +67,13 @@ console.log('Downloading video: ' + shortUrl); | ||
await downloadVideo(url, mp4Destination); | ||
console.log('Converting video to webm: ' + filename); | ||
const webmDestination = mp4Destination.replace('.mp4', '.webm'); | ||
await convertToWebM(mp4Destination, webmDestination); | ||
const dataURL = await fileToDataUrl(webmDestination); | ||
let dataURL = ''; | ||
if (!skipWebm) { | ||
console.log('Converting video to webm: ' + filename); | ||
const webmDestination = mp4Destination.replace('.mp4', '.webm'); | ||
await convertToWebM(mp4Destination, webmDestination); | ||
dataURL = await fileToDataUrl(webmDestination); | ||
console.log('Converting video finished: ' + filename); | ||
} | ||
console.log('Converting video finished: ' + filename); | ||
return { | ||
dataURL, | ||
file: webmDestination, | ||
mp4File: mp4Destination, | ||
@@ -111,3 +113,5 @@ }; | ||
); | ||
el.src = dataURL; | ||
if (!attrs.skipWebm) { | ||
el.src = dataURL; | ||
} | ||
el.file = file; | ||
@@ -121,5 +125,9 @@ el.mp4File = mp4File; | ||
}, 0); | ||
if (duration === 0) { | ||
throw new Error('Video duration is 0'); | ||
} | ||
const parallel = attrs.parallel || 5; | ||
const fps = attrs.fps || 15; | ||
const fps = attrs.fps || 30; | ||
const timePerFrame = 1000 / fps; | ||
@@ -156,2 +164,4 @@ | ||
const page = await instance.createPage(); | ||
page.setDefaultNavigationTimeout(60000); // Increase timeout to 60 seconds | ||
await page.evaluate(async (json) => { | ||
@@ -225,3 +235,3 @@ store.loadJSON(json); | ||
const frameTime = Date.now() - startTime; | ||
const progress = finishedFramesNumber / framesNumber; | ||
const progress = (finishedFramesNumber / framesNumber) * 0.95; | ||
attrs.onProgress(progress, frameTime); | ||
@@ -260,2 +270,3 @@ } | ||
outputEndTime: pageStartTime + pageDuration, | ||
volume: el.volume, | ||
}); | ||
@@ -285,2 +296,3 @@ } | ||
const outputOffsetSec = (input.outputStartTime / 1000).toFixed(3); | ||
const volume = input.volume !== undefined ? input.volume : 1; | ||
@@ -292,2 +304,5 @@ // Apply `-itsoffset` before each input file to shift its audio stream | ||
.inputOptions([`-ss ${inputStartSec}`, `-t ${inputDurationSec}`]); // Specify the timing to cut the audio | ||
// Apply volume filter to respect the input volume | ||
ffmpegCmd.audioFilters(`volume=${volume}`); | ||
}); | ||
@@ -294,0 +309,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1228078
5549
577