videoio


Namevideoio JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/vguzov/videoio
SummaryModule for saving and loading images and depth as H.264 video
upload_time2020-09-16 17:36:42
maintainer
docs_urlNone
authorVladimir Guzov
requires_python
license
keywords mp4 png h264 video image depth ffmpeg
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # videoio: save/load image sequence as H.264 video
A small Python module for saving and loading RGB and uint16 (depth) frames as H.264 encoded video

## Quickstart
##### Save/load RGB frames:
```python
import numpy as np
from videoio import videosave, videoread
frames = np.random.random((20,200,400,3)) #[framesNr, height, width, RGB]
# Save to video
videosave("out.mp4", frames)
# Load from video
frames = videoread("out.mp4")
```

##### Read frames sequentially:
```python
from videoio import VideoReader
for frame in VideoReader("in.mp4"):
    do_something_with(frame)
```

##### Write frames sequentially:
```python
from videoio import VideoWriter
writer = VideoWriter("out.mp4", resolution=(400, 200)) #[width, height]
for i in range(100):
    frame = get_frame()
    writer.write(frame)
writer.close()
```
or
```python
with VideoWriter("out.mp4", resolution=(400, 200)) as writer:
    for i in range(100):
        frame = get_frame()
        writer.write(frame)
```

##### Lossless write/read of uint16 3D arrays (useful for saving depth frames stored in mm, for example Kinect data):
```python
import numpy as np
from videoio import uint16save, uint16read
# Generate 20 random depth frames
depth_frames = (np.random.random((20,200,400))*65535).astype(np.uint16)
# Save
uint16save("out_depth.mp4", depth_frames)
# Load
depth_frames = uint16read("out_depth.mp4")
```

##### Save RGB frames in lossless mode with different compression preset and different FPS:
```python
videosave("out.mp4", frames, lossless=True, preset="veryfast", fps=10.5)
```

##### Read RGB frames and scale them to target resolution simultaneously:
```python
frames = videoread("in.mp4", output_resolution=(100, 250))
```

## Prerequisites
- `ffmpeg` with libx264 enabled and `ffprobe` (usually comes with ffmpeg)
- `numpy`
- `ffmpeg-python`

## Installation
From pip:
```
pip install videoio
```

From source:
```
git clone https://github.com/vguzov/videoio.git
python setup.py install
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vguzov/videoio",
    "name": "videoio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "mp4,png,h264,video,image,depth,ffmpeg",
    "author": "Vladimir Guzov",
    "author_email": "guzov.mail@gmail.com",
    "download_url": "",
    "platform": "",
    "description": "# videoio: save/load image sequence as H.264 video\nA small Python module for saving and loading RGB and uint16 (depth) frames as H.264 encoded video\n\n## Quickstart\n##### Save/load RGB frames:\n```python\nimport numpy as np\nfrom videoio import videosave, videoread\nframes = np.random.random((20,200,400,3)) #[framesNr, height, width, RGB]\n# Save to video\nvideosave(\"out.mp4\", frames)\n# Load from video\nframes = videoread(\"out.mp4\")\n```\n\n##### Read frames sequentially:\n```python\nfrom videoio import VideoReader\nfor frame in VideoReader(\"in.mp4\"):\n    do_something_with(frame)\n```\n\n##### Write frames sequentially:\n```python\nfrom videoio import VideoWriter\nwriter = VideoWriter(\"out.mp4\", resolution=(400, 200)) #[width, height]\nfor i in range(100):\n    frame = get_frame()\n    writer.write(frame)\nwriter.close()\n```\nor\n```python\nwith VideoWriter(\"out.mp4\", resolution=(400, 200)) as writer:\n    for i in range(100):\n        frame = get_frame()\n        writer.write(frame)\n```\n\n##### Lossless write/read of uint16 3D arrays (useful for saving depth frames stored in mm, for example Kinect data):\n```python\nimport numpy as np\nfrom videoio import uint16save, uint16read\n# Generate 20 random depth frames\ndepth_frames = (np.random.random((20,200,400))*65535).astype(np.uint16)\n# Save\nuint16save(\"out_depth.mp4\", depth_frames)\n# Load\ndepth_frames = uint16read(\"out_depth.mp4\")\n```\n\n##### Save RGB frames in lossless mode with different compression preset and different FPS:\n```python\nvideosave(\"out.mp4\", frames, lossless=True, preset=\"veryfast\", fps=10.5)\n```\n\n##### Read RGB frames and scale them to target resolution simultaneously:\n```python\nframes = videoread(\"in.mp4\", output_resolution=(100, 250))\n```\n\n## Prerequisites\n- `ffmpeg` with libx264 enabled and `ffprobe` (usually comes with ffmpeg)\n- `numpy`\n- `ffmpeg-python`\n\n## Installation\nFrom pip:\n```\npip install videoio\n```\n\nFrom source:\n```\ngit clone https://github.com/vguzov/videoio.git\npython setup.py install\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Module for saving and loading images and depth as H.264 video",
    "version": "0.1.2",
    "split_keywords": [
        "mp4",
        "png",
        "h264",
        "video",
        "image",
        "depth",
        "ffmpeg"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3d92945336332b7bf38e2a92fdd47c73",
                "sha256": "81cd2bbad3eec34eb2a9f3eb3a58fd1df86cfbc89541b830748b9a6b30b96833"
            },
            "downloads": -1,
            "filename": "videoio-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3d92945336332b7bf38e2a92fdd47c73",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11847,
            "upload_time": "2020-09-16T17:36:42",
            "upload_time_iso_8601": "2020-09-16T17:36:42.420083Z",
            "url": "https://files.pythonhosted.org/packages/d1/85/ff6cb53b79407c6ee029be111d7be28b476cf17b5beb07010e4b9a012b0a/videoio-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-09-16 17:36:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "vguzov",
    "error": "Could not fetch GitHub repository",
    "lcname": "videoio"
}
        
Elapsed time: 0.14991s