capture_stream


Namecapture_stream JSON
Version 0.0.1.5 PyPI version JSON
download
home_pagehttps://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/capture_stream
SummaryCapture video stream, save as screenshots.
upload_time2024-09-21 06:34:41
maintainerNone
docs_urlNone
authorChenyangGao
requires_python<4.0,>=3.9
licenseMIT
keywords video stream capture
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Capture video stream, save as screenshots.

## Installation

You can install from [pypi](https://pypi.org/project/capture_stream/)

```console
pip install -U capture_stream
```

## Usage

### As a Module

```python
>>> import capture_stream
>>> help(capture_stream)

Help on package capture_stream:

NAME
    capture_stream - # encoding: utf-8

PACKAGE CONTENTS
    __main__

FUNCTIONS
    cv_capture(url: str, start: int = 0, stop: None | int = None, step: int = 1, prefix: str = 'frame_', dir_to_save: str = '')
        从 url 读取视频流,保存图片到本地,jpg 图片格式
        
        :param url: 视频链接
        :param start: 开始索引(从 0 开始编号)
        :param stop:  结束索引(不含此帧),如果 stop 为 None 则到视频结束
        :param step:  索引递增步长
        :param prefix: 文件名会被保存为 f"{prefix}{frame_number}.jpg",frame_number 是帧的索引序号
        :param dir_to_save: 把生成的 jpg 保存到此目录,默认是当前工作目录
        
        从第 start 帧开始,到第 stop 帧结束,以 step 帧递增
            - 如果 step <= 0,只截取 start 那一帧
            - 如果 stop 为 None,则从 start 到视频结束
            - 否则,跳过此视频
    
    cv_capture_iter(url: str, start: int = 0, stop: None | int = None, step: int = 1) -> collections.abc.Iterator[tuple[int, numpy.ndarray]]
        从 url 读取视频流,返回帧的迭代器
        
        :param url: 视频链接
        :param start: 开始索引(从 0 开始编号)
        :param stop:  结束索引(不含此帧),如果 stop 为 None 则到视频结束
        :param step:  索引递增步长
        
        :return: (帧索引序号, 图片数据) 的元组的迭代器
        
        从第 start 帧开始,到第 stop 帧结束,以 step 帧递增
            - 如果 step <= 0,只截取 start 那一帧
            - 如果 stop 为 None,则从 start 到视频结束
            - 否则,跳过此视频

DATA
    __all__ = ['cv_capture_iter', 'cv_capture']

VERSION
    (0, 0, 1)

AUTHOR
    ChenyangGao <https://chenyanggao.github.io>

FILE
    /path/to/capture_stream/__init__.py
```

### As a Command Line

You can use this module to capture screenshots for video steam.

```console
$ capture_stream -h
usage: capture_stream [-h] [-s START] [-t STOP] [-st STEP] [-p PREFIX] [-d DIR_TO_SAVE] [-v] url

从 url 读取视频流,为某些帧截图

positional arguments:
  url                   视频的 url

options:
  -h, --help            show this help message and exit
  -s START, --start START
                        开始帧的索引,从 0 开始编号,默认值:0
  -t STOP, --stop STOP  结束帧的索引(不含),默认为到视频结束
  -st STEP, --step STEP
                        帧的索引递增步长,如果小于等于 0 则只截取 start 那一帧,默认值:1
  -p PREFIX, --prefix PREFIX
                        生成图片的名称的前缀,文件名会被保存为 f'{prefix}{frame_number}.jpg',frame_number 是帧的索引序号,默认无前缀
  -d DIR_TO_SAVE, --dir-to-save DIR_TO_SAVE
                        把生成的 jpg 保存到此目录,默认值:当前工作目录
  -v, --version         输出版本号
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/capture_stream",
    "name": "capture_stream",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "video, stream, capture",
    "author": "ChenyangGao",
    "author_email": "wosiwujm@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1d/50/b9eca22533096c2361a9e65af0bde780be92c4e1433d8f6ae4d30cbadf77/capture_stream-0.0.1.5.tar.gz",
    "platform": null,
    "description": "# Capture video stream, save as screenshots.\n\n## Installation\n\nYou can install from [pypi](https://pypi.org/project/capture_stream/)\n\n```console\npip install -U capture_stream\n```\n\n## Usage\n\n### As a Module\n\n```python\n>>> import capture_stream\n>>> help(capture_stream)\n\nHelp on package capture_stream:\n\nNAME\n    capture_stream - # encoding: utf-8\n\nPACKAGE CONTENTS\n    __main__\n\nFUNCTIONS\n    cv_capture(url: str, start: int = 0, stop: None | int = None, step: int = 1, prefix: str = 'frame_', dir_to_save: str = '')\n        \u4ece url \u8bfb\u53d6\u89c6\u9891\u6d41\uff0c\u4fdd\u5b58\u56fe\u7247\u5230\u672c\u5730\uff0cjpg \u56fe\u7247\u683c\u5f0f\n        \n        :param url: \u89c6\u9891\u94fe\u63a5\n        :param start: \u5f00\u59cb\u7d22\u5f15\uff08\u4ece 0 \u5f00\u59cb\u7f16\u53f7\uff09\n        :param stop:  \u7ed3\u675f\u7d22\u5f15\uff08\u4e0d\u542b\u6b64\u5e27\uff09\uff0c\u5982\u679c stop \u4e3a None \u5219\u5230\u89c6\u9891\u7ed3\u675f\n        :param step:  \u7d22\u5f15\u9012\u589e\u6b65\u957f\n        :param prefix: \u6587\u4ef6\u540d\u4f1a\u88ab\u4fdd\u5b58\u4e3a f\"{prefix}{frame_number}.jpg\"\uff0cframe_number \u662f\u5e27\u7684\u7d22\u5f15\u5e8f\u53f7\n        :param dir_to_save: \u628a\u751f\u6210\u7684 jpg \u4fdd\u5b58\u5230\u6b64\u76ee\u5f55\uff0c\u9ed8\u8ba4\u662f\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\n        \n        \u4ece\u7b2c start \u5e27\u5f00\u59cb\uff0c\u5230\u7b2c stop \u5e27\u7ed3\u675f\uff0c\u4ee5 step \u5e27\u9012\u589e\n            - \u5982\u679c step <= 0\uff0c\u53ea\u622a\u53d6 start \u90a3\u4e00\u5e27\n            - \u5982\u679c stop \u4e3a None\uff0c\u5219\u4ece start \u5230\u89c6\u9891\u7ed3\u675f\n            - \u5426\u5219\uff0c\u8df3\u8fc7\u6b64\u89c6\u9891\n    \n    cv_capture_iter(url: str, start: int = 0, stop: None | int = None, step: int = 1) -> collections.abc.Iterator[tuple[int, numpy.ndarray]]\n        \u4ece url \u8bfb\u53d6\u89c6\u9891\u6d41\uff0c\u8fd4\u56de\u5e27\u7684\u8fed\u4ee3\u5668\n        \n        :param url: \u89c6\u9891\u94fe\u63a5\n        :param start: \u5f00\u59cb\u7d22\u5f15\uff08\u4ece 0 \u5f00\u59cb\u7f16\u53f7\uff09\n        :param stop:  \u7ed3\u675f\u7d22\u5f15\uff08\u4e0d\u542b\u6b64\u5e27\uff09\uff0c\u5982\u679c stop \u4e3a None \u5219\u5230\u89c6\u9891\u7ed3\u675f\n        :param step:  \u7d22\u5f15\u9012\u589e\u6b65\u957f\n        \n        :return: (\u5e27\u7d22\u5f15\u5e8f\u53f7, \u56fe\u7247\u6570\u636e) \u7684\u5143\u7ec4\u7684\u8fed\u4ee3\u5668\n        \n        \u4ece\u7b2c start \u5e27\u5f00\u59cb\uff0c\u5230\u7b2c stop \u5e27\u7ed3\u675f\uff0c\u4ee5 step \u5e27\u9012\u589e\n            - \u5982\u679c step <= 0\uff0c\u53ea\u622a\u53d6 start \u90a3\u4e00\u5e27\n            - \u5982\u679c stop \u4e3a None\uff0c\u5219\u4ece start \u5230\u89c6\u9891\u7ed3\u675f\n            - \u5426\u5219\uff0c\u8df3\u8fc7\u6b64\u89c6\u9891\n\nDATA\n    __all__ = ['cv_capture_iter', 'cv_capture']\n\nVERSION\n    (0, 0, 1)\n\nAUTHOR\n    ChenyangGao <https://chenyanggao.github.io>\n\nFILE\n    /path/to/capture_stream/__init__.py\n```\n\n### As a Command Line\n\nYou can use this module to capture screenshots for video steam.\n\n```console\n$ capture_stream -h\nusage: capture_stream [-h] [-s START] [-t STOP] [-st STEP] [-p PREFIX] [-d DIR_TO_SAVE] [-v] url\n\n\u4ece url \u8bfb\u53d6\u89c6\u9891\u6d41\uff0c\u4e3a\u67d0\u4e9b\u5e27\u622a\u56fe\n\npositional arguments:\n  url                   \u89c6\u9891\u7684 url\n\noptions:\n  -h, --help            show this help message and exit\n  -s START, --start START\n                        \u5f00\u59cb\u5e27\u7684\u7d22\u5f15\uff0c\u4ece 0 \u5f00\u59cb\u7f16\u53f7\uff0c\u9ed8\u8ba4\u503c\uff1a0\n  -t STOP, --stop STOP  \u7ed3\u675f\u5e27\u7684\u7d22\u5f15\uff08\u4e0d\u542b\uff09\uff0c\u9ed8\u8ba4\u4e3a\u5230\u89c6\u9891\u7ed3\u675f\n  -st STEP, --step STEP\n                        \u5e27\u7684\u7d22\u5f15\u9012\u589e\u6b65\u957f\uff0c\u5982\u679c\u5c0f\u4e8e\u7b49\u4e8e 0 \u5219\u53ea\u622a\u53d6 start \u90a3\u4e00\u5e27\uff0c\u9ed8\u8ba4\u503c\uff1a1\n  -p PREFIX, --prefix PREFIX\n                        \u751f\u6210\u56fe\u7247\u7684\u540d\u79f0\u7684\u524d\u7f00\uff0c\u6587\u4ef6\u540d\u4f1a\u88ab\u4fdd\u5b58\u4e3a f'{prefix}{frame_number}.jpg'\uff0cframe_number \u662f\u5e27\u7684\u7d22\u5f15\u5e8f\u53f7\uff0c\u9ed8\u8ba4\u65e0\u524d\u7f00\n  -d DIR_TO_SAVE, --dir-to-save DIR_TO_SAVE\n                        \u628a\u751f\u6210\u7684 jpg \u4fdd\u5b58\u5230\u6b64\u76ee\u5f55\uff0c\u9ed8\u8ba4\u503c\uff1a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\n  -v, --version         \u8f93\u51fa\u7248\u672c\u53f7\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Capture video stream, save as screenshots.",
    "version": "0.0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/capture_stream",
        "Repository": "https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/capture_stream"
    },
    "split_keywords": [
        "video",
        " stream",
        " capture"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "500610e4754697fd887c9a4335d1b9b583ed6d6a76881d439f2632dcb3dc852a",
                "md5": "01b11e5fb59b4b6885992209279a8f6e",
                "sha256": "56d2808f4615d1ea280125c93a86c30b950931b91d04bfd051dd194ae954b9da"
            },
            "downloads": -1,
            "filename": "capture_stream-0.0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "01b11e5fb59b4b6885992209279a8f6e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 7044,
            "upload_time": "2024-09-21T06:34:38",
            "upload_time_iso_8601": "2024-09-21T06:34:38.043194Z",
            "url": "https://files.pythonhosted.org/packages/50/06/10e4754697fd887c9a4335d1b9b583ed6d6a76881d439f2632dcb3dc852a/capture_stream-0.0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1d50b9eca22533096c2361a9e65af0bde780be92c4e1433d8f6ae4d30cbadf77",
                "md5": "af253c1373ca4bb8bf3f84c593c34cf0",
                "sha256": "3d25b93c989e33bce12129e3452aa85ddc1d8d5c029854dabaef69dfa205a1ce"
            },
            "downloads": -1,
            "filename": "capture_stream-0.0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "af253c1373ca4bb8bf3f84c593c34cf0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 4390,
            "upload_time": "2024-09-21T06:34:41",
            "upload_time_iso_8601": "2024-09-21T06:34:41.210353Z",
            "url": "https://files.pythonhosted.org/packages/1d/50/b9eca22533096c2361a9e65af0bde780be92c4e1433d8f6ae4d30cbadf77/capture_stream-0.0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-21 06:34:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ChenyangGao",
    "github_project": "web-mount-packs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "capture_stream"
}
        
Elapsed time: 0.37118s