videopk


Namevideopk JSON
Version 2.0.0 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-08-15 20:17:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseCopyright 2024 Sébastien Gemme Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords transcoding video
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Video Pocket Knife (videopk)

A collection of helper functions for processing videos. Currently, only transcoding is supported.

The initial use case was reducing the size of the videos acquired using a cell phone which normally have an overkill bitrate. This was driven by the need to save space on my Google Photos account.

Currently only one tool is available ```video-transcode```, please type ```video-transcode --help``` for details. The resulting transcoded file will contain all the metadata of the initial file including the rotation. The resulting file is in ```mp4``` file format where the video stream is encoded using [High Efficiency Video Coding (HEVC), also known as H.265](https://fr.wikipedia.org/wiki/H.265).

## Installation

```bash
pip install videopk
```

The code relies on [FFmpeg](https://www.ffmpeg.org/) to perform the conversion. Make sure ```ffmpeg``` is installed and in your path. This code has not been tested on windows, only under Linux.

* For gpu support, make sure to install [FFmpeg NVIDIA GPU Hardware Acceleation](https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/ffmpeg-with-nvidia-gpu/index.html). 
* Also make sure the ```ffmpeg``` installation has ```libx265``` support if you want to perform software encoding.

## How to use

To transcode a video file, use ```video-transcode```:
```
usage: video transcoding [-h] [-v] [-n] [--version] [-b BITRATE] input_file output_dir

positional arguments:
  input_file            Input file
  output_dir            Outout directory

options:
  -h, --help            show this help message and exit
  -v, --verbose         Verbose output
  -n, --no_gpu          Do not use gpu
  --version             show program's version number and exit
  -b BITRATE, --bitrate BITRATE
                        Bitrate, in bps, if not specified, nominal bitrate is calculated (preferred option)
```

To transcode a file using nominal bitrate. Note that the nominal bitrate is conservately high, suitable for scenes that are noisy such as scenes that contain trees, clouds and bushes. This bitrate has been determined using [this calculator](https://www.dr-lex.be/info-stuff/videocalc.html).

```bash
video-transcode input.mp4 output_dir
```

The resulting file will be located under ```output_dir/input.mp4```. 

## API Usage

Sample. Currenty, the API is meant to be asynchronous, synchronous version of the API will be added in the future.

```python
import asyncio

from videopk.ffmpeg import Transcoder


async def main():
    transcoder = Transcoder()

    # Try using the gpu for encoding, will throw an exception if no gpu codec is found
    # Currently, this will throw an FFmpegUnsupportedCodec exception.
    transcoder.parameters.try_gpu = True

    # Will compute the nominal bitrate using average framerate of the file and its resolution
    transcoder.parameters.auto_bitrate = True

    # Output file will be in H.265 (HEVC) format
    await transcoder.transcode("input.mp4", "output.mp4")


if __name__ == "__main__":
    asyncio.run(main())
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "videopk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "S\u00e9bastien Gemme <sgemme7@gmail.com>",
    "keywords": "transcoding, video",
    "author": null,
    "author_email": "S\u00e9bastien Gemme <sgemme7@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d9/02/27a7a5e0fa908a7af94dbcfde3dce79c4485a8d5064ebb4600cec0cb538b/videopk-2.0.0.tar.gz",
    "platform": null,
    "description": "# Video Pocket Knife (videopk)\n\nA collection of helper functions for processing videos. Currently, only transcoding is supported.\n\nThe initial use case was reducing the size of the videos acquired using a cell phone which normally have an overkill bitrate. This was driven by the need to save space on my Google Photos account.\n\nCurrently only one tool is available ```video-transcode```, please type ```video-transcode --help``` for details. The resulting transcoded file will contain all the metadata of the initial file including the rotation. The resulting file is in ```mp4``` file format where the video stream is encoded using [High Efficiency Video Coding (HEVC), also known as H.265](https://fr.wikipedia.org/wiki/H.265).\n\n## Installation\n\n```bash\npip install videopk\n```\n\nThe code relies on [FFmpeg](https://www.ffmpeg.org/) to perform the conversion. Make sure ```ffmpeg``` is installed and in your path. This code has not been tested on windows, only under Linux.\n\n* For gpu support, make sure to install [FFmpeg NVIDIA GPU Hardware Acceleation](https://docs.nvidia.com/video-technologies/video-codec-sdk/11.1/ffmpeg-with-nvidia-gpu/index.html). \n* Also make sure the ```ffmpeg``` installation has ```libx265``` support if you want to perform software encoding.\n\n## How to use\n\nTo transcode a video file, use ```video-transcode```:\n```\nusage: video transcoding [-h] [-v] [-n] [--version] [-b BITRATE] input_file output_dir\n\npositional arguments:\n  input_file            Input file\n  output_dir            Outout directory\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --verbose         Verbose output\n  -n, --no_gpu          Do not use gpu\n  --version             show program's version number and exit\n  -b BITRATE, --bitrate BITRATE\n                        Bitrate, in bps, if not specified, nominal bitrate is calculated (preferred option)\n```\n\nTo transcode a file using nominal bitrate. Note that the nominal bitrate is conservately high, suitable for scenes that are noisy such as scenes that contain trees, clouds and bushes. This bitrate has been determined using [this calculator](https://www.dr-lex.be/info-stuff/videocalc.html).\n\n```bash\nvideo-transcode input.mp4 output_dir\n```\n\nThe resulting file will be located under ```output_dir/input.mp4```. \n\n## API Usage\n\nSample. Currenty, the API is meant to be asynchronous, synchronous version of the API will be added in the future.\n\n```python\nimport asyncio\n\nfrom videopk.ffmpeg import Transcoder\n\n\nasync def main():\n    transcoder = Transcoder()\n\n    # Try using the gpu for encoding, will throw an exception if no gpu codec is found\n    # Currently, this will throw an FFmpegUnsupportedCodec exception.\n    transcoder.parameters.try_gpu = True\n\n    # Will compute the nominal bitrate using average framerate of the file and its resolution\n    transcoder.parameters.auto_bitrate = True\n\n    # Output file will be in H.265 (HEVC) format\n    await transcoder.transcode(\"input.mp4\", \"output.mp4\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n",
    "bugtrack_url": null,
    "license": "Copyright 2024 S\u00e9bastien Gemme  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": null,
    "version": "2.0.0",
    "project_urls": {
        "homepage": "https://github.com/sebastiengemme/videopk"
    },
    "split_keywords": [
        "transcoding",
        " video"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d60321ea53a84700c65afed063d64f180ef8dd6b8a8a21129885fe6ece80ae1",
                "md5": "e141f2bf8808312f5a7e618a95265c0e",
                "sha256": "c6ba9770e8f212bb4648628601630836ccd8cacdcb06f223398326006e86a850"
            },
            "downloads": -1,
            "filename": "videopk-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e141f2bf8808312f5a7e618a95265c0e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9202,
            "upload_time": "2024-08-15T20:17:10",
            "upload_time_iso_8601": "2024-08-15T20:17:10.942150Z",
            "url": "https://files.pythonhosted.org/packages/2d/60/321ea53a84700c65afed063d64f180ef8dd6b8a8a21129885fe6ece80ae1/videopk-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d90227a7a5e0fa908a7af94dbcfde3dce79c4485a8d5064ebb4600cec0cb538b",
                "md5": "a546083ea9f32a88f4f160247dd6c01d",
                "sha256": "0399d9d57d0dd5de39cbfad2fc055d708368c05b34f3001cd224aa2a30b6c1e4"
            },
            "downloads": -1,
            "filename": "videopk-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a546083ea9f32a88f4f160247dd6c01d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8289,
            "upload_time": "2024-08-15T20:17:12",
            "upload_time_iso_8601": "2024-08-15T20:17:12.816007Z",
            "url": "https://files.pythonhosted.org/packages/d9/02/27a7a5e0fa908a7af94dbcfde3dce79c4485a8d5064ebb4600cec0cb538b/videopk-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-15 20:17:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sebastiengemme",
    "github_project": "videopk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "videopk"
}
        
Elapsed time: 8.82652s