videopython 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of videopython might be problematic. Click here for more details.

Files changed (41) hide show
  1. videopython-0.3.0/.gitignore +143 -0
  2. videopython-0.3.0/PKG-INFO +118 -0
  3. {videopython-0.2.0 → videopython-0.3.0}/README.md +7 -0
  4. videopython-0.3.0/pyproject.toml +69 -0
  5. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/base/transitions.py +2 -2
  6. videopython-0.3.0/src/videopython/base/video.py +345 -0
  7. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/generation/__init__.py +2 -1
  8. videopython-0.3.0/src/videopython/generation/audio.py +68 -0
  9. videopython-0.3.0/src/videopython/py.typed +0 -0
  10. videopython-0.3.0/src/videopython/utils/__init__.py +0 -0
  11. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/utils/image.py +4 -0
  12. videopython-0.2.0/PKG-INFO +0 -316
  13. videopython-0.2.0/pyproject.toml +0 -43
  14. videopython-0.2.0/requirements-dev.txt +0 -7
  15. videopython-0.2.0/requirements-generation.txt +0 -4
  16. videopython-0.2.0/requirements.txt +0 -6
  17. videopython-0.2.0/setup.cfg +0 -4
  18. videopython-0.2.0/src/videopython/base/video.py +0 -315
  19. videopython-0.2.0/src/videopython/generation/audio.py +0 -22
  20. videopython-0.2.0/src/videopython/generation/pipeline.py +0 -32
  21. videopython-0.2.0/src/videopython.egg-info/PKG-INFO +0 -316
  22. videopython-0.2.0/src/videopython.egg-info/SOURCES.txt +0 -32
  23. videopython-0.2.0/src/videopython.egg-info/dependency_links.txt +0 -1
  24. videopython-0.2.0/src/videopython.egg-info/requires.txt +0 -21
  25. videopython-0.2.0/src/videopython.egg-info/top_level.txt +0 -1
  26. videopython-0.2.0/tests/test_compose.py +0 -35
  27. videopython-0.2.0/tests/test_effects.py +0 -71
  28. videopython-0.2.0/tests/test_transforms.py +0 -69
  29. videopython-0.2.0/tests/test_transitions.py +0 -40
  30. videopython-0.2.0/tests/test_utils.py +0 -11
  31. videopython-0.2.0/tests/test_video.py +0 -135
  32. {videopython-0.2.0 → videopython-0.3.0}/LICENSE +0 -0
  33. {videopython-0.2.0/src/videopython/base → videopython-0.3.0/src/videopython}/__init__.py +0 -0
  34. {videopython-0.2.0/src/videopython/utils → videopython-0.3.0/src/videopython/base}/__init__.py +0 -0
  35. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/base/compose.py +0 -0
  36. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/base/effects.py +0 -0
  37. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/base/exceptions.py +0 -0
  38. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/base/transforms.py +0 -0
  39. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/generation/image.py +0 -0
  40. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/generation/video.py +0 -0
  41. {videopython-0.2.0 → videopython-0.3.0}/src/videopython/utils/common.py +0 -0
@@ -0,0 +1,143 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # type checker
129
+ .pyre/
130
+ .mypy_cache/
131
+
132
+ # Random shit
133
+ *.ipynb
134
+ .vscode
135
+ *.csv
136
+
137
+ # Data directories
138
+ data/downloaded/*.mp4
139
+ data/exported/*.mp4
140
+ !data/exported/example.mp4
141
+
142
+ # Mac
143
+ *.DS_Store
@@ -0,0 +1,118 @@
1
+ Metadata-Version: 2.4
2
+ Name: videopython
3
+ Version: 0.3.0
4
+ Summary: Minimal video generation and processing library.
5
+ Project-URL: Homepage, https://github.com/bartwojtowicz/videopython/
6
+ Project-URL: Repository, https://github.com/bartwojtowicz/videopython/
7
+ Project-URL: Documentation, https://github.com/bartwojtowicz/videopython/
8
+ Author-email: Bartosz Wójtowicz <bartoszwojtowicz@outlook.com>, Bartosz Rudnikowicz <bartoszrudnikowicz840@gmail.com>, Piotr Pukisz <piotr.pukisz@gmail.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: editing,generation,movie,opencv,python,video,videopython
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Requires-Python: <3.13,>=3.10
18
+ Requires-Dist: numpy>=1.25.2
19
+ Requires-Dist: opencv-python>=4.9.0.80
20
+ Requires-Dist: pillow>=10.3.0
21
+ Requires-Dist: pydub>=0.25.1
22
+ Requires-Dist: soundpython>=0.1.9
23
+ Requires-Dist: tqdm>=4.66.3
24
+ Description-Content-Type: text/markdown
25
+
26
+ # About
27
+
28
+ Minimal video generation and processing library.
29
+
30
+ ## Setup
31
+
32
+ ### Install ffmpeg
33
+ ```bash
34
+ # Install with brew for MacOS:
35
+ brew install ffmpeg
36
+ # Install with apt-get for Ubuntu:
37
+ sudo apt-get install ffmpeg
38
+ ```
39
+
40
+ ### Install with pip
41
+ ```bash
42
+ pip install videopython[generation]
43
+ ```
44
+ > You can install without `[generation]` dependencies for basic video handling and processing.
45
+ > The funcionalities found in `videopython.generation` won't work.
46
+
47
+ ## Basic Usage
48
+
49
+ ### Video handling
50
+
51
+ ```python
52
+ from videopython.base.video import Video
53
+
54
+ # Load videos and print metadata
55
+ video1 = Video.from_path("tests/test_data/fast_benchmark.mp4")
56
+ print(video1)
57
+
58
+ video2 = Video.from_path("tests/test_data/slow_benchmark.mp4")
59
+ print(video2)
60
+
61
+ # Define the transformations
62
+ from videopython.base.transforms import CutSeconds, ResampleFPS, Resize, TransformationPipeline
63
+
64
+ pipeline = TransformationPipeline(
65
+ [CutSeconds(start=1.5, end=6.5), ResampleFPS(fps=30), Resize(width=1000, height=1000)]
66
+ )
67
+ video1 = pipeline.run(video1)
68
+ video2 = pipeline.run(video2)
69
+
70
+ # Combine videos, add audio and save
71
+ from videopython.base.transitions import FadeTransition
72
+
73
+ fade = FadeTransition(effect_time_seconds=3.0)
74
+ video = fade.apply(videos=(video1, video2))
75
+ video.add_audio_from_file("tests/test_data/test_audio.mp3")
76
+
77
+ savepath = video.save()
78
+ ```
79
+
80
+ ### Video Generation
81
+
82
+ > Using Nvidia A40 or better is recommended for the `videopython.generation` module.
83
+ ```python
84
+ # Generate image and animate it
85
+ from videopython.generation import ImageToVideo
86
+ from videopython.generation import TextToImage
87
+ from videopython.generation import TextToMusic
88
+
89
+ image = TextToImage().generate_image(prompt="Golden Retriever playing in the park")
90
+ video = ImageToVideo().generate_video(image=image, fps=24)
91
+
92
+ # Video generation directly from prompt
93
+ from videopython.generation import TextToVideo
94
+ video_gen = TextToVideo()
95
+ video = video_gen.generate_video("Dogs playing in the snow")
96
+ for _ in range(10):
97
+ video += video_gen.generate_video("Dogs playing in the snow")
98
+
99
+ # Cut the first 2 seconds
100
+ from videopython.base.transforms import CutSeconds
101
+ transformed_video = CutSeconds(start_second=0, end_second=2).apply(video.copy())
102
+
103
+ # Upsample to 30 FPS
104
+ from videopython.base.transforms import ResampleFPS
105
+ transformed_video = ResampleFPS(new_fps=30).apply(transformed_video)
106
+
107
+ # Resize to 1000x1000
108
+ from videopython.base.transforms import Resize
109
+ transformed_video = Resize(width=1000, height=1000).apply(transformed_video)
110
+
111
+ # Add generated music
112
+ # MusicGen cannot generate more than 1503 tokens (~30seconds of audio)
113
+ text_to_music = TextToMusic()
114
+ audio = text_to_music.generate_audio("Happy dogs playing together in a park", max_new_tokens=256)
115
+ transformed_video.add_audio(audio=audio)
116
+
117
+ filepath = transformed_video.save()
118
+ ```
@@ -59,6 +59,7 @@ savepath = video.save()
59
59
  # Generate image and animate it
60
60
  from videopython.generation import ImageToVideo
61
61
  from videopython.generation import TextToImage
62
+ from videopython.generation import TextToMusic
62
63
 
63
64
  image = TextToImage().generate_image(prompt="Golden Retriever playing in the park")
64
65
  video = ImageToVideo().generate_video(image=image, fps=24)
@@ -82,5 +83,11 @@ transformed_video = ResampleFPS(new_fps=30).apply(transformed_video)
82
83
  from videopython.base.transforms import Resize
83
84
  transformed_video = Resize(width=1000, height=1000).apply(transformed_video)
84
85
 
86
+ # Add generated music
87
+ # MusicGen cannot generate more than 1503 tokens (~30seconds of audio)
88
+ text_to_music = TextToMusic()
89
+ audio = text_to_music.generate_audio("Happy dogs playing together in a park", max_new_tokens=256)
90
+ transformed_video.add_audio(audio=audio)
91
+
85
92
  filepath = transformed_video.save()
86
93
  ```
@@ -0,0 +1,69 @@
1
+ [project]
2
+ name = "videopython"
3
+ version = "0.3.0"
4
+ description = "Minimal video generation and processing library."
5
+ authors = [
6
+ { name = "Bartosz Wójtowicz", email = "bartoszwojtowicz@outlook.com" },
7
+ { name = "Bartosz Rudnikowicz", email = "bartoszrudnikowicz840@gmail.com" },
8
+ { name = "Piotr Pukisz", email = "piotr.pukisz@gmail.com" }
9
+ ]
10
+ license = { text = "Apache-2.0" }
11
+ readme = "README.md"
12
+ requires-python = ">=3.10, <3.13"
13
+ keywords = ["python", "videopython", "video", "movie", "opencv", "generation", "editing"]
14
+ classifiers = [
15
+ "License :: OSI Approved :: Apache Software License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+
22
+ dependencies = [
23
+ "numpy>=1.25.2",
24
+ "opencv-python>=4.9.0.80",
25
+ "pillow>=10.3.0",
26
+ "pydub>=0.25.1",
27
+ "soundpython>=0.1.9",
28
+ "tqdm>=4.66.3",
29
+ ]
30
+
31
+ [dependency-groups]
32
+ dev = [
33
+ "black>=24.3.0",
34
+ "isort>=5.12.0",
35
+ "mypy>=1.8.0",
36
+ "pytest>=7.4.0",
37
+ "types-Pillow>=10.2.0.20240213",
38
+ "types-tqdm>=4.66.0.20240106",
39
+ ]
40
+ generation = [
41
+ "accelerate>=0.29.2",
42
+ "diffusers>=0.26.3",
43
+ "torch>=2.1.0",
44
+ "transformers>=4.38.1",
45
+ ]
46
+
47
+ [project.urls]
48
+ Homepage = "https://github.com/bartwojtowicz/videopython/"
49
+ Repository = "https://github.com/bartwojtowicz/videopython/"
50
+ Documentation = "https://github.com/bartwojtowicz/videopython/"
51
+
52
+ [tool.mypy]
53
+ mypy_path = "stubs"
54
+
55
+ [build-system]
56
+ requires = ["hatchling"]
57
+ build-backend = "hatchling.build"
58
+
59
+ [tool.hatch.build.targets.wheel]
60
+ packages = ["src/videopython"]
61
+
62
+ [tool.hatch.build.targets.sdist]
63
+ include = ["src/videopython", "src/videopython/py.typed"]
64
+
65
+ [tool.pytest]
66
+ pythonpath = [".src/"]
67
+ testpaths = ["src/tests"]
68
+ python_files = ["test_*.py"]
69
+ addopts = "-v --tb=short"
@@ -67,7 +67,7 @@ class FadeTransition(Transition):
67
67
  ],
68
68
  fps=video_fps,
69
69
  )
70
- faded_videos.audio = videos[0].audio.append(videos[1].audio, crossfade=(effect_time_fps / video_fps) * 1000)
70
+ faded_videos.audio = videos[0].audio.concat(videos[1].audio, crossfade=(effect_time_fps / video_fps))
71
71
  return faded_videos
72
72
 
73
73
 
@@ -102,5 +102,5 @@ class BlurTransition(Transition):
102
102
  ],
103
103
  fps=video_fps,
104
104
  )
105
- blurred_videos.audio = videos[0].audio.append(videos[1].audio)
105
+ blurred_videos.audio = videos[0].audio.concat(videos[1].audio)
106
106
  return blurred_videos