generated from roboflow/template-python
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
FEATURE: New Video
API
#1924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ashp116
wants to merge
139
commits into
roboflow:develop
Choose a base branch
from
Ashp116:bug/process-video-audio
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
FEATURE: New Video
API
#1924
Changes from all commits
Commits
Show all changes
139 commits
Select commit
Hold shift + click to select a range
7fba113
ADD: Added audio stream for process_video
Ashp116 8947f77
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 73b5836
REMOVE: Removed ffprobe
Ashp116 e02d298
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 5e07794
UPDATE: Added a new Video class with OpenCV writer and backend
Ashp116 46ec693
Merge pull request #1 from Ashp116/update/video-core
Ashp116 b2096d0
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 9fb7098
Precommit
Ashp116 850a2c6
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 46900f8
Precommit
Ashp116 34cb9a1
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 c700394
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] fce8ade
UPDATE: Fixed incomplete write closing
Ashp116 f86f4f2
ADD: Docstrings
Ashp116 2265977
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] bf67bfa
UPDATE: Allow for ffmpeg error passthrough
Ashp116 ec4bd01
UPDATE: Writer and Backend abstract class
Ashp116 b9e7968
Precommit
Ashp116 a96c3f0
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] a6c91bc
Precommit
Ashp116 d075e03
UPDATE: Added manual control
Ashp116 7f078ff
ADD: Added docstrings
Ashp116 af49e9a
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 320d817
UPDATE: Deprecate warning old Video API
Ashp116 cb8d2f8
FIX: Prototype resolution for #1687
Ashp116 a3a3a9e
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] ecbf5af
FIX: Rounding type
Ashp116 1da4466
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 3b4c68f
UPDATE: Updated the file structure for the video API
Ashp116 385639b
UPDATE: Added frame generator within backend
Ashp116 61dd016
UPDATE: Added .save codec support
Ashp116 d2bb428
UPDATE: Added default mp4v codec
Ashp116 f3a3133
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 421cd5d
UPDATE: Trying to pass checks
Ashp116 dce0717
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 b9da794
UPDATE: Typings for optional params
Ashp116 e8b39a1
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 90885b0
Import check fix
Ashp116 9d0b5ed
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] f983113
Import check fix
Ashp116 c1544f0
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 3a33982
Import check fix
Ashp116 343600d
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] bf0f884
Import check fix
Ashp116 c7e5f44
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 881c9f4
Import check fix
Ashp116 5fed10b
Import check fix
Ashp116 a84dde8
Import check fix
Ashp116 012b950
RM: Remove video folder
Ashp116 af3db7f
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] e2edb96
ADD: Added video folder
Ashp116 f31d377
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 ed5e15b
UPDATE: Revert typings
Ashp116 fd66925
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 13010e0
UPDATE: sv imports
Ashp116 55727a7
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 25e3b5f
UPDATE: default imports using __init__
Ashp116 0ad6cd1
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 3e7b247
FIX: Fixed VideoInfo definition
Ashp116 cc7477a
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 e855b14
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 29fb666
FIX: Fixed futuer annotations
Ashp116 d9ab61c
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 941d487
UPDATE: Restructure video saves
Ashp116 1db5596
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 2175d25
UPDATE: Restructure manual writer
Ashp116 27f1266
FORMAT: Formatting changes
Ashp116 cf31e29
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] abba880
UPDATE: Restructured frame generator
Ashp116 3374544
FIX: Removed frames from BaseBackend
Ashp116 2e78c48
ADD: Added pyAV backend support
Ashp116 a3aca42
ADD: Added pyAV docstrings
Ashp116 819c70b
ADD: Added pyAV audio support
Ashp116 dfd9407
UPDATE: Backend support needed for all writers
Ashp116 d29e50e
FIX: Formatting
Ashp116 3ff8644
ADD: Added backend utils and type safe support
Ashp116 d006c47
UPDATE: Type safe syntax
Ashp116 8894819
FORMAT: Changed backend param
Ashp116 55b5ea0
UPDATE: Added ctx for pyAV
Ashp116 4b1c9bc
UPDATE: Updated docstrings
Ashp116 706e85a
UPDATE: Negate audio stream
Ashp116 8eb0774
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 9ea0f2b
FIX: Fixed av import error and formatting
Ashp116 40c2a7c
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 10482f4
FIX: Fixed av error message and formatting
Ashp116 337f65e
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 1e40420
FIX: Fixed issue with audio sync with fps
Ashp116 62b1fc6
UPDATE: Finer audio mux
Ashp116 e3e21ab
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 055c4fc
UPDATE: Param config to render audio
Ashp116 e35ddc7
Merge branch 'bug/process-video-audio' of https://github.com/Ashp116/…
Ashp116 7450573
UPDATE: Changed config to render audio to be isolated
Ashp116 9223804
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] fcee1a1
UPDATE: Updated deprecated warnings
Ashp116 42a0f24
ADD: Added unit tests from PR #1941
Ashp116 c004d24
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] c5e1d2e
FIX: Updated the pyproject.toml's extra requirements for ffmpeg
Ashp116 b258d1b
FIX: Fixes of formatting from code review
Ashp116 79e003d
UPDATE: Removed video info from path as it is dependant on the backend
Ashp116 c6e6e6c
UPDATE: Updated backend to Enum
Ashp116 4f5ac58
FIX: Reverted video utils
Ashp116 29a1045
FIX: Fixed backend bug issues
Ashp116 7e401ca
UPDATE: Updated render_audio param default value config
Ashp116 232ace5
BUG: Fixed pyav not resolving webcam source path
Ashp116 84f90ea
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] f6cea28
UPDATE: Updated file names
Ashp116 048ebc0
Precommit error fix
Ashp116 de62eb8
FIX: render_audio opencv param fix
Ashp116 afea7c0
UPDATE: Updated docstrings
Ashp116 6208f3d
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 9cb2170
UPDATE: Updated docstrings
Ashp116 70b73d8
UPDATE: Added .show()
Ashp116 01f8b2c
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 11fc8a5
UPDATE: Add support for IPython display
Ashp116 1dac635
UPDATE: Added support for headless machines and notebook for sv.Video…
Ashp116 dedb68a
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 035196a
UPDATE: Updated error msg for IPython
Ashp116 a1218e8
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 76d8145
Precommit
Ashp116 32a5e2c
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 7680cae
UPDATE: Fixed av module install
Ashp116 68fb727
UPDATE: Revert av error
Ashp116 3f403fe
UPDATE: updated av module getter
Ashp116 c9badc1
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 7a507e5
UPDATE: Updated .show() with more configuration params
Ashp116 824fa98
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 8aa364c
UPDATE: Updated IPython import
Ashp116 2bec991
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 43830f7
BUG: Frame iteration fix
Ashp116 f827455
UPDATE: Updated audio stream to use atempo reflecting changes in fps
Ashp116 2d90915
UPDATE: Updated docstrings
Ashp116 e9ccca2
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 9f115c4
UPDATE: Changed backend type class and added ref to root
Ashp116 c67aad3
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] ba9efc2
BUG: Appending fixes for VideoBackend error
Ashp116 1dcbb4b
FIX: Merge conflicts
Ashp116 9c7a9ec
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] fb2171c
UPDATE: Decompose playback speed into valid atempo chain
Ashp116 c78e4f7
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from supervision.video.core import Video | ||
from supervision.video.utils import SourceType, VideoInfo | ||
|
||
__all__ = ["SourceType", "Video", "VideoInfo"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
from typing import Literal, Union | ||
|
||
from supervision.video.backend.opencv import OpenCVBackend, OpenCVWriter | ||
from supervision.video.backend.pyav import pyAVBackend, pyAVWriter | ||
|
||
VideoBackendTypes = Union[OpenCVBackend, pyAVBackend] | ||
VideoWriterTypes = Union[OpenCVWriter, pyAVWriter] | ||
|
||
|
||
class VideoBackendType(Enum): | ||
""" | ||
Enumeration of Backends. | ||
|
||
Attributes: | ||
PYAV (str): PyAV backend (powered by FFmpeg, supports audio rendering) | ||
OPENCV (str): OpenCV backend | ||
|
||
""" | ||
|
||
PYAV = "pyav" | ||
OPENCV = "opencv" | ||
|
||
@classmethod | ||
def list(cls): | ||
return list(map(lambda c: c.value, cls)) | ||
|
||
@classmethod | ||
def from_value(cls, value: VideoBackendType | str) -> VideoBackendType: | ||
if isinstance(value, cls): | ||
return value | ||
if isinstance(value, str): | ||
value = value.lower() | ||
try: | ||
return cls(value) | ||
except ValueError: | ||
raise ValueError(f"Invalid value: {value}. Must be one of {cls.list()}") | ||
raise ValueError( | ||
f"Invalid value type: {type(value)}. Must be an instance of " | ||
f"{cls.__name__} or str." | ||
) | ||
|
||
|
||
VideoBackendDict = { | ||
VideoBackendType.PYAV: pyAVBackend, | ||
VideoBackendType.OPENCV: OpenCVBackend, | ||
} | ||
|
||
VideoWriterDict = { | ||
VideoBackendType.PYAV: pyAVWriter, | ||
VideoBackendType.OPENCV: OpenCVWriter, | ||
} | ||
|
||
__all__ = [ | ||
"VideoBackendDict", | ||
"VideoBackendType", | ||
"VideoBackendTypes", | ||
"VideoWriterDict", | ||
"VideoWriterTypes", | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from __future__ import annotations | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
import numpy as np | ||
|
||
from supervision.video.utils import VideoInfo | ||
|
||
|
||
class BaseBackend(ABC): | ||
def __init__(self): | ||
self.cap = None | ||
self.video_info: VideoInfo | None = None | ||
self.writer: BaseWriter | None = None | ||
self.path = None | ||
|
||
@abstractmethod | ||
def open(self, path: str | int) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
def isOpened(self) -> bool: | ||
pass | ||
|
||
@abstractmethod | ||
def _set_video_info(self) -> VideoInfo: | ||
pass | ||
|
||
@abstractmethod | ||
def info(self) -> VideoInfo: | ||
pass | ||
|
||
@abstractmethod | ||
def read(self) -> tuple[bool, np.ndarray]: | ||
pass | ||
|
||
@abstractmethod | ||
def grab(self) -> bool: | ||
pass | ||
|
||
@abstractmethod | ||
def seek(self, frame_idx: int) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
def release(self) -> None: | ||
pass | ||
|
||
|
||
class BaseWriter(ABC): | ||
@abstractmethod | ||
def __init__( | ||
self, | ||
filename: str, | ||
fps: int, | ||
frame_size: tuple[int, int], | ||
codec: str | None = None, | ||
backend: BaseBackend | None = None, | ||
render_audio: bool | None = None, | ||
): | ||
pass | ||
|
||
@abstractmethod | ||
def __enter__(self): | ||
pass | ||
|
||
@abstractmethod | ||
def __exit__(self, exc_type, exc_value, traceback): | ||
pass | ||
|
||
@abstractmethod | ||
def write(self, frame: np.ndarray) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
def close(self) -> None: | ||
pass |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.