Video Sampler -- sample frames from a video file
Project description
video-sampler
Video sampler allows you to efficiently sample video frames. Currently it uses keyframe decoding, frame interval gating and perceptual hashing to reduce duplicated samples.
Use case: for sampling videos for later annotations used in machine learning.
Installation and Usage
pip install -U video-sampler
then you can run
python3 -m video-sampler --help
or simply
video-sampler --help
Basic usage
python3 -m video-sampler hash FatCat.mp4 ./dataset-frames/ --hash-size 3 --buffer-size 20
Advanced usage
There are currently 3 sampling methods:
hash
- uses perceptual hashing to reduce duplicated samplesentropy
- uses entropy to reduce duplicated samples (work in progress)gzip
- uses gzip compressed size to reduce duplicated samples (work in progress)
To launch either you can run
video_sampler buffer `method-name` ...other options
e.g.
video_sampler buffer entropy --buffer-size 20 ...
where buffer-size
for entropy
and gzip
mean the top-k sliding buffer size. Sliding buffer also uses hashing to reduce duplicated samples.
Benchmarks
Configuration for this benchmark:
SamplerConfig(min_frame_interval_sec=1.0, keyframes_only=True, buffer_size=30, hash_size=X, queue_wait=0.1, debug=True)
Video | Total frames | Hash size | Decoded | Saved |
---|---|---|---|---|
SmolCat | 2936 | 8 | 118 | 106 |
SmolCat | - | 4 | - | 61 |
Fat Cat | 4462 | 8 | 179 | 163 |
Fat Cat | - | 4 | - | 101 |
HighLemurs | 4020 | 8 | 161 | 154 |
HighLemurs | - | 4 | - | 126 |
SamplerConfig(
min_frame_interval_sec=1.0,
keyframes_only=True,
queue_wait=0.1,
debug=False,
print_stats=True,
buffer_config={'type': 'entropy'/'gzip', 'size': 30, 'debug': False, 'hash_size': 8, 'expiry': 50}
)
Video | Total frames | Type | Decoded | Saved |
---|---|---|---|---|
SmolCat | 2936 | entropy | 118 | 39 |
SmolCat | - | gzip | - | 39 |
Fat Cat | 4462 | entropy | 179 | 64 |
Fat Cat | - | gzip | - | 73 |
HighLemurs | 4020 | entropy | 161 | 59 |
HighLemurs | - | gzip | - | 63 |
Flit commands
Build
flit build
Install
flit install
Publish
flit publish
🛡 License
This project is licensed under the terms of the MIT
license. See LICENSE for more details.
📃 Citation
@misc{video-sampler,
author = {video-sampler},
title = {Video sampler allows you to efficiently sample video frames},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/LemurPwned/video-sampler}}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file video_sampler-0.5.0.tar.gz
.
File metadata
- Download URL: video_sampler-0.5.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e199b3638f4ac5d5e9b27446e079810e2fb83600ae00f21c0c3594e1dbee8573 |
|
MD5 | e50861bfc892bd6ffe0d5573d0f04259 |
|
BLAKE2b-256 | 185d181a420b556fe59d312b20e4eaf3c272d391beabd0d909c8e67067783a71 |
File details
Details for the file video_sampler-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: video_sampler-0.5.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51dd405a45e21776164a37c8ddcd8d394c0687689abee62c6702151d01cf8e1b |
|
MD5 | 8d4fdf25c9551eea484db47196770fe7 |
|
BLAKE2b-256 | 9a8737b139a3d6cbf709395d76472e83b3ace2d1d6eedf733b014519deb6a482 |