import BlendDuck, { ExportOptions, ExportStatus } from "@blendduck/node-sdk";
// Initialize the BlendDuck client
const client = new BlendDuck({
apiKey: process.env.BLENDDUCK_API_KEY
});
async function exportVideo(projectId: string) {
// Define export options
const exportOptions: ExportOptions = {
resolution: "1080p",
quality: "medium",
fps: 30
};
try {
// Start the export process
const exportId = await client.videos.export(projectId, exportOptions);
console.log(`Export process started. Export ID: ${exportId}`);
// Monitor the export progress
let status: ExportStatus;
do {
await new Promise(resolve => setTimeout(resolve, 5000)); // Wait for 5 seconds
status = await client.videos.getExportStatus(exportId);
console.log(`Export progress: ${status.progress}%`);
} while (status.status === ExportStatus.Processing);
if (status.status === ExportStatus.Completed) {
console.log(`Export completed successfully!`);
console.log(`Download your video at: ${status.url}`);
} else {
console.error(`Export failed: ${status.error}`);
}
} catch (error) {
console.error("Error exporting video:", error);
}
}
// Usage
exportVideo("your-project-id-here");