Skip to main content

Time-lapse movie assembly

Project description

Time-Lapse assembling

This repo contains scripts used to compile Time-lapse movies using ffmpeg. The ffmpeg utility is controlled via the ffmpeg-python wrapper.

Installation

This package requires the ffmpeg tool to be installed.

brew install ffmpeg

Then install this package:

pip install time-lapse

Additionally, when using the verbose output option a graph will be rendered using graphviz, this requires the Graphviz library and the related Python package:

brew install graphviz
pip install time-lapse[graph]

Codec

For near-universal compatibility the H.264 codec is used. The following section describe some of the choices for specific configuration options.

See the ffmpeg wiki for additional information: https://trac.ffmpeg.org/wiki/Encode/H.264

Constant Rate Factor

Use -crf 22 to set a constant rate factor, which means the overall quality of the movie should be constant. So bitrate varies to ensure this. Higher value is slower quality. The quality with 22 seems reasonable. Check if it streams nicely to users on slower bandwidth.. otherwise a high crf (lower quality) might be needed.

Preset

Use -preset slower to improve the compression ratio for the selected quality (crf), without taking too much time. The slower preset is still fast enough for me.

Faststart

Set -movflags +faststart to allow the movie to quickly start playing, while it is still loading.

Quicktime support

The codec defaults to YUV 444, which is not supported by Quicktime. So add -pix_fmt yuv420p to fix Quicktime support.

Input

Select input frames

Use frames as input by giving a glob pattern which matches the desired images. Usually these will be tiff images so use -pattern_type glob -i "*.tiff".

Framerate

When using image sequences as input the framerate of the desired output should be given using -framerate 30.

Filters

Commonly used filters:

Steps

  • First deflicker the video to ensure it is equally deflickered for all outputs
  • Then scale and crop the videos to fit the desired final resolutions
  • Then add the watermark (which should not be deflickered)

Scale video

Add scaling to ensure it fits in given dimensions. Negative values for width or height make the encoder figure out the size by itself, keeping the aspect ratio of the source. The integer of the negative value, i.e. 4 for -4, means that the size should be devisble by that value. TODO: does it just scale/squish the video or crop?:

-vf scale=1920:-2
-vf scale=960:540:aspect..

Convert movie

Using time-lapse and ffmpeg-python:

import ffmpeg

from time_lapse import output

NAME = 'test'
PATTERN = '*.tiff'

input = (
    ffmpeg
    .input(PATTERN, pattern_type='glob', framerate=24)
    .filter_('deflicker', mode='pm', size=10)
)
output.create_outputs(input, NAME, verbose=False)

Inspection

By passing verbose=True to create outputs the following ffmpeg-python inspection methods will be performed.

Show the ffmpeg command options ffmpeg-python would use:

.get_args()

By using graphviz the graph from input to output can be shown using:

.view()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

time-lapse-1.tar.gz (51.6 kB view details)

Uploaded Source

Built Distribution

time_lapse-1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file time-lapse-1.tar.gz.

File metadata

  • Download URL: time-lapse-1.tar.gz
  • Upload date:
  • Size: 51.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for time-lapse-1.tar.gz
Algorithm Hash digest
SHA256 8214f598823019352f3d685c03a60533e8d7c56523e2362232d472870a997374
MD5 83d1a35aaa6ba71d3272fa4a87ec67bd
BLAKE2b-256 f050552cec99dbc74f10f45de9c546791f592c307a3310e9ca8af75b75124068

See more details on using hashes here.

Provenance

File details

Details for the file time_lapse-1-py3-none-any.whl.

File metadata

  • Download URL: time_lapse-1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for time_lapse-1-py3-none-any.whl
Algorithm Hash digest
SHA256 90694e90931dce2da0a28ba8fd1567c53916c0a38b4500bb9801e3cc45600edd
MD5 1ac53c72b5d5b7f10590f15b76945a25
BLAKE2b-256 61ce813877abb5537a015336d084b740cdf73820de0f5bda94e9f480c3b1538a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page