Skip to content

Feature: a useVideo() addon #66

@sc0ttj

Description

@sc0ttj

Create a useVideo addon that returns a video object that can be filtered, cropped, edited, etc.

It should extend Ctx canvas module, adding the extra methods needed for video editing:

  • split audio and video into separate channels/streams
    • can control both at same time (for playback etc)
    • can control each on its own (for filters, etc)
    • control the audio channel/stream using useAudio
  • filters:
    • cropping, zooming, panning, stretching, etc
    • colours/hues/sepia/etc
    • chromakey ("green screen", remove a colour)
  • overlays:
    • timestamps, titles, branded lower thirds, etc
  • can change all settings, even during playback
  • save the edited video to video file or video element

Keep it small & simple:

  • whole useVideo addon to be less then 15kb minified & gzipped
  • work in browser and NodeJS (with node-canvas)
  • no ffmpeg, only use the regular HTML5 Canvas API
  • very similar API and usage with useAudio addon
  • no other dependencies

Example:

const myVideo = useVideo({
  src: 'path/to/file.mp4',   // could also be a stream, File blob, <video> Element, webcam device, etc
  name: 'myVideo',
  container: canvasElem, // if not given, create an off-screen canvas to use instead
  startOffset: 0,
  endOffset: 0,
  filters: { 
    // ...filters and their settings here
  },
});

myVideo.play();

myVideo.settings({
  // ...change any settings defined above
});

myVideo.toElement(videoElem => { ... })

myVideo.saveAs('filename.mp4'); // raises the browsers "save file" dialog

Notes:

  • Using WebM and HEVC video formats, you can have native transparent HTML5 video in all browsers as of late 2020.

Further reading:

Other projects:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions