### Load clips into project Source: https://ezffmpeg.github.io/ezffmpeg/index.html Adds videos, audio, and text with precise timing to the project. This is the second step in the setup process. ```javascript await project.load(clips); ``` -------------------------------- ### Complete example: load and export videos with ezffmpeg Source: https://ezffmpeg.github.io/ezffmpeg/index.html A full example that loads multiple video clips, an audio track, and text overlays with precise timing, then exports the final video. Demonstrates the core API usage. ```javascript const ezffmpeg = require('ezffmpeg'); const project = new ezffmpeg({ width: 1080, height: 1920 }); // Load and concatenate videos async function loadAndExportVideos() { await project.load([ { type: 'video', url: 'train.mp4', position: 0, cutFrom: 1, end: 8, }, { type: 'video', url: 'forest.mp4', position: 8, end: 12, }, { type: 'video', url: 'river.mp4', position: 12, end: 16, }, { type: 'audio', url: 'music.mp3', position: 1, end: 18 }, { type: 'text', text: 'summer vlog', fontSize: 48, fontColor: 'white', position: 3, end: 8 }, { type: 'text', text: 'hope you like ezffmpeg!', fontSize: 48, fontColor: 'white', position: 16, end: 18, } ]); await project.export({ outputPath: 'output.mp4' }); } loadAndExportVideos(); ``` -------------------------------- ### Install and initialize ezffmpeg Source: https://ezffmpeg.github.io/ezffmpeg/index.html Creates a new ezffmpeg instance with desired output dimensions (width and height). This is the first step in setting up a project. ```javascript const ezffmpeg = require('ezffmpeg'); const project = new ezffmpeg({ width: 1080, height: 1920 }); ``` -------------------------------- ### Install ezffmpeg with npm Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Install the ezffmpeg package from npm. ```bash npm install ezffmpeg ``` -------------------------------- ### Export final video Source: https://ezffmpeg.github.io/ezffmpeg/index.html Generates the final video with a single command, specifying the output path. This is the third step in the setup process. ```javascript await project.export({ outputPath: 'output.mp4' }); ``` -------------------------------- ### Constructor Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Creates a new ezffmpeg instance with the specified output settings. ```APIDOC ## Constructor ### Description Creates a new ezffmpeg instance with the specified output settings. ### Method Constructor ### Endpoint `new ezffmpeg(options)` ### Parameters #### Options - **width** (number) - Optional - Output video width in pixels (default: 1920) - **height** (number) - Optional - Output video height in pixels (default: 1080) - **fps** (number) - Optional - Frames per second (default: 30) ### Request Example ```js const project = new ezffmpeg({ width: 1920, height: 1080, fps: 30 }); ``` ### Response No return value (constructor). ``` -------------------------------- ### Create ezffmpeg instance with settings Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Create a new ezffmpeg instance with width, height, and optional fps settings. ```javascript const project = new ezffmpeg({ width: 1920, // Output video width height: 1080, // Output video height fps: 30, // Frames per second (optional) }); ``` -------------------------------- ### project.load() Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Loads media items (video, audio, text) into the project. Each item is an object with type, url, position, end, and optional properties like volume, fontSize, fontColor, fontFile, borderColor, borderWidth, shadowColor, shadowX, shadowY. ```APIDOC ## project.load() ### Description Loads media items (video, audio, text) into the project. Each item is an object with type, url, position, end, and optional properties like volume, fontSize, fontColor, fontFile, borderColor, borderWidth, shadowColor, shadowX, shadowY. ### Method N/A (JavaScript method) ### Endpoint N/A (JavaScript method) ### Parameters #### Items Array Each item is an object with the following properties: - **type** (string) - Required - Type of media: 'video', 'audio', or 'text'. - **url** (string) - Required for video/audio - URL or path to the media file. - **position** (number) - Required - Start time in seconds. - **end** (number) - Required - End time in seconds. - **volume** (number) - Optional - Volume level (0.0 to 1.0). - **text** (string) - Required for text type - The text to display. - **fontSize** (number) - Optional - Font size for text. - **fontColor** (string) - Optional - Font color for text. - **fontFile** (string) - Optional - Path to a custom font file. - **borderColor** (string) - Optional - Border color for text stroke. - **borderWidth** (number) - Optional - Border width for text stroke. - **shadowColor** (string) - Optional - Shadow color for text. - **shadowX** (number) - Optional - Shadow horizontal offset. - **shadowY** (number) - Optional - Shadow vertical offset. ### Request Example javascript await project.load([ { type: 'video', url: 'video1.mp4', position: 0, end: 5 }, { type: 'video', url: 'video2.mp4', position: 5, end: 10 }, { type: 'video', url: 'video3.mp4', position: 10, end: 15 } ]); ### Response N/A (Returns a Promise) ### Response Example N/A ``` -------------------------------- ### load() Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Loads media elements (videos, images, audio, text) into the project. ```APIDOC ## load() ### Description Loads media elements (videos, images, audio, text) into the project. ### Method load ### Endpoint `project.load(mediaArray)` ### Parameters #### Request Body - **mediaArray** (array) - Required - Array of media objects. Each object must have a `type` property. ##### Video options - **type** (string) - Required - Must be 'video' - **url** (string) - Required - Path or URL to the video file - **position** (number) - Required - Start position in seconds in the output video - **end** (number) - Required - End position in seconds in the output video - **cutFrom** (number) - Optional - Start cutting from this position in the source video (default: 0) - **volume** (number) - Optional - Volume level (default: 1.0) ##### Audio options - **type** (string) - Required - Must be 'audio' - **url** (string) - Required - Path or URL to the audio file - **position** (number) - Required - Start position in seconds in the output video - **end** (number) - Required - End position in seconds in the output video - **volume** (number) - Optional - Volume level (default: 1.0) ##### Text options - **type** (string) - Required - Must be 'text' - **text** (string) - Required - The text to display - **position** (number) - Required - Start position in seconds in the output video - **end** (number) - Required - End position in seconds in the output video - **fontSize** (number) - Optional - Font size in pixels (default: 48) - **fontColor** (string) - Optional - Font color (CSS color name or hex) (default: 'white') - **centerX** (number) - Optional - Center X position (default: 0) - **centerY** (number) - Optional - Center Y position (default: 0) - **x** (number) - Optional - Top left X position (default: null) - **y** (number) - Optional - Top left Y position (default: null) - **fontFile** (string) - Optional - Path to a custom font file (.ttf) (default: Arial) - **borderColor** (string) - Optional - Color of the text border (CSS color name or hex) (default: null) - **borderWidth** (number) - Optional - Width of the text border in pixels (default: 0) - **shadowColor** (string) - Optional - Color of the text shadow (CSS color name or hex) (default: null) - **shadowX** (number) - Optional - Horizontal offset of the shadow in pixels (default: 0) - **shadowY** (number) - Optional - Vertical offset of the shadow in pixels (default: 0) - **backgroundColor** (string) - Optional - Background color for the text (CSS color name or hex) (default: null) - **padding** (number) - Optional - Padding around the text in pixels (default: 0) ### Request Example ```js await project.load([ { type: 'video', url: './assets/video.mp4', position: 0, end: 10, cutFrom: 2, }, { type: 'audio', url: 'https://example.com/audio.mp3', position: 0, end: 15 }, { type: 'text', text: 'Hello World', position: 5, end: 10, fontSize: 48, fontColor: 'white' } ]); ``` ### Response Returns a Promise that resolves when the media elements are loaded. ``` -------------------------------- ### export() Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Exports the project to a video file. ```APIDOC ## export() ### Description Exports the project to a video file. ### Method export ### Endpoint `project.export(options)` ### Parameters #### Request Body - **outputPath** (string) - Required - Path to the output video file. ### Request Example ```js await project.export({ outputPath: 'output.mp4' }); ``` ### Response Returns a Promise that resolves when the export is complete. ``` -------------------------------- ### Load media elements with project.load() Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Load media elements (video, audio, text) into the project using the load() API. ```javascript await project.load([ { type: 'video', url: './assets/video.mp4', position: 0, end: 10, cutFrom: 2, }, { type: 'audio', url: 'https://example.com/audio.mp3', position: 0, end: 15 }, { type: 'text', text: 'Hello World', position: 5, end: 10, fontSize: 48, fontColor: 'white' } ]); ``` -------------------------------- ### export() Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Exports the current project to a video file. The outputPath option is required and specifies where the output video will be saved. ```APIDOC ## export() ### Description Exports the current project to a video file. ### Method N/A (JavaScript method) ### Endpoint N/A (JavaScript method) ### Parameters #### Options - **outputPath** (string) - Required - Path where the output video will be saved ### Request Example javascript await project.export({ outputPath: 'output.mp4', }); ### Response N/A (Returns a Promise) ### Response Example N/A ``` -------------------------------- ### Export project to video file Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Exports the current project to a video file. The outputPath option is required and specifies where the output video will be saved. ```javascript await project.export({ outputPath: 'output.mp4', }); ``` -------------------------------- ### Basic usage of ezffmpeg Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Basic usage of ezffmpeg: create a project, load two video clips, and export the result. ```javascript const ezffmpeg = require('ezffmpeg'); const project = new ezffmpeg({ width: 1080, height: 1920 }); async function createVideo() { await project.load([ { type: 'video', url: 'input.mp4', position: 0, end: 5 }, { type: 'video', url: 'input2.mp4', position: 5, end: 10 } ]); await project.export({ outputPath: 'output.mp4' }); } createVideo(); ``` -------------------------------- ### Add text overlay Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Adds a text overlay to a background video. The text element is positioned between 2 and 8 seconds with a font size of 64 and white color. ```javascript await project.load([ { type: 'video', url: 'background.mp4', position: 0, end: 10 }, { type: 'text', text: 'Hello World', position: 2, end: 8, fontSize: 64, fontColor: 'white' } ]); await project.export({ outputPath: 'text_overlay.mp4' }); ``` -------------------------------- ### Add background music Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Adds background music to a video by loading an audio track and adjusting volumes. The video volume is lowered to 0.3 and the music volume is set to 0.8. ```javascript await project.load([ { type: 'video', url: 'video.mp4', position: 0, end: 30, // Lower the original video volume volume: 0.3 }, { type: 'audio', url: 'music.mp3', position: 0, end: 30, // Set the background music volume volume: 0.8 } ]); await project.export({ outputPath: 'video_with_music.mp4' }); ``` -------------------------------- ### Concatenate multiple videos Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Loads three video files sequentially and exports them as a single concatenated video. The position and end properties define the timeline placement for each clip. ```javascript await project.load([ { type: 'video', url: 'video1.mp4', position: 0, end: 5 }, { type: 'video', url: 'video2.mp4', position: 5, end: 10 }, { type: 'video', url: 'video3.mp4', position: 10, end: 15 } ]); await project.export({ outputPath: 'concatenated.mp4' }); ``` -------------------------------- ### Use custom font for text Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Uses a custom font file for text overlay. The fontFile option specifies the path to a TTF font file. ```javascript await project.load([ { type: 'video', url: 'background.mp4', position: 0, end: 10 }, { type: 'text', text: 'Custom Font Example', position: 2, end: 8, fontSize: 64, fontColor: 'white', fontFile: './assets/fonts/Montserrat-Bold.ttf' } ]); await project.export({ outputPath: 'custom_font.mp4' }); ``` -------------------------------- ### Text with shadow Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Adds a black shadow to text using shadowColor, shadowX, and shadowY options. The shadow offset is 4 pixels in both X and Y directions. ```javascript await project.load([ { type: 'video', url: 'background.mp4', position: 0, end: 10 }, { type: 'text', text: 'Shadow Text', position: 2, end: 8, fontSize: 72, fontColor: 'white', // Add a black shadow shadowColor: '#000000', shadowX: 4, shadowY: 4, } ]); await project.export({ outputPath: 'text_with_shadow.mp4' }); ``` -------------------------------- ### Text with stroke Source: https://ezffmpeg.github.io/ezffmpeg/docs.html Adds a black stroke to text using borderColor and borderWidth options. The stroke width is set to 3 pixels. ```javascript await project.load([ { type: 'video', url: 'background.mp4', position: 0, end: 10 }, { type: 'text', text: 'Stroke Text', position: 2, end: 8, fontSize: 72, fontColor: 'white', // Add a black stroke borderColor: 'black', borderWidth: 3, } ]); await project.export({ outputPath: 'text_with_stroke.mp4' }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.