https://github.com/samst-one/imagesequencer
A well-tested iOS framework for producing a video from a sequence of images.
https://github.com/samst-one/imagesequencer
animation image-processing ios swift timelapse
Last synced: 8 months ago
JSON representation
A well-tested iOS framework for producing a video from a sequence of images.
- Host: GitHub
- URL: https://github.com/samst-one/imagesequencer
- Owner: samst-one
- License: mit
- Created: 2023-10-02T16:25:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-28T18:56:29.000Z (about 2 years ago)
- Last Synced: 2025-10-21T09:53:50.401Z (8 months ago)
- Topics: animation, image-processing, ios, swift, timelapse
- Language: Swift
- Homepage: https://samst.one
- Size: 871 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ImageSequencer
[](https://app.bitrise.io/app/4e19a931-761f-4f2b-b360-dcf083ca551c)
[](https://swiftpackageindex.com/samst-one/ImageSequencer)
[](https://swiftpackageindex.com/samst-one/ImageSequencer)
## Overview
ImageSequencer is a Swift framework for iOS, macOS, tvOS that allows you to create videos from a selection of images. Developed by [Sam Stone](https://samst.one).
In use in production with [Lapsey](https://apps.apple.com/gb/app/lapsey/id6467548808). Create beautiful time-lapses on iOS - find out more [here](https://lapsey.app).
The API can be found in the ``ImageSequencerController`` interface.
## Install
Go to **File > Swift Packages > Add Package Dependency** and add the following URL:
```
https://github.com/samst-one/ImageSequencer
```
## Usage
1. First we need to import the `ImageSequencer` into our project, we do this by importing the framework
```swift
import ImageSequencer
```
2. Next we need to create a `ImageSequencerController` object. The `ImageSequencerController` acts as the API for the package. We use the `ImageSequencerFactory` to do this. We also pass in the settings for the video we want to create. To create the `ImageSequencerController`, we do:
```swift
let outputUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("\(UUID().uuidString).mp4")
let renderSettings = RenderSettings(bitrate: 10000000,
size: CGSize(width: 1920,
height: 1080),
fps: 24,
outputUrl: outputUrl)
let controller = try? ImageSequencerFactory.make(settings: settings)
```
The `make` method has the ability to throw.
3. With the `controller`, we can now access the API. We first must start of some internal `ImageSequencer` processes before rendering. To do this, call:
```swift
controller.start()
```
4. When you have the images you want to render to a video, we can call the `render` function below. A breakdown of the parameters are as follows.
- Parameters:
- `images`: The collection of images you wish to render in URL format.
- `didAddFrame`: A closure that returns a double representing the percentage of rendering completed.
- `completion`: A closure thats called when all the images have been rendered out. It returns an optional `Error`.
So the code looks a bit like this:
```swift
controller?.render(images: images) { percent in
} completion: { error in
}
```
5. Once the `completion` handler has been called without an error, you call the `finish()` method to produce the video. The video can be found at the output URL that was provided in the render settings.
```swift
controller?.finish { outputUrl in
// Video now available at output URL provided.
}
```
## Putting it all together
In conclusion, to render out an sequence of images, use full code is below:
```swift
let outputUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("\(UUID().uuidString).mp4")
let renderSettings = RenderSettings(bitrate: 10000000,
size: CGSize(width: 1920,
height: 1080),
fps: 24,
outputUrl: outputUrl)
let controller = try? ImageSequencerFactory.make(settings: settings)
controller?.start()
controller?.render(images: images) { percent in
// Update the user on progress here.
} completion: { error in
if error == nil {
controller?.finish { outputUrl in
// Video now available at output URL provided.
}
}
}
```
A sample app is included.