editly
repository·master·Indexed 26 days ago
https://github.com/mifi/editlyA declarative non-linear video editing (NLE) tool and framework built on Node.js and ffmpeg. It allows developers to programmatically generate videos from clips, images, and audio using a JavaScript API or a CLI. Features include support for various aspect ratios, text overlays, GL shaders, and custom HTML5 Canvas/Fabric.js screens. Version 0.15.0-rc.1 is ESM only.
What's inside editly
- Editly is a tool and framework for declarative non-linear video editing (NLE) using Node.js and ffmpeg. It allows you to programmatically create videos from clips, images, audio, and titles using a streaming editing approach. It supports various aspect ratios (e.g., 1:1, 9:16, 16:9), automatic scaling/letterboxing, and features like text overlays, custom HTML5 Canvas/Fabric.js screens, and GL shaders.
Run editly using Docker
masterTo use
editlyas a containerized CLI without managing local dependencies, you can use the provided Docker Compose setup. This involves cloning the repository, setting up assets, and running the container.$ git clone https://github.com/mifi/editly.git $ cd editly/examples $ git clone https://github.com/mifi/editly-assets.git assets $ cd .. $ docker-compose up $ docker-compose run editly bash -c "cd examples && editly audio1.json5 --out /outputs/audio1.mp4" $ docker cp editly:/outputs/audio1.mp4 .Use the Editly CLI for quick video assembly
masterYou can use the Editly CLI to quickly assemble a video from a sequence of clips, images, and titles, or by providing a JSON/JSON5 edit specification file.
Quick randomized edit
Create a video by listing assets directly in the command:
editly \ title:'My video' \ clip1.mov \ clip2.mov \ title:'My slideshow' \ img1.jpg \ img2.jpg \ title:'THE END' \ --fast \ --audio-file-path /path/to/music.mp3Create video from an edit spec
Use a JSON or JSON5 file to define a complex edit:
editly my-spec.json5 --fast --keep-source-audio --out output.gifCLI Behavior
- By default (without
--fast), Editly uses the width, height, and frame rate from the first input video. All other clips will be converted to these dimensions. - Use
--fastto skip certain processing steps.
- By default (without
Install Editly via npm
masterInstall Editly globally using npm to use the Command Line Interface (CLI).
npm i -g editlyRequirements for Editly
masterTo use Editly, ensure you meet the following requirements:
- Operating System: Windows, MacOS, or Linux.
- Node.js: Latest LTS version is recommended (v12.16.2 or newer on MacOS).
- FFmpeg:
ffmpegandffprobemust be installed and available in yourPATH. - Linux Users: May require extra steps for
headless-glsystem dependencies. - Module System: Editly is ESM only.
Define an Edit Spec
masterAn Edit Spec is a JavaScript or JSON object that describes the entire video editing operation. It includes global settings (width, height, fps), default layer/transition settings, and a list of
clips. Each clip contains one or morelayersthat are overlaid in sequence.{ outPath, width, height, fps, allowRemoteRequests: false, defaults: { duration: 4, transition: { duration: 0.5, name: 'random', audioOutCurve: 'tri', audioInCurve: 'tri', }, layer: { fontPath, }, layerType: { 'fill-color': { color: '#ff6666', } }, }, clips: [ { transition, duration, layers: [ { type, } ], } ], audioFilePath, loopAudio: false, keepSourceAudio: false, clipsAudioVolume: 1, outputVolume: 1, audioTracks: [ { path, mixVolume: 1, cutFrom: 0, cutTo, start: 0, } ], audioNorm: { enable: false, gaussSize: 5, maxGain: 30, }, enableFfmpegLog: false, verbose: false, fast: false, }Run Editly using Docker Compose
masterYou can run Editly as a containerized service using Docker Compose. The service uses the
editly/editly:latestimage.To persist generated videos, the configuration uses a named volume
outputsmapped to/outputsinside the container. It also maps a local directory./examples/assets/to/app/examples/assets/inside the container to provide assets for editing tasks.services: editly: container_name: editly image: editly/editly:latest build: context: . dockerfile: Dockerfile volumes: - "outputs:/outputs" - ./examples/assets/:/app/examples/assets/ volumes: outputs:Use the editly CLI to create videos
masterThe
editlycommand allows you to create videos from the command line using either a sequence of clips or a JSON/JSON5 edit specification file.Basic Usage (Clip Sequence)
You can pass video files, images, or title screens directly as arguments. Title screens must be prefixed with
title:.$ editly title:'My video' clip1.mov clip2.mov title:'My slideshow' img1.jpgUsage with JSON/JSON5
You can provide a path to a JSON or JSON5 file containing a full edit specification.
$ editly my-editly.json5 --out output.gif$ editly title:'My video' clip1.mov clip2.mov title:'My slideshow' img1.jpg img2.jpg title:'THE END' --audio-file-path /path/to/music.mp3 --font-path /path/to/my-favorite-font.ttfTroubleshoot editly installation and runtime errors
masterIf you encounter issues while using
editly, check the following common solutions:- Error:
The specified module could not be found.: Reinstalleditlyby building from source:npm un -g editly && npm i -g --build-from-source editly. - Error:
gl returning null: Review the project's Requirements section (check system dependencies like OpenGL/WebGL support). - Error:
/bin/sh: pkg-config: command not found: Ensure you are using the newest Node.js LTS version.
- Error:
Use Video Layers
masterVideo layers allow you to play video files within a clip. If the
clip.durationis specified, the video will be automatically slowed or sped up to match that duration.Parameters:
type: Must be'video'.path: Path to the video file.resizeMode: How to fit the video to the screen (contain,contain-blur,cover,stretch). Default iscontain-blur.cutFrom/cutTo: Time values (seconds) to segment the source video.width/height: Relative size (0 to 1) compared to screen dimensions.left/top: X/Y position relative to screen (0 to 1).originX/originY: Anchor point (left/rightandtop/bottom).mixVolume: Relative volume for this video's audio.
Use Audio Layers and Tracks
masterThere are three ways to handle audio:
- Layer type 'audio': Part of a clip. Audio is mixed with other layers. If
cutFrom/cutTois set, the audio is sped up/slowed down to fit theclip.duration(limit: 0.5x to 100x). - Layer type 'detached-audio': Similar to
audioTracks, but thestarttime is relative to the start of the clip it is placed in. audioTracks[]: Arbitrary audio tracks that can play across multiple clips. They use global video time for thestartparameter.
Audio Track Parameters:
path: File path.mixVolume: Relative volume (default1).cutFrom/cutTo: Segment the source file.start: Seconds into the video to start this track.
- Layer type 'audio': Part of a clip. Audio is mixed with other layers. If
Use Editly as a JavaScript library
masterImport
editlyand call it with aneditSpecobject. Since Editly is ESM only, ensure your environment supports ES modules.import editly from "editly"; // See editSpec documentation await editly(editSpec);import editly from "editly"; // See editSpec documentation await editly(editSpec);