photo-to-video-ai
v1773739.408.185
Published
Professional integration for https://pvid.app/
Maintainers
Readme
Photo to Video AI
A JavaScript library to seamlessly transform static images into engaging videos using AI-powered transitions and effects. Enhance your visual storytelling with minimal effort.
Installation
Install the package using npm: bash npm install photo-to-video-ai
Usage Examples
Here are a few examples demonstrating how to use photo-to-video-ai in your JavaScript/Node.js projects:
1. Basic Image to Video Conversion:
This example demonstrates the simplest way to create a video from a single image. javascript const photoToVideoAI = require('photo-to-video-ai');
async function createVideo() {
try {
const videoPath = await photoToVideoAI.createVideo({
imagePath: 'path/to/your/image.jpg',
outputPath: 'path/to/your/output/video.mp4',
});
console.log(Video created successfully at: ${videoPath});
} catch (error) {
console.error('Error creating video:', error);
}
}
createVideo();
2. Creating a Video from Multiple Images with Custom Transitions:
This example shows how to create a video from an array of images, specifying transition types and durations. javascript const photoToVideoAI = require('photo-to-video-ai');
async function createVideoWithTransitions() {
try {
const videoPath = await photoToVideoAI.createVideo({
imagePaths: [
'path/to/image1.jpg',
'path/to/image2.jpg',
'path/to/image3.jpg',
],
outputPath: 'path/to/your/output/video_with_transitions.mp4',
transition: {
type: 'fade', // Example transition: fade, slide, zoom
duration: 1, // Transition duration in seconds
},
imageDuration: 3, // Duration each image is displayed in seconds
});
console.log(Video with transitions created at: ${videoPath});
} catch (error) {
console.error('Error creating video with transitions:', error);
}
}
createVideoWithTransitions();
3. Adding Background Music to Your Video:
This example demonstrates how to add background music to your generated video. javascript const photoToVideoAI = require('photo-to-video-ai');
async function createVideoWithMusic() {
try {
const videoPath = await photoToVideoAI.createVideo({
imagePath: 'path/to/your/image.jpg',
outputPath: 'path/to/your/output/video_with_music.mp4',
musicPath: 'path/to/your/music.mp3',
musicVolume: 0.5, // Adjust music volume (0.0 to 1.0)
});
console.log(Video with music created at: ${videoPath});
} catch (error) {
console.error('Error creating video with music:', error);
}
}
createVideoWithMusic();
4. Advanced Configuration: Custom Video Resolution and Frame Rate:
This example shows how to configure the video resolution and frame rate. javascript const photoToVideoAI = require('photo-to-video-ai');
async function createCustomVideo() {
try {
const videoPath = await photoToVideoAI.createVideo({
imagePath: 'path/to/your/image.jpg',
outputPath: 'path/to/your/output/custom_video.mp4',
videoWidth: 1280, // Desired video width
videoHeight: 720, // Desired video height
frameRate: 30, // Desired frames per second
});
console.log(Custom video created at: ${videoPath});
} catch (error) {
console.error('Error creating custom video:', error);
}
}
createCustomVideo();
API Summary
The photo-to-video-ai library provides a single function:
createVideo(options): Creates a video from images based on the provided options. Returns a Promise that resolves with the path to the generated video file.options: An object containing the following properties:imagePath(string, optional): Path to a single image file. Required ifimagePathsis not provided.imagePaths(array of strings, optional): An array of paths to image files. Required ifimagePathis not provided.outputPath(string, required): Path where the generated video will be saved.transition(object, optional): Transition configuration.type(string, optional): Transition type (e.g., 'fade', 'slide', 'zoom'). Defaults to 'fade'.duration(number, optional): Transition duration in seconds. Defaults to 1.
imageDuration(number, optional): Duration each image is displayed in seconds when usingimagePaths. Defaults to 3.musicPath(string, optional): Path to a background music file.musicVolume(number, optional): Music volume (0.0 to 1.0). Defaults to 0.5.videoWidth(number, optional): Desired video width in pixels. Defaults to 640.videoHeight(number, optional): Desired video height in pixels. Defaults to 480.frameRate(number, optional): Desired frames per second. Defaults to 24.
License
MIT
Official site links:
