videopython


Namevideopython JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryMinimal video generation and processing library.
upload_time2024-08-18 08:29:06
maintainerNone
docs_urlNone
authorNone
requires_python<3.13,>=3.10
licenseApache-2.0
keywords editing generation movie opencv python video videopython
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # About

Minimal video generation and processing library.

## Setup 

### Install ffmpeg
```bash
# Install with brew for MacOS:
brew install ffmpeg
# Install with apt-get for Ubuntu:
sudo apt-get install ffmpeg
```

### Install with pip
```bash
pip install videopython[generation]
```
> You can install without `[generation]` dependencies for basic video handling and processing. 
> The funcionalities found in `videopython.generation` won't work.

## Basic Usage

### Video handling

```python
from videopython.base.video import Video

# Load videos and print metadata
video1 = Video.from_path("tests/test_data/fast_benchmark.mp4")
print(video1)

video2 = Video.from_path("tests/test_data/slow_benchmark.mp4")
print(video2)

# Define the transformations
from videopython.base.transforms import CutSeconds, ResampleFPS, Resize, TransformationPipeline

pipeline = TransformationPipeline(
    [CutSeconds(start=1.5, end=6.5), ResampleFPS(fps=30), Resize(width=1000, height=1000)]
)
video1 = pipeline.run(video1)
video2 = pipeline.run(video2)

# Combine videos, add audio and save
from videopython.base.transitions import FadeTransition

fade = FadeTransition(effect_time_seconds=3.0)
video = fade.apply(videos=(video1, video2))
video.add_audio_from_file("tests/test_data/test_audio.mp3")

savepath = video.save()
```

### Video Generation

> Using Nvidia A40 or better is recommended for the `videopython.generation` module.
```python
# Generate image and animate it
from videopython.generation import ImageToVideo
from videopython.generation import TextToImage
from videopython.generation import TextToMusic

image = TextToImage().generate_image(prompt="Golden Retriever playing in the park")
video = ImageToVideo().generate_video(image=image, fps=24)

# Video generation directly from prompt
from videopython.generation import TextToVideo
video_gen = TextToVideo()
video = video_gen.generate_video("Dogs playing in the snow")
for _ in range(10):
    video += video_gen.generate_video("Dogs playing in the snow")

# Cut the first 2 seconds
from videopython.base.transforms import CutSeconds
transformed_video = CutSeconds(start_second=0, end_second=2).apply(video.copy())

# Upsample to 30 FPS
from videopython.base.transforms import ResampleFPS
transformed_video = ResampleFPS(new_fps=30).apply(transformed_video)

# Resize to 1000x1000
from videopython.base.transforms import Resize
transformed_video = Resize(width=1000, height=1000).apply(transformed_video)

# Add generated music
# MusicGen cannot generate more than 1503 tokens (~30seconds of audio)
text_to_music = TextToMusic()
audio = text_to_music.generate_audio("Happy dogs playing together in a park", max_new_tokens=256)
transformed_video.add_audio(audio=audio)

filepath = transformed_video.save()
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "videopython",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.10",
    "maintainer_email": null,
    "keywords": "editing, generation, movie, opencv, python, video, videopython",
    "author": null,
    "author_email": "Bartosz W\u00f3jtowicz <bartoszwojtowicz@outlook.com>, Bartosz Rudnikowicz <bartoszrudnikowicz840@gmail.com>, Piotr Pukisz <piotr.pukisz@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a2/3e/73c925e5b6fa1363512b4203eb54b6899e81f57d6a0fbfc2ee05fe30cd9b/videopython-0.2.1.tar.gz",
    "platform": null,
    "description": "# About\n\nMinimal video generation and processing library.\n\n## Setup \n\n### Install ffmpeg\n```bash\n# Install with brew for MacOS:\nbrew install ffmpeg\n# Install with apt-get for Ubuntu:\nsudo apt-get install ffmpeg\n```\n\n### Install with pip\n```bash\npip install videopython[generation]\n```\n> You can install without `[generation]` dependencies for basic video handling and processing. \n> The funcionalities found in `videopython.generation` won't work.\n\n## Basic Usage\n\n### Video handling\n\n```python\nfrom videopython.base.video import Video\n\n# Load videos and print metadata\nvideo1 = Video.from_path(\"tests/test_data/fast_benchmark.mp4\")\nprint(video1)\n\nvideo2 = Video.from_path(\"tests/test_data/slow_benchmark.mp4\")\nprint(video2)\n\n# Define the transformations\nfrom videopython.base.transforms import CutSeconds, ResampleFPS, Resize, TransformationPipeline\n\npipeline = TransformationPipeline(\n    [CutSeconds(start=1.5, end=6.5), ResampleFPS(fps=30), Resize(width=1000, height=1000)]\n)\nvideo1 = pipeline.run(video1)\nvideo2 = pipeline.run(video2)\n\n# Combine videos, add audio and save\nfrom videopython.base.transitions import FadeTransition\n\nfade = FadeTransition(effect_time_seconds=3.0)\nvideo = fade.apply(videos=(video1, video2))\nvideo.add_audio_from_file(\"tests/test_data/test_audio.mp3\")\n\nsavepath = video.save()\n```\n\n### Video Generation\n\n> Using Nvidia A40 or better is recommended for the `videopython.generation` module.\n```python\n# Generate image and animate it\nfrom videopython.generation import ImageToVideo\nfrom videopython.generation import TextToImage\nfrom videopython.generation import TextToMusic\n\nimage = TextToImage().generate_image(prompt=\"Golden Retriever playing in the park\")\nvideo = ImageToVideo().generate_video(image=image, fps=24)\n\n# Video generation directly from prompt\nfrom videopython.generation import TextToVideo\nvideo_gen = TextToVideo()\nvideo = video_gen.generate_video(\"Dogs playing in the snow\")\nfor _ in range(10):\n    video += video_gen.generate_video(\"Dogs playing in the snow\")\n\n# Cut the first 2 seconds\nfrom videopython.base.transforms import CutSeconds\ntransformed_video = CutSeconds(start_second=0, end_second=2).apply(video.copy())\n\n# Upsample to 30 FPS\nfrom videopython.base.transforms import ResampleFPS\ntransformed_video = ResampleFPS(new_fps=30).apply(transformed_video)\n\n# Resize to 1000x1000\nfrom videopython.base.transforms import Resize\ntransformed_video = Resize(width=1000, height=1000).apply(transformed_video)\n\n# Add generated music\n# MusicGen cannot generate more than 1503 tokens (~30seconds of audio)\ntext_to_music = TextToMusic()\naudio = text_to_music.generate_audio(\"Happy dogs playing together in a park\", max_new_tokens=256)\ntransformed_video.add_audio(audio=audio)\n\nfilepath = transformed_video.save()\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Minimal video generation and processing library.",
    "version": "0.2.1",
    "project_urls": {
        "Documentation": "https://github.com/bartwojtowicz/videopython/",
        "Homepage": "https://github.com/bartwojtowicz/videopython/",
        "Repository": "https://github.com/bartwojtowicz/videopython/"
    },
    "split_keywords": [
        "editing",
        " generation",
        " movie",
        " opencv",
        " python",
        " video",
        " videopython"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "330fc16e320a187684f56dcb15101c476dde10fa6d91d8214f203b60d590b8e1",
                "md5": "d48fdf4f6b4a8a4ea8363b1b30a2ca7d",
                "sha256": "03c7ba811e1e21d8a40b758e11cae0814054b10b19aa6de8da1c73fdfaa81da7"
            },
            "downloads": -1,
            "filename": "videopython-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d48fdf4f6b4a8a4ea8363b1b30a2ca7d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.10",
            "size": 22945,
            "upload_time": "2024-08-18T08:29:05",
            "upload_time_iso_8601": "2024-08-18T08:29:05.169562Z",
            "url": "https://files.pythonhosted.org/packages/33/0f/c16e320a187684f56dcb15101c476dde10fa6d91d8214f203b60d590b8e1/videopython-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a23e73c925e5b6fa1363512b4203eb54b6899e81f57d6a0fbfc2ee05fe30cd9b",
                "md5": "1a6eae4d5fdf9398565c59dde38ef850",
                "sha256": "237e06b1eb1ca57ec7f89bd37a92bf6eaa1f9033d6bc5a8e2807ad6f519f144c"
            },
            "downloads": -1,
            "filename": "videopython-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1a6eae4d5fdf9398565c59dde38ef850",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.10",
            "size": 18929,
            "upload_time": "2024-08-18T08:29:06",
            "upload_time_iso_8601": "2024-08-18T08:29:06.945443Z",
            "url": "https://files.pythonhosted.org/packages/a2/3e/73c925e5b6fa1363512b4203eb54b6899e81f57d6a0fbfc2ee05fe30cd9b/videopython-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-18 08:29:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bartwojtowicz",
    "github_project": "videopython",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "videopython"
}
        
Elapsed time: 0.49378s