generated from roboflow/template-python
-
Notifications
You must be signed in to change notification settings - Fork 3k
Video class refactor #1947
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
timmermansjoy
wants to merge
14
commits into
roboflow:develop
Choose a base branch
from
timmermansjoy:video-refactor
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
Video class refactor #1947
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
af406c7
starting structure for new video class
timmermansjoy 5beb137
Merge remote-tracking branch 'myfork/video-refactor' into video-refactor
timmermansjoy b8f820d
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 505689b
add better deprication warnings
timmermansjoy 15286b1
add ffmpeg (pyav) backend as support
timmermansjoy bb67f6f
add better depracated warnings
timmermansjoy fab59ea
format docstrings correctly
timmermansjoy 9561e3d
keep keep naming consistent with pyav
timmermansjoy a9bf329
add test notebook (will removed later)
timmermansjoy 9bd156d
Merge branch 'video-refactor' of https://github.com/timmermansjoy/sup…
timmermansjoy 83d3b65
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] 375883c
remove answered question
timmermansjoy f25e3b1
Merge branch 'video-refactor' of https://github.com/timmermansjoy/sup…
timmermansjoy cb2f265
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,297 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 1, | ||
| "id": "fb864ed3", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "from tqdm import tqdm\n", | ||
| "\n", | ||
| "import supervision as sv" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 2, | ||
| "id": "94cbdffa", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "data": { | ||
| "text/plain": [ | ||
| "<Video gemist.mp4 : VideoInfo(width=848, height=480, fps=15, precise_fps=14.955430835259161, total_frames=151) : Backend: opencv>" | ||
| ] | ||
| }, | ||
| "execution_count": 2, | ||
| "metadata": {}, | ||
| "output_type": "execute_result" | ||
| } | ||
| ], | ||
| "source": [ | ||
| "video = sv.Video(\"gemist.mp4\")\n", | ||
| "video" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 3, | ||
| "id": "3cd5bbd6", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 151/151 [00:00<00:00, 1929.48it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "video = sv.Video(\"gemist.mp4\")\n", | ||
| "for frame in tqdm(video):\n", | ||
| " pass" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 4, | ||
| "id": "5ca4d68c", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "for frame in sv.Video(\"gemist.mp4\").frames(\n", | ||
| " stride=5, start=100, end=500, resolution_wh=(1280, 720)\n", | ||
| "):\n", | ||
| " pass" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 5, | ||
| "id": "90463868", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "Saving video: 151it [00:00, 540.72it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "import cv2\n", | ||
| "\n", | ||
| "\n", | ||
| "def blur(frame, i):\n", | ||
| " return cv2.GaussianBlur(frame, (11, 11), 0)\n", | ||
| "\n", | ||
| "\n", | ||
| "sv.Video(\"gemist.mp4\").save(\"blurred.mp4\", callback=blur, show_progress=True)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 6, | ||
| "id": "47382afa", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "Saving video: 151it [00:00, 539.70it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "sv.Video(\"gemist.mp4\").save(\n", | ||
| " \"timelapse.mp4\", fps=60, callback=lambda f, i: f, show_progress=True\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 7, | ||
| "id": "11bbe111", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "Saving video: 151it [00:00, 625.05it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "from supervision import Video, VideoInfo\n", | ||
| "\n", | ||
| "# Need more elaboration on this\n", | ||
| "\n", | ||
| "source = Video(\"gemist.mp4\")\n", | ||
| "target_info = VideoInfo(width=200, height=600, fps=200)\n", | ||
| "\n", | ||
| "source.save(\"resized.mp4\", info=target_info, show_progress=True)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 8, | ||
| "id": "f60323ab", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "data": { | ||
| "text/plain": [ | ||
| "<Video gemist.mp4 : VideoInfo(width=848, height=480, fps=15, precise_fps=14.955430835259161, total_frames=151) : Backend: pyav>" | ||
| ] | ||
| }, | ||
| "execution_count": 8, | ||
| "metadata": {}, | ||
| "output_type": "execute_result" | ||
| } | ||
| ], | ||
| "source": [ | ||
| "import supervision as sv\n", | ||
| "\n", | ||
| "video = sv.Video(\"gemist.mp4\", backend=\"pyav\")\n", | ||
| "video" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 9, | ||
| "id": "de97b6c3", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 151/151 [00:00<00:00, 1969.45it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "from tqdm import tqdm\n", | ||
| "\n", | ||
| "import supervision as sv\n", | ||
| "\n", | ||
| "video = sv.Video(\"gemist.mp4\", backend=\"pyav\")\n", | ||
| "for frame in tqdm(video):\n", | ||
| " pass" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 10, | ||
| "id": "726ffd1a", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "13it [00:00, 318.78it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "from tqdm import tqdm\n", | ||
| "\n", | ||
| "import supervision as sv\n", | ||
| "\n", | ||
| "for frame in tqdm(\n", | ||
| " sv.Video(\"gemist.mp4\", backend=\"pyav\").frames(\n", | ||
| " stride=5, start=100, end=500, resolution_wh=(1280, 720)\n", | ||
| " )\n", | ||
| "):\n", | ||
| " pass" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 11, | ||
| "id": "0da30fa8", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "Saving video: 151it [00:00, 413.05it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "def blur(frame, i):\n", | ||
| " return cv2.GaussianBlur(frame, (11, 11), 0)\n", | ||
| "\n", | ||
| "\n", | ||
| "sv.Video(\"gemist.mp4\", backend=\"pyav\").save(\n", | ||
| " \"blurred_av.mp4\", callback=blur, show_progress=True\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 12, | ||
| "id": "ef5fb50e", | ||
| "metadata": {}, | ||
| "outputs": [ | ||
| { | ||
| "name": "stderr", | ||
| "output_type": "stream", | ||
| "text": [ | ||
| "Saving video: 151it [00:00, 413.50it/s]\n" | ||
| ] | ||
| } | ||
| ], | ||
| "source": [ | ||
| "sv.Video(\"gemist.mp4\", backend=\"pyav\").save(\n", | ||
| " \"timelapse.mp4\", fps=60, callback=lambda f, i: f, show_progress=True\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "a8db8606", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": ".venv", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 3 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.11.13" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
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 .core import Video | ||
| from .utils import VideoInfo | ||
|
|
||
| __all__ = ["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,7 @@ | ||
| BACKENDS = { | ||
| "opencv": "supervision.video.backends.opencv", | ||
| "pyav": "supervision.video.backends.pyav", | ||
| } | ||
|
|
||
|
|
||
| __all__ = ["BACKENDS"] |
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.