grok-video-generator
v1768377.239.270
Published
Professional integration for https://supermaker.ai/blog/grok-ai-video-generator-the-ultimate-guide-to-creating-ai-videos-2025/
Maintainers
Readme
grok-video-generator
A JavaScript library for programmatically generating videos from various media sources. Simplifies video creation workflows with an intuitive API.
Installation
bash npm install grok-video-generator
Usage Examples
Here are a few examples showcasing the capabilities of grok-video-generator.
1. Creating a video from a sequence of images: javascript const { VideoGenerator } = require('grok-video-generator');
async function createImageVideo() { const generator = new VideoGenerator({ outputFile: 'image_sequence_video.mp4', frameRate: 30, });
const imagePaths = [ 'path/to/image1.jpg', 'path/to/image2.jpg', 'path/to/image3.jpg', ];
for (const imagePath of imagePaths) { await generator.addImage(imagePath); }
await generator.finalize(); console.log('Image sequence video created successfully!'); }
createImageVideo();
2. Adding audio to an existing video: javascript const { VideoGenerator } = require('grok-video-generator');
async function addAudioToVideo() { const generator = new VideoGenerator({ outputFile: 'video_with_audio.mp4', inputVideo: 'existing_video.mp4', });
await generator.addAudio('path/to/audio.mp3');
await generator.finalize();
console.log('Video with audio created successfully!');}
addAudioToVideo();
3. Generating a video from text using a text-to-speech service (example using a placeholder service): javascript const { VideoGenerator } = require('grok-video-generator');
async function generateVideoFromText() { const generator = new VideoGenerator({ outputFile: 'text_to_video.mp4', width: 1280, height: 720, frameRate: 30, });
const text = "This is a sample video generated from text.";
// Assume 'textToSpeechService' is a function that converts text to an audio file path. // This is a placeholder - you'll need to integrate with a real TTS service. const audioFilePath = await textToSpeechService(text);
await generator.addAudio(audioFilePath);
// Optionally add a background image or color. await generator.addBackgroundImage('path/to/background.jpg');
await generator.finalize(); console.log('Video from text created successfully!'); }
// Placeholder text-to-speech function (replace with a real implementation)
async function textToSpeechService(text) {
// In a real application, you would use a text-to-speech API here.
// For example: Google Cloud Text-to-Speech, Amazon Polly, etc.
console.log(Simulating text-to-speech conversion for: ${text});
return 'path/to/generated_audio.mp3'; // Replace with the actual path
}
generateVideoFromText();
4. Overlaying text onto a video: javascript const { VideoGenerator } = require('grok-video-generator');
async function overlayTextOnVideo() { const generator = new VideoGenerator({ outputFile: 'video_with_text.mp4', inputVideo: 'existing_video.mp4' });
await generator.addTextOverlay({
text: 'Hello, World!',
startTime: 2, // Start at 2 seconds
duration: 5, // Display for 5 seconds
x: 100,
y: 100,
fontSize: 48,
color: 'white'
});
await generator.finalize();
console.log('Video with text overlay created successfully!');}
overlayTextOnVideo();
API Summary
VideoGenerator(options): Constructor for theVideoGeneratorclass.options: An object containing configuration parameters.outputFile: (required) The path to the output video file.inputVideo: (optional) The path to an existing video to use as a base.frameRate: (optional, default: 30) The frame rate of the output video.width: (optional) The width of the output video. If not specified, it will be determined by the input video or images.height: (optional) The height of the output video. If not specified, it will be determined by the input video or images.
addImage(imagePath): Adds an image to the video.imagePath: The path to the image file.
addAudio(audioPath): Adds an audio track to the video.audioPath: The path to the audio file.
addTextOverlay(options): Adds a text overlay to the video.options: An object containing the text overlay configuration.text: The text to display.startTime: The time in seconds when the text overlay should start.duration: The duration in seconds for which the text overlay should be displayed.x: The x-coordinate of the text overlay.y: The y-coordinate of the text overlay.fontSize: The font size of the text.color: The color of the text.
addBackgroundImage(imagePath): Adds a background image to the video.imagePath: The path to the background image file.
finalize(): Finalizes the video generation process and saves the video to the specified output file. Returns a Promise.
License
MIT
This package is part of the grok-video-generator ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/grok-ai-video-generator-the-ultimate-guide-to-creating-ai-videos-2025/
