Baidu SeedDance video generation model Node.js SDK. SeedDance is an AI video generation platform launched by Baidu Research, supporting text-to-video, image-to-video, and video style transfer features.
Quick Start
Step 1: Install the SeedDance Node.js SDK. Run the following command directly:
npm install @seeddance/node-sdk
Note: The SDK installation must be completed first; all subsequent features depend on this package.
Usage Examples
Text-to-Video
const { SeedDance } = require('@seeddance/node-sdk');
const client = new SeedDance({ region: 'cn-beijing' });
async function generateVideo() {
const result = await client.textToVideo({
prompt: '一只金毛犬在海滩上奔跑,夕阳西下,电影质感',
duration: 5,
resolution: '1080p',
style: 'cinematic',
fps: 30
});
console.log(`视频生成完成: ${result.videoUrl}`);
console.log(`时长: ${result.duration}秒`);
}
generateVideo();
Image-to-Video
const fs = require('fs');
async function imageToVideo() {
const image = fs.readFileSync('./input-image.jpg');
const result = await client.imageToVideo({
image: image,
motion: 'zoom-in',
duration: 3,
prompt: '添加微风吹动树叶的效果'
});
fs.writeFileSync('./output.mp4', result.videoBuffer);
console.log('视频已保存到 output.mp4');
}
Video Style Transfer
async function styleTransfer() {
const result = await client.styleTransfer({
videoUrl: 'https://example.com/input.mp4',
targetStyle: 'anime',
preserveMotion: true,
intensity: 0.8
});
console.log(`风格转换完成: ${result.videoUrl}`);
}
Batch Processing
async function batchGenerate(prompts) {
const batch = client.createBatch();
for (const prompt of prompts) {
batch.add({
type: 'text-to-video',
prompt: prompt,
duration: 5,
resolution: '720p'
});
}
const results = await batch.execute({
concurrency: 3,
onProgress: (completed, total) => {
console.log(`进度: ${completed}/${total}`);
}
});
return results;
}
FAQ
Q: Which output formats are supported? A: MP4, WebM, and GIF formats are supported. The default output is MP4.
Q: How can I improve video quality?
A: Use a more detailed prompt, specify style: 'cinematic', and choose a higher resolution.