Eric Radman : a Journal

Blender Scripting

Blender unique as video editor because it runs on nearly any platform and unlike DaVinci Resolve, it does not require a dedicated GPU, and is compatible with Intel GPUs.

Unused Video Files

#
# List video files not used by .blend project
#

import os
import bpy

AllScenes = bpy.data.scenes

movie_ext = ['.MP4', '.mp4', '.MOV', '.mov', '.MKV', '.mkv']
project_path = os.path.dirname(bpy.data.filepath)
files = os.listdir(project_path)
movies = set(filter(lambda fn: os.path.splitext(fn)[1] in movie_ext, files))

project_movies = set()
for scene in AllScenes:
    sequences = scene.sequence_editor.sequences_all
    for seq in sequences:
        if seq.type == 'MOVIE':
            project_movies.add(seq.filepath.strip("/"))

for fn in movies.difference(project_movies):
    print(fn)

Run from the terminal by supplying a .blend file.

#!/bin/sh -eu

scriptdir=$(dirname $0)
blender "$1" --background --python $scriptdir/blender-unused-videos.py

Timelapse

The allows a video strip to be played back at an arbitrary multiple of the original frame rate, but the result is very harsh: each frame is a new cut. To improve this we can blur several frames together to simulate a slow shutter speed.

# merge 10 frames
in="DSCF1937.MP4"
fn=$(basename $in .MP4)

ffmpeg -y -i $in -c:v huffyuv -vf tmix=frames=10:weights="1 1 1 1 1 1 1 1 1 1" -an blur_$fn.avi
ffmpeg -y -i blur_$fn.avi -c:v huffyuv -filter:v "setpts=0.1*PTS" -an 10x-$fn.avi
rm blur_$fn.avi

One advantage of using the huffyuv CODEC is that proxy generation is not needed.