### Start FFTcreator project (with display) Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/installation.md This command starts the FFTcreator project using npm start. It assumes the project is running on a machine with a display device or a server with a graphics card. ```shell npm start ``` -------------------------------- ### Run Examples with npm Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/qa/CONTRIBUTING.md Executes the example scripts provided within the FFCreator project. This is useful for testing features and understanding usage. ```bash npm run examples ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/qa/CONTRIBUTING.md Installs all necessary project dependencies using npm. This is a prerequisite for local development and running examples. ```bash npm i ``` -------------------------------- ### FFVideo: Set Start Time Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Sets the starting point for video playback. Accepts a string or number. ```javascript video.setStartTime("00:00:10"); ``` -------------------------------- ### FFScene: Start Rendering Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Starts the rendering process for the FFScene. ```javascript ffScene.start() ``` -------------------------------- ### Start FFTcreator project (without display) Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/installation.md This command starts the FFTcreator project using xvfb-run on servers without display devices. It utilizes xvfb-run to simulate a virtual display environment, enabling the application to run correctly. ```shell xvfb-run -s "-ac -screen 0 1280x1024x24" npm start ``` -------------------------------- ### FFVtuber: Start Rendering Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Initiates the rendering process for FFVtuber. ```javascript ffVtuber.start() ``` -------------------------------- ### FFAlbum: Start Playback Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initiates the playback of the album, starting the sequence of images and transitions. ```javascript album.start(); ``` -------------------------------- ### FFSubtitle Constructor and Example Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initializes an FFSubtitle component, which can be used for displaying text, potentially integrated with voice-to-subtitle technologies. It accepts configuration for positioning and styling. ```javascript const text = "《街头霸王5》是卡普空使用虚幻引擎开发的3D格斗游戏."; const subtitle = new FFSubtitle({ x: 320, y: 520, scale: 1, rotate: 0, opacity: 1, style: { color: "#FFFFFF", fontSize: 30 }, text: "Default text" }); subtitle.setText(text); // Example of setting other properties subtitle.setFrameBuffer(Buffer.from('frame data')); // Assuming frameBuffer is a Buffer subtitle.setSpeech("This is a voice narration."); subtitle.setAudio("This is a voice dialogue."); subtitle.setRegexp(/pattern/); subtitle.setFontSize(40); subtitle.setDuration(10); subtitle.setBackgroundColor("#000000"); subtitle.setBackground("#FF0000"); // Alias for setBackgroundColor subtitle.setColor("#00FF00"); subtitle.setFont("path/to/font.ttf"); subtitle.setStyle({ fontStyle: "italic" }); // To start rendering or display the subtitle, further methods or integration would be needed. ``` -------------------------------- ### FFNode Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Demonstrates various methods available for the FFNode base class, including getting dimensions, setting animations, adding effects, checking readiness, preprocessing, starting rendering, and destroying the component. These methods provide core functionalities for managing display objects. ```javascript // Get width and height const [width, height] = ffNode.getWH(); // Add animations ffNode.setAnimations(...); // Add special effects ffNode.addEffect("type", 1.2, 0); // Check if ready ffNode.isReady().then(() => console.log('Ready')); // Preprocess materials ffNode.preProcessing().then(() => console.log('Preprocessing complete')); // Start rendering ffNode.start(); // Destroy component ffNode.destroy(); ``` -------------------------------- ### FFVideo Constructor and Basic Usage Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initializes an FFVideo component with a path and dimensions, then sets audio and time properties. This is a fundamental example for using the FFVideo class. ```javascript const video = new FFVideo({ path: "path/to/video.mp4", width: 500, height: 350 }); video.setAudio(true); video.setTimes("00:00:43", "00:00:50"); scene.addChild(video); ``` -------------------------------- ### Integrate FFCreator with PM2 and Xvfb via process.json Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/qa/qa.md Demonstrates how to configure `process.json` to run FFCreator applications using PM2 as a process manager alongside Xvfb for virtual display management on Linux servers. This setup ensures FFCreator runs correctly in headless environments by assigning a DISPLAY environment variable. ```json { "apps" : [{ "name" : "", "script" : "", "env": { "DISPLAY": ":99" } }, { "name" : "Xvfb", "interpreter" : "none", "script" : "Xvfb", "args" : ":99 -ac -screen 0 1280x1024x24" }] } ``` -------------------------------- ### FFNode: Start Rendering (JavaScript) Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Provides the method to initiate the rendering process for an FFNode. This is typically called after all configurations and effects have been applied. ```javascript ffnode.start(); ``` -------------------------------- ### Install node-canvas/headless-gl dependencies on Debian/Ubuntu Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/installation.md This shell command installs necessary dependencies for node-canvas and headless-gl on Debian and Ubuntu systems using apt. These dependencies are required for rendering on servers without a display. ```shell sudo apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++ sudo apt-get install libgl1-mesa-dev xvfb libxi-dev libx11-dev ``` -------------------------------- ### FFScene: Start Scene Rendering Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initiates the rendering process for the FFScene. ```javascript ffScene.start(); ``` -------------------------------- ### FFAlbum Constructor and Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Initializes an FFAlbum with configuration options and provides methods to control album animation duration, transitions, transition times, and retrieve dimensions. It also includes a method to check readiness and start rendering. ```javascript const conf = { list: [], width: 1920, height: 1080, scale: 1, rotate: 0, opacity: 1 }; const ffAlbum = new FFAlbum(conf); ffAlbum.setDuration(5); ffAlbum.setTransition('fade'); ffAlbum.setTransTime(0.5); const [width, height] = ffAlbum.getWH(); ffAlbum.isReady().then(() => { ffAlbum.start(); }); ``` -------------------------------- ### Install FFTcreator npm package Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/installation.md This command installs the FFTcreator npm package and saves it as a dependency to your project. This is the standard way to add FFTcreator to your Node.js application. ```shell npm i ffcreator --save ``` -------------------------------- ### FFAlbum Constructor and Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initializes an FFAlbum with configuration options and provides methods to control album animation duration, transition types, transition times, retrieve dimensions, check readiness, and start rendering. ```javascript const conf = { list: ["path/to/image1.png", "path/to/image2.png"], width: 1920, height: 1080, scale: 1, rotate: 0, opacity: 1 }; const ffAlbum = new FFAlbum(conf); ffAlbum.setDuration(5); // Set total animation duration to 5 seconds ffAlbum.setTransition("fade"); // Set transition type to fade ffAlbum.setTransTime(1.5); // Set transition time to 1.5 seconds const [width, height] = ffAlbum.getWH(); // Get album dimensions console.log(`Album dimensions: ${width}x${height}`); ffAlbum.isReady().then(() => { console.log("Album is ready to start."); ffAlbum.start(); // Start rendering the album }); ``` -------------------------------- ### Install node-canvas/headless-gl dependencies on CentOS/Redhat/Fedora Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/installation.md This shell command installs necessary dependencies for node-canvas and headless-gl on CentOS, Redhat, and Fedora systems using yum. These dependencies are required for rendering on servers without a display. ```shell sudo yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel sudo yum install mesa-dri-drivers Xvfb libXi-devel libXinerama-devel libX11-devel ``` -------------------------------- ### FFCreatorCenter.setFFmpegPath Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Configures the installation path for the FFmpeg executable. ```APIDOC ## FFCreatorCenter.setFFmpegPath(path) ### Description Set the installation path of the current server ffmpeg. If not set, the ffmpeg command of command will be found by default. ### Method POST ### Endpoint /FFCreatorCenter/setFFmpegPath ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **path** (string) - Required - Installation path of the current server ffmpeg. ### Request Example ```json { "path": "/usr/local/bin/ffmpeg" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates if the path was set successfully. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### FFCreatorCenter.setFFprobePath Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Configures the installation path for the FFprobe executable. ```APIDOC ## FFCreatorCenter.setFFprobePath(path) ### Description Set the installation path of the current server ffprobe. If not set, the ffprobe command of command will be found by default. ### Method POST ### Endpoint /FFCreatorCenter/setFFprobePath ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **path** (string) - Required - Installation path of the current server ffprobe. ### Request Example ```json { "path": "/usr/local/bin/ffprobe" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates if the path was set successfully. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### FFVideo: Set Playback Start Time Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Sets only the start time for video playback. Accepts string or number format. ```javascript ffVideo.setStartTime("00:00:15"); ffVideo.setStartTime(15); ``` -------------------------------- ### FFNode Effects and Lifecycle Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Documentation for methods related to adding effects, checking readiness, preprocessing, starting, and destroying FFNode instances. ```APIDOC ## FFNode Effects and Lifecycle ### Description This section covers methods for applying effects to FFNode instances, checking their readiness, performing preprocessing, initiating their start sequence, and managing their destruction. ### Methods #### `addEffect(type, time, delay)` Adds an effect to the FFNode. - **type** (string) - Required - The type of effect. - **time** (number) - Required - The duration or timing of the effect. - **delay** (number) - Optional - The delay before the effect starts. #### `isReady()` Checks if the FFNode is ready for operations. - **Returns**: `Promise` - Resolves when the FFNode is ready. #### `preProcessing()` Performs preprocessing tasks for the FFNode. - **Returns**: `Promise` - Resolves after preprocessing is complete. #### `start()` Starts the FFNode sequence or animation. #### `destroy()` Cleans up and removes the FFNode from the scene. ### Request Example (for `addEffect`) ```json { "type": "fade-in", "time": 1000, "delay": 500 } ``` ### Response Example (for `isReady`) ```json { "isReady": true } ``` ``` -------------------------------- ### Create Video Scene with FFCreator (Node.js) Source: https://github.com/tnfe/ffcreator/blob/master/README.md This snippet demonstrates the basic usage of FFCreator to create a video scene. It includes setting up the creator instance, defining a scene with background color and duration, adding an image with effects, a text element, an album of images, and a video. Finally, it outputs and starts the video processing. ```javascript const { FFScene, FFText, FFVideo, FFAlbum, FFImage, FFCreator } = require("ffcreator"); // Create FFCreator instance const creator = new FFCreator({ cacheDir, outputDir, width: 800, height: 450 }); // Create scene const scene = new FFScene(); scene.setBgColor("#ffcc22"); scene.setDuration(6); scene.setTransition("GridFlip", 2); creator.addChild(scene); // Create Image and add animation effect const image = new FFImage({ path: path.join(__dirname, "../assets/01.jpg") }); image.addEffect("moveInUp", 1, 1); image.addEffect("fadeOutDown", 1, 4); scene.addChild(image); // Create Text const text = new FFText({ text: "hello 你好", x: 400, y: 300 }); text.setColor("#ffffff"); text.setBackgroundColor("#000000"); text.addEffect("fadeIn", 1, 1); scene.addChild(text); // Create a multi-photo Album const album = new FFAlbum({ list: [img1, img2, img3, img4], // Picture collection for album x: 250, y: 300, width: 500, height: 300, }); album.setTransition('zoomIn'); // Set album switching animation album.setDuration(2.5); // Set the stay time of a single sheet album.setTransTime(1.5); // Set the duration of a single animation scene.addChild(album); // Create Video const video = new FFVideo({ path, x: 300, y: 50, width: 300, height: 200 }); video.addEffect("zoomIn", 1, 0); scene.addChild(video); creator.output(path.join(__dirname, "../output/example.mp4")); creator.start(); // Start processing creator.closeLog(); // Close log (including perf) creator.on('start', () => { console.log(`FFCreator start`); }); creator.on('error', e => { console.log(`FFCreator error: ${JSON.stringify(e)}`); }); creator.on('progress', e => { console.log(colors.yellow(`FFCreator progress: ${e.state} ${(e.percent * 100) >> 0}%`)); }); creator.on('complete', e => { console.log(colors.magenta(`FFCreator completed: \n USEAGE: ${e.useage} \n PATH: ${e.output} `)); }); ``` -------------------------------- ### Create video scenes with FFmpeg and FFcreatorLite Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/lite.md Demonstrates how to use the FFcreatorLite library in JavaScript to create video content. This includes initializing the creator, defining scenes, adding images and text with effects, setting durations, and handling progress and completion events. It requires the 'ffcreatorlite' package and assumes FFmpeg is installed. ```javascript const {FFCreatorCenter, FFScene, FFImage, FFText, FFCreator} = require('ffcreatorlite'); // create creator instance const creator = new FFCreator({ cacheDir, outputDir, width: 600, height: 400, log: true, }); // create FFScene const scene1 = new FFScene(); const scene2 = new FFScene(); scene1.setBgColor('#ff0000'); scene2.setBgColor('#b33771'); // scene1 const fbg = new FFImage({path: bg1}); scene1.addChild(fbg); const fimg1 = new FFImage({path: img1, x: 300, y: 60}); fimg1.addEffect('moveInRight', 1.5, 1.2); scene1.addChild(fimg1); const text = new FFText({text: 'This is the first screen', font, x: 100, y: 100}); text.setColor('#ffffff'); text.setBackgroundColor('#000000'); text.addEffect('fadeIn', 1, 1); scene1.addChild(text); scene1.setDuration(8); creator.addChild(scene1); // scene2 const fbg2 = new FFImage({path: bg2}); scene2.addChild(fbg2); // logo const flogo = new FFImage({path: logo, x: 100, y: 100}); flogo.addEffect('moveInUpBack', 1.2, 0.3); scene2.addChild(flogo); scene2.setDuration(4); creator.addChild(scene2); creator.start(); creator.on('progress', e => { console.log(colors.yellow(`FFCreatorLite progress: ${(e.percent * 100) >> 0}%`)); }); creator.on('complete', e => { console.log( colors.magenta(`FFCreatorLite completed: \n USEAGE: ${e.useage} \n PATH: ${e.output} `), ); }); ``` -------------------------------- ### FFCreator Audio Configuration (Node.js) Source: https://github.com/tnfe/ffcreator/blob/master/README.md This snippet shows how to add audio to videos using FFCreator. It covers enabling background music for individual FFVideo elements, setting global background audio for the entire project, and adding specific music tracks to individual scenes. Options for loop and start time are also demonstrated. ```javascript const video = new FFVideo({ path, x: 100, y: 150, width: 500, height: 350 }); video.setTimes('00:00:18', '00:00:33'); video.setAudio(true); // Turn on ``` ```javascript const creator = new FFCreator({ cacheDir, outputDir, audio: path, // background audio }); // or creator.addAudio({ path, loop, start }); ``` ```javascript scene.addAudio(path); // or scene.addAudio({ path, loop, start }); ``` -------------------------------- ### FFAudio Component Initialization Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initializes the FFAudio component, which handles audio playback for video projects. It accepts a configuration object for audio source, loop, and start time. ```javascript const audio = new FFAudio(args); ``` ```javascript const audio = new FFAudio({ src: 'audio.mp3', loop: true, start: 0 }); ``` -------------------------------- ### Set FFprobe Path in FFCreatorCenter Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Sets the FFprobe installation path for the FFCreatorCenter. This allows the center to use FFprobe for media analysis across all its tasks. It's a static method. ```javascript FFCreatorCenter.setFFprobePath(path); ``` -------------------------------- ### Set FFprobe Path for FFCreator Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Configures the installation path for the FFprobe executable used by FFCreator. FFprobe is used for analyzing media streams. ```javascript FFCreator.setFFprobePath(path); ``` -------------------------------- ### FFVtuber: Start Animation Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initiates the animation sequence for the FFVtuber component. This method should be called after configuring the vtuber's appearance and behavior. ```javascript ffVtuber.start(); ``` -------------------------------- ### FFVtuber API Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Constructor and methods for the FFVtuber class, including setting texture packs, textures, speed, and period, as well as cloning and starting the component. ```APIDOC ## FFVtuber Class ### new FFVtuber(conf) FFVtuber constructor. - **Kind**: global class - **Access**: public - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: ```javascript const vtuber = new FFVtuber({ x: 320, y: 520 }); ``` - **Response**: - **Success Response (200)**: None (constructor) - **Response Example**: None ### ffVtuber.clone() Get a cloned object. - **Kind**: instance method of [FFVtuber](#FFVtuber) - **Access**: public - **Returns**: [FFVtuber](#FFVtuber) - cloned object - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: None - **Response**: - **Success Response (200)**: None - **Response Example**: None ### ffVtuber.setTexturePacker(texture, json) Set up an animated sprite texture. - **Kind**: instance method of [FFVtuber](#FFVtuber) - **Access**: public - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: None - **Response**: - **Success Response (200)**: None (method modifies instance state) - **Response Example**: None ### ffVtuber.setTexture(texture, json) Set up a sprite texture. - **Kind**: instance method of [FFVtuber](#FFVtuber) - **Access**: public - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: None - **Response**: - **Success Response (200)**: None (method modifies instance state) - **Response Example**: None ### ffVtuber.setSpeed(speed) Set animation speed. - **Kind**: instance method of [FFVtuber](#FFVtuber) - **Access**: public - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: None - **Response**: - **Success Response (200)**: None (method modifies instance state) - **Response Example**: None ### ffVtuber.setPeriod(period) Set animation period. - **Kind**: instance method of [FFVtuber](#FFVtuber) - **Access**: public - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: None - **Response**: - **Success Response (200)**: None (method modifies instance state) - **Response Example**: None ### ffVtuber.getPeriod() Get animation period. - **Kind**: instance method of [FFVtuber](#FFVtuber) - **Access**: public - **Returns**: array - animation period - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: None - **Response**: - **Success Response (200)**: None - **Response Example**: None ### ffVtuber.start() Start the animation. - **Kind**: instance method of [FFVtuber](#FFVtuber) - **Access**: public - **Parameters**: - **Path Parameters**: None - **Query Parameters**: None - **Request Body**: None - **Request Example**: None - **Response**: - **Success Response (200)**: None (method modifies instance state) - **Response Example**: None ``` -------------------------------- ### Create Preset Video Animation Templates with FFCreator Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/koa.md This snippet demonstrates how to define and create reusable video animation templates using FFCreator. It involves setting up a creator instance, defining scenes, adding elements like images, and applying effects. This is typically a one-time setup executed in a service. ```javascript FFCreatorCenter.createTemplate(tempid, ({ image })=>{ const creator = new FFCreator({...}); const scene = new FFScene(); scene.setBgColor('#b33771'); creator.addChild(scene); const fimg = new FFImage({ path: image, x: 100, y: 200 }); fimg.addEffect('fadeInLeft', 1, 1); scene.addChild(fimg); // Add more elements and animation ... creator.start(); return creator; }); ``` -------------------------------- ### Manage FFCreatorCenter Tasks Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Provides methods for managing video production tasks within the FFCreatorCenter, including starting, monitoring, and adding tasks by template. ```javascript FFCreatorCenter.start(); ``` ```javascript FFCreatorCenter.addTaskByTemplate(tempid); ``` ```javascript FFCreatorCenter.onTask(id, eventName, func); ``` ```javascript FFCreatorCenter.onTaskError(id, func); ``` ```javascript FFCreatorCenter.onTaskComplete(id, func); ``` ```javascript FFCreatorCenter.getTaskState(); ``` ```javascript FFCreatorCenter.addTemplate(id, taskFunc); ``` -------------------------------- ### Set FFmpeg Path in FFCreatorCenter Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Sets the FFmpeg installation path for the FFCreatorCenter. This ensures that all tasks managed by the center can access FFmpeg. It's a static method. ```javascript FFCreatorCenter.setFFmpegPath(path); ``` -------------------------------- ### FFVideo - Embed and Control Videos in FFCreator Source: https://context7.com/tnfe/ffcreator/llms.txt Explains how to incorporate video clips into a scene using FFVideo, including specifying video paths, dimensions, and positioning. It demonstrates advanced features like trimming videos using start and end times (in seconds or HH:MM:SS format), controlling audio playback, setting looping, and specifying video codecs. ```javascript const { FFVideo } = require('ffcreator'); // Basic video with trimming const video1 = new FFVideo({ path: './clips/intro.mp4', x: 640, y: 360, width: 1000, height: 562, ss: 5, // Start time in seconds to: 15 // End time in seconds }); video1.setAudio(true); // Enable video audio (default: true) video1.addEffect('zoomIn', 1, 0); scene.addChild(video1); // Video with precise time control const video2 = new FFVideo({ path: './clips/product-demo.mp4', x: 400, y: 300, width: 600, height: 400 }); video2.setTimes('00:00:18', '00:00:33'); // Precise time format video2.setAudio(false); // Disable video audio video2.setLoop(true); // Loop video if shorter than scene scene.addChild(video2); // Video with codec specification const video3 = new FFVideo({ path: './clips/background.webm', x: 640, y: 360, width: 1280, height: 720 }); video3.setCodec('libvpx-vp9'); // Specify video codec video3.setAudio(true); scene.addChild(video3); // Multiple videos in one scene const pip = new FFVideo({ path: './clips/pip-overlay.mp4', x: 1050, y: 150, width: 320, height: 180, ss: 0, to: 10 }); pip.setAudio(false); pip.addEffect('slideInRight', 0.8, 0.5); scene.addChild(pip); ``` -------------------------------- ### Initialize Creator (Entry Point) Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/useage.md Sets up the main FFCreator instance, defining project settings like cache and output directories, video dimensions, cover image, audio loop, FPS, and threading. ```javascript const creator = new FFCreator({ cacheDir, outputDir, output, width: 500, height: 680, cover: 'a.jpg', audioLoop: true, fps: 24, threads: 4, debug: false, defaultOutputOptions: null, }); ``` -------------------------------- ### FFVideo: Constructor with Configuration Options Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Constructs an FFVideo instance with detailed configuration options including path, dimensions, scale, rotation, and opacity. ```javascript const video = new FFVideo({ path: "video.mp4", width: 1920, height: 1080, scale: 0.5, rotate: 90, opacity: 0.8 }); ``` -------------------------------- ### Install Missing 'xi' Package for FFCreator Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/qa/qa.md Resolves errors during FFCreator installation that indicate a missing 'xi' package. This typically involves installing development libraries for X11, Xi, and Xinerama using a package manager like yum. ```shell yum install libXi-devel libXinerama-devel libX11-devel ``` -------------------------------- ### FFCreatorCenter.start Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Initiates the execution of a task. ```APIDOC ## FFCreatorCenter.start() ### Description Start a task. ### Method POST ### Endpoint /FFCreatorCenter/start ### Parameters None ### Request Example ```json { "taskId": "task123", "taskParameters": { ... } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates if the task was successfully started. #### Response Example ```json { "status": "started" } ``` ``` -------------------------------- ### FFAlbum Constructor and Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Documentation for the FFAlbum constructor and its associated methods for creating and managing photo albums. ```APIDOC ## FFAlbum Class ### new FFAlbum(conf) FFAlbum constructor. #### Parameters - **conf** (object) - FFNode related configuration items - **conf.list** (array) - Photo album picture list - **conf.width** (number) - the width of this album - **conf.height** (number) - this width of this album - **conf.scale** (number) - scale of FFNode - **conf.rotate** (number) - rotation of FFNode - **conf.opacity** (number) - opacity of FFNode ### ffAlbum.setDuration(duration) Set total album animation duration. #### Parameters - **duration** (number) - album animation duration (default: 2) ### ffAlbum.setTransition(transition) Set the way to switch the album animation. #### Parameters - **transition** (string) - transition type (default: "random") ### ffAlbum.setTransTime(time) Set the transition time of each image. #### Parameters - **time** (number) - transition time (default: 1) ### ffAlbum.getWH() Get the width and height of the album component. #### Returns - array - [width, height] array ### ffAlbum.isReady() Check if all resources, materials, and actions are ready. #### Returns - Promise ### ffAlbum.start() Start rendering. ``` -------------------------------- ### Resolve Npm Installation Error with Node Version Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/qa/qa.md Addresses npm installation errors, specifically `ERR! command sh -c node-pre-gyp install --fallback-to-build`, which can occur with Node.js version 15. The solution is to downgrade the Node.js version to 14. ```shell # Downgrade Node.js to v14 if currently using v15 # Example using nvm: nvm install 14 nvm use 14 ``` -------------------------------- ### Set FFmpeg Path for FFTcreator Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/installation.md This code snippet demonstrates how to set the FFmpeg path for FFTcreator if it's not globally installed. This is crucial for FFTcreator to locate and utilize FFmpeg for video processing. ```javascript FFCreator.setFFmpegPath('...'); ``` -------------------------------- ### FFSubtitle Constructor and Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Documentation for the FFSubtitle constructor and its associated methods for handling subtitles. ```APIDOC ## FFSubtitle Class ### new FFSubtitle(conf) FFSubtitle constructor. Used for subtitles, can be used in conjunction with voice-to-subtitle TTS. #### Parameters - **conf** (object) - FFNode related configuration items - **conf.text** (string) - the text of this instance - **conf.style** (object) - this text instance's style - **conf.scale** (number) - scale of FFNode - **conf.rotate** (number) - rotation of FFNode - **conf.opacity** (number) - opacity of FFNode #### Example: ```javascript const text = "《街头霸王5》是卡普空使用虚幻引擎开发的3D格斗游戏."; const subtitle = new FFSubtitle({ x: 320, y: 520 }); subtitle.setText(text); ``` ### ffSubtitle.setFrameBuffer(frameBuffer) Set frame buffer. #### Parameters - **frameBuffer** (buffer) - frame buffer ### ffSubtitle.setSpeech(speech) Set up voice narration. #### Parameters - **speech** (string) - voice narration ### ffSubtitle.setAudio(speech) Set up voice dialogue. #### Parameters - **speech** (string) - voice narration ### ffSubtitle.setText(text) Set the text for the subtitle. #### Parameters - **text** (string) - the subtitle text ### ffSubtitle.setRegexp(regexp) Set a regular expression for text processing. #### Parameters - **regexp** (RegExp) - the regular expression ### ffSubtitle.setFontSize(fontSize) Set the font size for the subtitle. #### Parameters - **fontSize** (number) - the font size ### ffSubtitle.setDuration(duration) Set the duration for the subtitle display. #### Parameters - **duration** (number) - the subtitle duration ### ffSubtitle.setBackgroundColor(backgroundColor) Set the background color for the subtitle. #### Parameters - **backgroundColor** (string) - the background color ### ffSubtitle.setBackground(backgroundColor) Set the background for the subtitle (alias for setBackgroundColor). #### Parameters - **backgroundColor** (string) - the background color ### ffSubtitle.setColor(color) Set the text color for the subtitle. #### Parameters - **color** (string) - the text color ### ffSubtitle.setFont(file) Set the font file for the subtitle. #### Parameters - **file** (string) - path to the font file ### ffSubtitle.setStyle(style) Set the style object for the subtitle. #### Parameters - **style** (object) - the style object ``` -------------------------------- ### Configure FFCreator Cache Format and Quality Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/qa/qa.md Allows customization of FFCreator's cache format and quality to manage disk space and processing speed. By default, FFCreator uses raw format for speed and quality. Changing `cacheType` to 'jpg' or 'png' significantly reduces cache size at the cost of slightly slower processing. ```javascript cacheType: 'jpg', // or png cacheQuality: 70 // default 80 ``` -------------------------------- ### Install ffcreatorlite npm package Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/lite.md Installs the ffcreatorlite npm package using the npm install command. This package is a core dependency for the FFcreator functionality. ```shell npm i ffcreatorlite --save ``` -------------------------------- ### FFNode: Check Readiness (JavaScript) Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Shows how to asynchronously check if all necessary resources and actions for an FFNode are prepared. This is crucial for ensuring smooth rendering and preventing errors. ```javascript ffnode.isReady().then(() => { // All resources are ready }); ``` -------------------------------- ### FFImage: Initialize and Add Effect (JavaScript) Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Demonstrates how to create an FFImage instance with specified properties and apply a slide-in animation effect. This is useful for displaying images with dynamic entry animations. ```javascript const img = new FFImage({ path: "path/to/your/image.png", x: 94, y: 271, width: 375, height: 200, resetXY: true }); img.addEffect("slideInDown", 1.2, 0); scene.addChild(img); ``` -------------------------------- ### Control Creator Lifecycle and Events Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/useage.md Manages the FFCreator process, including starting the rendering, closing logging output, and handling events like 'start' and 'error'. ```javascript creator.start(); creator.closeLog(); creator.on('start', () => { console.log(`FFCreator start`); }); creator.on('error', e => { ``` -------------------------------- ### FFSubtitle Constructor and Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Creates an FFSubtitle component, which can be used for displaying text, often in conjunction with voice-to-subtitle functionality. It allows setting text content, speech, audio, styling, and appearance properties. ```javascript const text = "《街头霸王5》是卡普空使用虚幻引擎开发的3D格斗游戏."; const subtitle = new FFSubtitle({ x: 320, y: 520 }); subtitle.setText(text); subtitle.setSpeech("This is a speech narration."); subtitle.setAudio("This is a dialogue."); subtitle.setFontSize(24); subtitle.setColor("#FFFFFF"); subtitle.setBackgroundColor("rgba(0,0,0,0.5)"); ``` -------------------------------- ### FFVtuber Constructor and Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Documentation for the FFVtuber class, including its constructor and methods for setting textures, speed, and period. ```APIDOC ## FFVtuber ### new FFVtuber(conf) FFVtuber constructor. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * **conf** (object) - Required - FFNode related configuration items * **conf.path** (string) - Optional - the path of this video * **conf.width** (number) - Optional - the width of this video * **conf.height** (number) - Optional - this width of this video * **conf.scale** (number) - Optional - scale of FFNode * **conf.rotate** (number) - Optional - rotation of FFNode * **conf.opacity** (number) - Optional - opacity of FFNode ### Request Example ```json { "conf": { "x": 320, "y": 520, "path": "/path/to/video.mp4" } } ``` ### Response #### Success Response (200) * **None** #### Response Example ```json // No response body ``` ## FFVtuber ### ffVtuber.clone() Get a cloned object. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * None ### Request Example ```json // No request body ``` ### Response #### Success Response (200) * **FFVtuber** (FFVtuber) - cloned object #### Response Example ```json // FFVtuber object ``` ## FFVtuber ### ffVtuber.setTexturePacker(texture, json) Set up an animated sprite texture. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * **texture** (string) - Required - animated sprite texture * **json** (string) - Required - sprite texture data map ### Request Example ```json { "texture": "path/to/texture.png", "json": "path/to/texture.json" } ``` ### Response #### Success Response (200) * **None** #### Response Example ```json // No response body ``` ## FFVtuber ### ffVtuber.setTexture(texture, json) Set up a sprite texture. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * **texture** (string) - Required - sprite texture * **json** (string) - Required - sprite texture data map ### Request Example ```json { "texture": "path/to/texture.png", "json": "path/to/texture.json" } ``` ### Response #### Success Response (200) * **None** #### Response Example ```json // No response body ``` ## FFVtuber ### ffVtuber.setSpeed(speed) Set the animation speed. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * **speed** (number) - Required - animation speed ### Request Example ```json { "speed": 2 } ``` ### Response #### Success Response (200) * **None** #### Response Example ```json // No response body ``` ## FFVtuber ### ffVtuber.setPeriod(period) Set the animation period. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * **period** (array) - Required - animation period ### Request Example ```json { "period": [0, 1, 2, 3, 4, 5] } ``` ### Response #### Success Response (200) * **None** #### Response Example ```json // No response body ``` ## FFVtuber ### ffVtuber.getPeriod() Get the animation period. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * None ### Request Example ```json // No request body ``` ### Response #### Success Response (200) * **period** (array) - The animation period #### Response Example ```json { "period": [0, 1, 2, 3, 4, 5] } ``` ## FFVtuber ### ffVtuber.start() Start the animation. #### Parameters ##### Path Parameters * None ##### Query Parameters * None ##### Request Body * None ### Request Example ```json // No request body ``` ### Response #### Success Response (200) * **None** #### Response Example ```json // No response body ``` ``` -------------------------------- ### FFAlbum: Constructor and Initialization Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Initializes an FFAlbum component with a list of images and layout properties. Supports setting position, width, and height. ```javascript const album = new FFAlbum({ list: [img1, img2, img3, img4], x: 100, y: 100, width: 500, height: 300 }); ``` -------------------------------- ### Implement Koa.js GET Endpoint for Video Production Progress Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/guide/koa.md This code defines a GET endpoint in Koa.js for polling video production progress. It takes a `taskid` as a query parameter and uses `FFCreatorCenter.getProgress` to retrieve the current progress status, returning it in the response. ```javascript router.get('/progress', async (ctx, next) => { const taskid = ctx.request.query.taskid; // Task id const progress = FFCreatorCenter.getProgress(taskid); // You can also get the production status complete // const state = FFCreatorCenter.getTaskState(taskid); ctx.body = {msg:`${taskid}进度为${progress}`, data:{ progress, taskid }}; }); ``` -------------------------------- ### FFScene: Get Real Duration Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Retrieves the actual calculated duration the scene will stay on screen. ```javascript ffScene.getRealDuration() ``` -------------------------------- ### FFImage API Source: https://github.com/tnfe/ffcreator/blob/master/docs/api/api.md Represents an image component. Includes constructor and methods for getting image properties. ```APIDOC ## FFImage Class ### new FFImage(conf) FFImage constructor. Creates an image component-based display component. - **Parameters**: - **conf** (object) - Required - FFNode related configuration items. - **conf.path** (string) - Required - Path to the image. - **conf.x** (number) - Optional - x coordinate of FFNode. - **conf.y** (number) - Optional - y coordinate of FFNode. - **conf.width** (number) - Optional - Width of the image. - **conf.height** (number) - Optional - Height of the image. - **conf.resetXY** (boolean) - Optional - Whether to reset X/Y coordinates. - **conf.scale** (number) - Optional - Scale of FFNode. - **conf.rotate** (number) - Optional - Rotation of FFNode. - **conf.opacity** (number) - Optional - Opacity of FFNode. ### getPath() Get the path to the image. - **Method**: `getPath()` - **Endpoint**: N/A - **Returns**: `string` - img path ``` -------------------------------- ### FFCreator Constructor and Static Methods Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Initialization and static utility methods for FFCreator. ```APIDOC ## new FFCreator(conf) ### Description FFCreator constructor. ### Method POST ### Endpoint /ffcreator ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **conf** (object) - FFCreator related configuration items. ### Request Example ```json { "conf": { "logLevel": "info" } } ``` ### Response #### Success Response (200) - **message** (string) - Initialization success message. #### Response Example ```json { "message": "FFCreator initialized successfully." } ``` ## FFCreator.setFFmpegPath(path) ### Description Sets the path to the FFmpeg executable. ### Method PUT ### Endpoint /ffcreator/ffmpeg/path ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **path** (string) - The absolute path to the FFmpeg executable. ### Request Example ```json { "path": "/usr/local/bin/ffmpeg" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "FFmpeg path set successfully." } ``` ## FFCreator.setFFprobePath(path) ### Description Sets the path to the FFprobe executable. ### Method PUT ### Endpoint /ffcreator/ffprobe/path ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **path** (string) - The absolute path to the FFprobe executable. ### Request Example ```json { "path": "/usr/local/bin/ffprobe" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "FFprobe path set successfully." } ``` ``` -------------------------------- ### Set FFmpeg Path for FFCreator Source: https://github.com/tnfe/ffcreator/blob/master/docs/en/api/api.md Configures the installation path for the FFmpeg executable used by FFCreator. This is essential for video processing operations. ```javascript FFCreator.setFFmpegPath(path); ```