Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Make multithumbnails for Parler videos.
This file reads a list of Parler video IDs and generates "multithumbnails" (a sequence of 9 evenly-spaced thumbnails).
The multithumbnails are stored in the multithumbnails/linear and multithumbnails/rect directories.
linear/ puts the thumbnails side-by-side in a linear sequence.
rect/ puts the thumbnails in a 3x3 rectangle.
To run, download this script from GitHub then:
git clone utils
sudo apt install python3 python3-pip
pip3 install --user --upgrade pip
pip3 install --user numpy ffmpeg-python opencv-python pillow
python3 id-list.txt
import sys
import os
import time
from utils.ffmpeg import vidread
from utils.imutil import imresize
from utils.imutil import imwrite
from utils.mosaic import make_mosaic
from utils.list_files import list_files
from utils.list_files import get_stem
from utils.progress import progress
input_fn = sys.argv[1]
output_dir = 'multithumbnails/'
max_side = 320
os.makedirs(os.path.join(output_dir, 'linear'), exist_ok=True)
os.makedirs(os.path.join(output_dir, 'rect'), exist_ok=True)
with open(input_fn) as f:
ids =
for video_id in progress(ids):
linear_fn = os.path.join(output_dir, 'linear', video_id + '.jpg')
rect_fn = os.path.join(output_dir, 'rect', video_id + '.jpg')
if os.path.exists(linear_fn) and os.path.exists(rect_fn):
fn = f'.cache/{video_id}'
os.system(f'aws s3 cp --request-payer requester s3://ddosecrets-parler/{video_id} {fn}')
thumbs = []
samples = 9
for frame in vidread(fn, samples=samples):
thumb = imresize(frame, max_side=max_side)
except KeyboardInterrupt:
print('read/resize error', fn)
if len(thumbs) > samples:
thumbs = thumbs[1:]
if len(thumbs) != samples:
print('incorrect total:', fn)
imwrite(linear_fn, make_mosaic(thumbs, ny=1))
imwrite(rect_fn, make_mosaic(thumbs))
except FileNotFoundError:
print('ignoring deletion')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment