Convert Figma logo to code with AI

mifi logoeditly

Slick, declarative command line video editing & API

4,722
306
4,722
127

Top Related Projects

20,002

🎥 Make videos programmatically with React

A fluent API to FFMPEG (http://www.ffmpeg.org)

Python bindings for FFmpeg - with complex filtering support

Quick Overview

Editly is a Node.js library and command-line tool for creating and editing videos programmatically. It allows users to combine images, videos, audio, and text to create dynamic video content without the need for traditional video editing software.

Pros

  • Easy-to-use API for programmatic video creation
  • Supports a wide range of input formats and effects
  • Can be used as both a library and a command-line tool
  • Extensible with custom transitions and effects

Cons

  • Requires FFmpeg to be installed separately
  • Limited advanced video editing features compared to professional software
  • Performance may be slower for complex projects
  • Documentation could be more comprehensive for advanced use cases

Code Examples

  1. Creating a simple video with text and image:
const editly = require('editly');

editly({
  outPath: './output.mp4',
  width: 1280,
  height: 720,
  clips: [
    { duration: 5, layers: [
      { type: 'title', text: 'Hello World' },
      { type: 'image', path: './background.jpg' }
    ]}
  ]
}).then(() => console.log('Video created!'));
  1. Adding audio to a video clip:
const editly = require('editly');

editly({
  outPath: './output.mp4',
  clips: [
    { duration: 10, layers: [
      { type: 'video', path: './input.mp4' },
      { type: 'audio', path: './music.mp3', volume: 0.5 }
    ]}
  ]
}).then(() => console.log('Video with audio created!'));
  1. Applying a transition between clips:
const editly = require('editly');

editly({
  outPath: './output.mp4',
  clips: [
    { duration: 3, layers: [{ type: 'title', text: 'First clip' }] },
    { duration: 3, layers: [{ type: 'title', text: 'Second clip' }] }
  ],
  transitions: [{ name: 'fade', duration: 0.5 }]
}).then(() => console.log('Video with transition created!'));

Getting Started

  1. Install FFmpeg on your system
  2. Install editly via npm:
    npm install editly
    
  3. Create a new JavaScript file (e.g., video.js) and add the following code:
    const editly = require('editly');
    
    editly({
      outPath: './my-video.mp4',
      width: 1280,
      height: 720,
      clips: [
        { duration: 5, layers: [
          { type: 'title', text: 'My First Editly Video' }
        ]}
      ]
    }).then(() => console.log('Video created successfully!'));
    
  4. Run the script:
    node video.js
    

Competitor Comparisons

20,002

🎥 Make videos programmatically with React

Pros of Remotion

  • More powerful and flexible, allowing for complex animations and interactions
  • Better suited for larger, more sophisticated video projects
  • Integrates well with React ecosystem and components

Cons of Remotion

  • Steeper learning curve, especially for those unfamiliar with React
  • Requires more setup and configuration compared to Editly
  • May be overkill for simple video editing tasks

Code Comparison

Editly example:

const edit = await editly({
  outPath: './output.mp4',
  clips: [
    { duration: 5, layers: [{ type: 'title', text: 'Hello World' }] },
    { duration: 5, layers: [{ type: 'video', path: './video.mp4' }] },
  ],
});

Remotion example:

export const MyVideo = () => {
  return (
    <Composition
      id="MyComp"
      component={MyComp}
      durationInFrames={150}
      fps={30}
      width={1920}
      height={1080}
    />
  );
};

Editly focuses on a more straightforward, configuration-based approach, while Remotion leverages React components for creating video content. Editly is better suited for quick, simple video edits, whereas Remotion offers more flexibility and power for complex video projects, especially those requiring advanced animations or interactivity.

A fluent API to FFMPEG (http://www.ffmpeg.org)

Pros of fluent-ffmpeg

  • More comprehensive and flexible FFmpeg wrapper
  • Supports a wider range of FFmpeg features and operations
  • Better suited for complex video processing tasks

Cons of fluent-ffmpeg

  • Steeper learning curve due to its extensive API
  • Requires more code to achieve simple video editing tasks
  • Less focused on creating video slideshows or simple edits

Code Comparison

fluent-ffmpeg:

const ffmpeg = require('fluent-ffmpeg');

ffmpeg('input.mp4')
  .videoFilters('fade=in:0:30')
  .output('output.mp4')
  .run();

editly:

const editly = require('editly');

editly({
  outPath: 'output.mp4',
  clips: [{ duration: 4, layers: [{ type: 'video', path: 'input.mp4' }] }],
}).render();

Summary

fluent-ffmpeg is a powerful and flexible FFmpeg wrapper that provides extensive control over video processing tasks. It's well-suited for complex operations but may require more code for simple edits. editly, on the other hand, is designed for creating video slideshows and simple edits with less code, making it more accessible for basic video creation tasks. The choice between the two depends on the complexity of the project and the level of control required over the video processing operations.

Python bindings for FFmpeg - with complex filtering support

Pros of ffmpeg-python

  • More flexible and powerful, offering direct access to FFmpeg's extensive capabilities
  • Better suited for complex video processing tasks and fine-grained control
  • Larger community and more extensive documentation

Cons of ffmpeg-python

  • Steeper learning curve, requiring more knowledge of FFmpeg and video processing
  • Less user-friendly for simple video editing tasks
  • Requires more code to achieve basic video editing operations

Code Comparison

ffmpeg-python:

import ffmpeg

(
    ffmpeg
    .input('input.mp4')
    .filter('scale', 1280, 720)
    .output('output.mp4')
    .run()
)

editly:

const editly = require('editly');

editly({
  outPath: 'output.mp4',
  clips: [{ duration: 5, layers: [{ type: 'video', path: 'input.mp4' }] }],
  width: 1280,
  height: 720,
}).then(() => console.log('Done!'));

Summary

ffmpeg-python offers more power and flexibility for advanced video processing tasks, while editly provides a simpler, more user-friendly approach for basic video editing. ffmpeg-python is better suited for developers who need fine-grained control and are comfortable with FFmpeg, while editly is ideal for those seeking quick and easy video composition with less code.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Discord NPM version Build status PayPal

Editly is a tool and framework for declarative NLE (non-linear video editing) using Node.js and ffmpeg. Editly allows you to easily and programmatically create a video from a set of clips, images, audio and titles, with smooth transitions and music overlaid.

Editly has a simple CLI for quickly assembling a video from a set of clips or images, or you can use its more flexible JavaScript API.

Inspired by ffmpeg-concat, editly is much faster and doesn't require much storage because it uses streaming editing. Editly aims to be very extensible and feature rich with a pluggable interface for adding new dynamic content.

demo

This GIF / YouTube was created with this command: "editly commonFeatures.json5". See more examples here.

Features

  • Edit videos with code! 🤓
  • Declarative API with fun defaults
  • Create colorful videos with random colors generated from aesthetically pleasing palettes and random effects
  • Supports any input size, e.g. 4K video and DSLR photos
  • Can output to any dimensions and aspect ratio, e.g. Instagram post (1:1), Instagram story (9:16), YouTube (16:9), or any other dimensions you like.
  • Content is scaled and letterboxed automatically, even if the input aspect ratio is not the same and the framerate will be converted.
  • Speed up / slow down videos automatically to match the cutFrom/cutTo segment length with each clip's duration
  • Overlay text and subtitles on videos, images or backgrounds
  • Accepts custom HTML5 Canvas / Fabric.js JavaScript code for custom screens or dynamic overlays
  • Render custom GL shaders (for example from shadertoy)
  • Can output GIF
  • Overlay transparent images or even videos with alpha channel
  • Show different sub-clips for parts of a clips duration (B-roll)
  • Picture-in-picture
  • Vignette
  • Preserve/mix multiple audio sources
  • Automatic audio crossfading
  • Automatic audio ducking and normalization

Use cases

  • Create a slideshow from a set of pictures with text overlay
  • Create a fast-paced trailer or promo video
  • Create a tutorial video with help text
  • Create news stories
  • Create an animated GIF
  • Resize video to any size or framerate and with automatic letterboxing/cropping (e.g. if you need to upload a video somewhere but the site complains Video must be 1337x1000 30fps)
  • Create a podcast with multiple mixed tracks

See examples

Requirements

Installing

npm i -g editly

Usage: Command line video editor

Run editly --help for usage

Create a simple randomized video edit from videos, images and text with an audio track:

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.mp3

Or create an MP4 (or GIF) from a JSON or JSON5 edit spec (JSON5 is just a more user friendly JSON format):

editly my-spec.json5 --fast --keep-source-audio --out output.gif

For examples of how to make a JSON edit spec, see below or examples.

Without --fast, it will default to using the width, height and frame rate from the first input video. All other clips will be converted to these dimensions. You can of course override any or all of these parameters.

  • TIP: Use this tool in conjunction with LosslessCut
  • TIP: If you need catchy music for your video, have a look at this YouTube or the YouTube audio library. Then use youtube-dl to download the video, and then point --audio-file-path at the video file. Be sure to respect their license!

JavaScript library

import editly from 'editly';

// See editSpec documentation
await editly(editSpec)

Edit spec

Edit specs are JavaScript / JSON objects describing the whole edit operation with the following structure:

{
  outPath,
  width,
  height,
  fps,
  allowRemoteRequests: false,
  defaults: {
    duration: 4,
    transition: {
      duration: 0.5,
      name: 'random',
      audioOutCurve: 'tri',
      audioInCurve: 'tri',
    },
    layer: {
      fontPath,
      // ...more layer defaults
    },
    layerType: {
      'fill-color': {
        color: '#ff6666',
      }
      // ...more per-layer-type defaults
    },
  },
  clips: [
    {
      transition,
      duration,
      layers: [
        {
          type,
          // ...more layer-specific options
        }
        // ...more layers
      ],
    }
    // ...more clips
  ],
  audioFilePath,
  loopAudio: false,
  keepSourceAudio: false,
  clipsAudioVolume: 1,
  outputVolume: 1,
  audioTracks: [
    {
      path,
      mixVolume: 1,
      cutFrom: 0,
      cutTo,
      start: 0,
    },
    // ...more audio tracks
  ],
  audioNorm: {
    enable: false,
    gaussSize: 5,
    maxGain: 30,
  }

  // Testing options:
  enableFfmpegLog: false,
  verbose: false,
  fast: false,
}

Parameters

ParameterCLI equivalentDescriptionDefault
outPath--outOutput path (mp4, mkv), can also be a .gif
width--widthWidth which all media will be converted to640
height--heightHeight which all media will be converted toauto based on width and aspect ratio of first video
fps--fpsFPS which all videos will be converted toFirst video FPS or 25
customOutputArgsSpecify custom output codec/format arguments for ffmpeg (See example)auto (h264)
allowRemoteRequests--allow-remote-requestsAllow remote URLs as pathsfalse
fast--fast, -fFast mode (low resolution and FPS, useful for getting a quick preview ⏩)false
defaults.layer.fontPath--font-pathSet default font to a .ttfSystem font
defaults.layer.*Set any layer parameter that all layers will inherit
defaults.duration--clip-durationSet default clip duration for clips that don't have an own duration4sec
defaults.transitionAn object { name, duration } describing the default transition. Set to null to disable transitions
defaults.transition.duration--transition-durationDefault transition duration0.5sec
defaults.transition.name--transition-nameDefault transition type. See Transition typesrandom
defaults.transition.audioOutCurveDefault fade out curve in audio cross fadestri
defaults.transition.audioInCurveDefault fade in curve in audio cross fadestri
clips[]List of clip objects that will be played in sequence. Each clip can have one or more layers.
clips[].durationClip duration. See defaults.duration. If unset, the clip duration will be that of the first video layer.defaults.duration
clips[].transitionSpecify transition at the end of this clip. See defaults.transitiondefaults.transition
clips[].layers[]List of layers within the current clip that will be overlaid in their natural order (final layer on top)
clips[].layers[].typeLayer type, see below
clips[].layers[].startWhat time into the clip should this layer startsec
clips[].layers[].stopWhat time into the clip should this layer stopsec
audioTracks[]List of arbitrary audio tracks. See audio tracks.[]
audioFilePath--audio-file-pathSet an audio track for the whole video. See also audio tracks
loopAudio--loop-audioLoop the audio track if it is shorter than video?false
keepSourceAudio--keep-source-audioKeep source audio from clips?false
clipsAudioVolumeVolume of audio from clips relative to audioTracks. See audio tracks.1
outputVolume--output-volumeAdjust output volume (final stage). See example1e.g. 0.5 or 10dB
audioNorm.enableEnable audio normalization? See audio normalization.false
audioNorm.gaussSizeAudio normalization gauss size. See audio normalization.5
audioNorm.maxGainAudio normalization max gain. See audio normalization.30

Transition types

transition.name can be any of gl-transitions, or any of the following: directional-left, directional-right, directional-up, directional-down, random or dummy.

Layer types

See examples and commonFeatures.json5

Layer type 'video'

For video layers, if parent clip.duration is specified, the video will be slowed/sped-up to match clip.duration. If cutFrom/cutTo is set, the resulting segment (cutTo-cutFrom) will be slowed/sped-up to fit clip.duration. If the layer has audio, it will be kept (and mixed with other audio layers if present.)

ParameterDescriptionDefault
pathPath to video file
resizeModeSee Resize modes
cutFromTime value to cut from0sec
cutToTime value to cut toend of videosec
widthWidth relative to screen width10 to 1
heightHeight relative to screen height10 to 1
leftX-position relative to screen width00 to 1
topY-position relative to screen height00 to 1
originXX anchorleftleft or right
originYY anchortoptop or bottom
mixVolumeRelative volume when mixing this video's audio track with others1

Layer type 'audio'

Audio layers will be mixed together. If cutFrom/cutTo is set, the resulting segment (cutTo-cutFrom) will be slowed/sped-up to fit clip.duration. The slow down/speed-up operation is limited to values between 0.5x and 100x.

ParameterDescriptionDefault
pathPath to audio file
cutFromTime value to cut from0sec
cutToTime value to cut toclip.durationsec
mixVolumeRelative volume when mixing this audio track with others1

Layer type 'detached-audio'

This is a special case of audioTracks that makes it easier to start the audio relative to clips start times without having to calculate global start times.

detached-audio has the exact same properties as audioTracks, except start time is relative to the clip's start.

Example of detached audio tracks

Layer type 'image'

Full screen image

ParameterDescriptionDefault
pathPath to image file
resizeModeSee Resize modes

See also See Ken Burns parameters.

Layer type 'image-overlay'

Image overlay with a custom position and size on the screen. NOTE: If you want to use animated GIFs use video instead.

ParameterDescriptionDefault
pathPath to image file
positionSee Position parameter
widthWidth (from 0 to 1) where 1 is screen width
heightHeight (from 0 to 1) where 1 is screen height

See also Ken Burns parameters.

Layer type 'title'

  • fontPath - See defaults.layer.fontPath
  • text - Title text to show, keep it short
  • textColor - default #ffffff
  • position - See Position parameter

See also Ken Burns parameters

Layer type 'subtitle'

  • fontPath - See defaults.layer.fontPath
  • text - Subtitle text to show
  • textColor - default #ffffff

Layer type 'title-background'

Title with background

  • text - See type title
  • textColor - See type title
  • background - { type, ... } - See type radial-gradient, linear-gradient or fill-color
  • fontPath - See type title

Layer type 'news-title'

  • fontPath - See defaults.layer.fontPath
  • text
  • textColor - default #ffffff
  • backgroundColor - default #d02a42
  • position - See Position parameter

Layer type 'slide-in-text'

  • fontPath - See defaults.layer.fontPath
  • text
  • fontSize
  • charSpacing
  • color
  • position - See Position parameter

Layer type 'fill-color', 'pause'

  • color - Color to fill background, default: randomize

Layer type 'radial-gradient'

  • colors - Array of two colors, default: randomize

Layer type 'linear-gradient'

  • colors - Array of two colors, default: randomize

Layer type 'rainbow-colors'

🌈🌈🌈

Layer type 'canvas'

See customCanvas.js

  • func - Custom JavaScript function

Layer type 'fabric'

See customFabric.js

  • func - Custom JavaScript function

Layer type 'gl'

Loads a GLSL shader. See gl.json5 and rainbow-colors.frag

  • fragmentPath
  • vertexPath (optional)

Arbitrary audio tracks

audioTracks property can optionally contain a list of objects which specify audio tracks that can be started at arbitrary times in the final video. These tracks will be mixed together (mixVolume specifying a relative number for how loud each track is compared to the other tracks). Because audio from clips will be mixed separately from audioTracks, clipsAudioVolume specifies the volume of the combined audio from clips relative to the volume of each of the audio tracks from audioTracks.

ParameterDescriptionDefault
audioTracks[].pathFile path for this track
audioTracks[].mixVolumeRelative volume for this track1
audioTracks[].cutFromTime value to cut source file from0sec
audioTracks[].cutToTime value to cut source file tosec
audioTracks[].startHow many seconds into video to start this audio track0sec

The difference between audioTracks and Layer type 'audio' is that audioTracks will continue to play across multiple clips and can start and stop whenever needed.

See audioTracks example

See also Layer type 'detached-audio'.

Audio normalization

You can enable audio normalization of the final output audio. This is useful if you want to achieve Audio Ducking (e.g. automatically lower volume of all other tracks when voice-over speaks).

audioNorm parameters are documented here.

Example of audio ducking

Resize modes

resizeMode - How to fit image to screen. Can be one of:

  • contain - All the video will be contained within the frame and letterboxed
  • contain-blur - Like contain, but with a blurred copy as the letterbox
  • cover - Video be cropped to cover the whole screen (aspect ratio preserved)
  • stretch - Video will be stretched to cover the whole screen (aspect ratio ignored).

Default contain-blur.

See:

Position parameter

Certain layers support the position parameter

position can be one of either:

  • top, bottom center, top-left, top-right, center-left, center-right, bottom-left, bottom-right
  • An object { x, y, originX = 'left', originY = 'top' }, where { x: 0, y: 0 } is the upper left corner of the screen, and { x: 1, y: 1 } is the lower right corner, x is relative to video width, y to video height. originX and originY are optional, and specify the position's origin (anchor position) of the object.

See position.json5

Ken Burns parameters

ParameterDescriptionDefault
zoomDirectionZoom direction for Ken Burns effect: in, out, left, right or null to disable
zoomAmountZoom amount for Ken Burns effect0.1

Docker

This should help you use editly as a containerized CLI, without worrying about getting all the right versions of dependencies on your system.

$ 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 .

Troubleshooting

  • If you get Error: The specified module could not be found., try: npm un -g editly && npm i -g --build-from-source editly (see #15)
  • If you get an error about gl returning null, see Requirements.
  • If you get an error /bin/sh: pkg-config: command not found, try to use newest Node.js LTS version

Donate 🙏

This project is maintained by me alone. The project will always remain free and open source, but if it's useful for you, consider supporting me. :) It will give me extra motivation to improve it.

Paypal

Thanks

This package would not exist without the support and help from all the contributors and sponsors!

Special thanks to:

See also

Videos made by you

Submit a PR if you want to share your videos or project created with editly here.


Made with ❤️ in 🇳🇴

More apps by mifi.no

Follow me on GitHub, YouTube, IG, Twitter for more awesome content!

NPM DownloadsLast 30 Days