Desplice
Desplice is a Python library designed to process video files by removing duplicate frames, still images, and certain transitions. This helps in deduplicating video content, making it more efficient for storage or further processing.
Features
- Heal: Drops duplicate frames from the output.
- Keep: Retains one instance of each duplicate frame in the output.
- Explode: Removes duplicate frames from the video output and returns separate clips for each splice.
Installation
To install Desplice, you can use pip:
pip install desplice
Usage
Below are some examples demonstrating how to use Desplice.
Importing the Library
from desplice import Desplice
Loading a Video and Processing it
Take note that in the input value may be a path to the target video or alternatively a list of frames list[np.ndarray] that has already been captured/loaded.
# Initialize the Desplice class
desplice = Desplice(debug=True)
# Load a video file into memory
video_frames = desplice.load_video_to_memory('path_to_your_video.mp4')
# Process the video to deduplicate frames
result, is_slideshow = desplice.process(video_frames, mode='heal', show=True, show_breaks=True)
If show is set to True processing and results will be displayed using cv2.imshow().
If show_breaks is set to True one black frame will be inserted between each slice.
If debug is set to True measurements and detections will be returned to console.
Example of Different Modes:
Heal Mode
Removes the detected content from output entirely.
result, is_slideshow = desplice.process('path_to_your_video.mp4', mode='heal')
Keep Mode
Keeps 1 frame of the duplicated content in the output.
result, is_slideshow = desplice.process('path_to_your_video.mp4', mode='keep')
Explode Mode
Returns each segment inbetween each duplicated sequence as it's own sequence.
result, is_slideshow = desplice.process('path_to_your_video.mp4', mode='explode')
Results are returned in a nested tuple object:
(
(
[video-1, video-2, video-3...], # List of videos: list[list[np.ndarray]]
[still-1, still-2, still-3] # List of still images: list[np.ndarray]
),
slideshow # Is the video a slideshow: Bool
)
Deduplication weights can be passed to augment the behavior of the antidupe module:
custom_thresholds = {
'ih': 0.0, # Image Hash
'ssim': 0.1, # SSIM
'cs': 0.02, # Cosine Similarity
'cnn': 0.03, # CNN
'dedup': 0.005 # Mobilenet
}
desplice = Desplice(thresholds=custom_thresholds)
Further information on using antidupe can be found here
Class and Method Descriptions
Desplice
Methods
-
__init__(self, thresholds: dict = None, device: str = 'cpu', debug: bool = False): Initializes the Desplice class with optional threshold values, device, and debug mode. -
load_video_to_memory(file_path: str) -> list: Loads a video from the given file path into memory. -
show_video_from_frames(frames: list): Displays a video from a list of frames. -
deduplicate_frames(self, frames: list) -> tuple: Deduplicates frames from the input video and returns a tuple containing processed video frames and images. -
process(self, file_path_or_array: [str, list[np.ndarray]], mode: modes = 'heal', show: bool = False, show_breaks: bool = False) -> tuple: Processes the video based on the specified mode and returns the processed result and a boolean indicating if the output is a slideshow.
License
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for more details.
Metadata
Release files for desplice 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| desplice-0.0.2.tar.gz | 8.4 kB | Without provenance | Details for desplice-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| desplice-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for desplice-0.0.2-py3-none-any.whl |
Total release size: 17.4 kB
Release files / desplice-0.0.2.tar.gz
| Download URL | desplice-0.0.2.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75efd6916e3ff8507cc2802f6c6ce3d72c0bf143a9441c6d0e842e2d82a345a2
|
|
BLAKE2b-256 checksum How to use checksums |
0a2fabee874d70c50752141df728356b91233961d6aa7574fd4e6ffc2f505dbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / desplice-0.0.2-py3-none-any.whl
| Download URL | desplice-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e004c11f93d17f9c0ca53a493baf72f784842a06fa1006b8f4ce83cf29cd32eb
|
|
BLAKE2b-256 checksum How to use checksums |
87e203ee806da41f2c52836677409958d263747be316c72fe2f8e56e291ca0a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for desplice 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.