scenecut-extractor


Namescenecut-extractor JSON
Version 0.6.1 PyPI version JSON
download
home_pagehttps://github.com/slhck/scenecut-extractor
SummaryGet scenecuts from a video file using ffmpeg
upload_time2023-03-10 16:11:15
maintainer
docs_urlNone
authorWerner Robitza
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Scenecut Extractor

[![PyPI version](https://img.shields.io/pypi/v/scenecut-extractor.svg)](https://pypi.org/project/scenecut-extractor)

[![Python package](https://github.com/slhck/scenecut-extractor/actions/workflows/python-package.yml/badge.svg)](https://github.com/slhck/scenecut-extractor/actions/workflows/python-package.yml)

Extract scenecuts from video files using ffmpeg.

This tool uses the [`select` filter](http://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect) from ffmpeg to determine the scene cut probability of adjacent frames, and allows users to determine which frames (or at which timestamps) the scene cuts happen.

**Note:** Previous versions installed a `scenecut_extractor` executable. To harmonize it with other tools, now the executable is called `scenecut-extractor`. Please ensure you remove the old executable (e.g. run `which scenecut_extractor` and remove the file).

Author: Werner Robitza <werner.robitza@gmail.com>

**Contents:**

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Extended Usage](#extended-usage)
- [API](#api)
- [Alternatives](#alternatives)
- [License](#license)

## Requirements

- Python 3.8 or higher
- FFmpeg:
    - download a static build from [their website](http://ffmpeg.org/download.html))
    - put the `ffmpeg` executable in your `$PATH`

## Installation

```bash
pip3 install --user scenecut_extractor
```

Or clone this repository, then run the tool with `python3 -m scenecut_extractor`.

## Usage

Run:

```bash
scenecut-extractor <input-file>
```

This might take a while depending on the length of your input file, and then output a list of scene cuts in JSON format:

```json
[
  {
    "frame": 114,
    "pts": 114.0,
    "pts_time": 3.8,
    "score": 0.445904
  },
  {
    "frame": 159,
    "pts": 159.0,
    "pts_time": 5.3,
    "score": 0.440126
  }
]
```

To extract the scene cuts, use the `-x` flag and optionally specify an output directory with `-d`:

```bash
scenecut-extractor <input-file> -x -d output-directory
```

This will create a directory called `output-directory` and put the extracted scenes in there. The filenames will be the same as the input file, but with the scene times appended to them.

**Note:** Cutting may not be frame-accurate. To be precise, you have to re-encode the video. Use the `--no-copy` flag to do this. The output will use libx264 encoding with CRF 23 to achieve a good balance between quality and file size. Future versions of this tool will allow you to specify your own encoding options.

## Extended Usage

The command supports the following arguments and options, see `scenecut-extractor -h`:

```
usage: scenecut-extractor [-h] [-t THRESHOLD] [-o {all,frames,seconds}]
                   [-of {json,csv}] [-x] [-d OUTPUT_DIRECTORY] [--no-copy]
                   [-p] [-v]
                   input

scenecut_extractor v0.5.0

positional arguments:
  input                 input file

options:
  -h, --help            show this help message and exit
  -t THRESHOLD, --threshold THRESHOLD
                        threshold (between 0 and 1) (default: 0.3)
  -o {all,frames,seconds}, --output {all,frames,seconds}
                        output which information (default: all)
  -of {json,csv}, --output-format {json,csv}
                        output in which format (default: json)
  -x, --extract         extract the scene cuts (default: False)
  -d OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
                        Set the output directory. Default is the current
                        working directory. (default: None)
  --no-copy             Don't stream-copy, but re-encode the video. (default:
                        False)
  -p, --progress        Show a progress bar on stderr (default: False)
  -v, --verbose         Print verbose info to stderr (default: False)
```

You can use the `-t` parameter to set the threshold that ffmpeg internally uses (between 0 and 1) – if you set it to 0, all frames will be printed with their probabilities.

## API

This program has a simple API that can be used to integrate it into other Python programs.

For more information see the [API documentation](https://htmlpreview.github.io/?https://github.com/slhck/scenecut-extractor/blob/master/docs/scenecut_extractor.html).

## Alternatives

For extended scene detection features such as automatic splitting or perceptual hashing, you may want to check out [PySceneDetect](https://pyscenedetect.readthedocs.io/en/latest/).

## License

scenecut_extractor, Copyright (c) 2018–2023 Werner Robitza

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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/slhck/scenecut-extractor",
    "name": "scenecut-extractor",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Werner Robitza",
    "author_email": "werner.robitza@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b3/b7/4326f924ff7ad8b04bff4ed9e514016db6e77303864ed4aae97cfbff7379/scenecut_extractor-0.6.1.tar.gz",
    "platform": null,
    "description": "# Scenecut Extractor\n\n[![PyPI version](https://img.shields.io/pypi/v/scenecut-extractor.svg)](https://pypi.org/project/scenecut-extractor)\n\n[![Python package](https://github.com/slhck/scenecut-extractor/actions/workflows/python-package.yml/badge.svg)](https://github.com/slhck/scenecut-extractor/actions/workflows/python-package.yml)\n\nExtract scenecuts from video files using ffmpeg.\n\nThis tool uses the [`select` filter](http://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect) from ffmpeg to determine the scene cut probability of adjacent frames, and allows users to determine which frames (or at which timestamps) the scene cuts happen.\n\n**Note:** Previous versions installed a `scenecut_extractor` executable. To harmonize it with other tools, now the executable is called `scenecut-extractor`. Please ensure you remove the old executable (e.g. run `which scenecut_extractor` and remove the file).\n\nAuthor: Werner Robitza <werner.robitza@gmail.com>\n\n**Contents:**\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Extended Usage](#extended-usage)\n- [API](#api)\n- [Alternatives](#alternatives)\n- [License](#license)\n\n## Requirements\n\n- Python 3.8 or higher\n- FFmpeg:\n    - download a static build from [their website](http://ffmpeg.org/download.html))\n    - put the `ffmpeg` executable in your `$PATH`\n\n## Installation\n\n```bash\npip3 install --user scenecut_extractor\n```\n\nOr clone this repository, then run the tool with `python3 -m scenecut_extractor`.\n\n## Usage\n\nRun:\n\n```bash\nscenecut-extractor <input-file>\n```\n\nThis might take a while depending on the length of your input file, and then output a list of scene cuts in JSON format:\n\n```json\n[\n  {\n    \"frame\": 114,\n    \"pts\": 114.0,\n    \"pts_time\": 3.8,\n    \"score\": 0.445904\n  },\n  {\n    \"frame\": 159,\n    \"pts\": 159.0,\n    \"pts_time\": 5.3,\n    \"score\": 0.440126\n  }\n]\n```\n\nTo extract the scene cuts, use the `-x` flag and optionally specify an output directory with `-d`:\n\n```bash\nscenecut-extractor <input-file> -x -d output-directory\n```\n\nThis will create a directory called `output-directory` and put the extracted scenes in there. The filenames will be the same as the input file, but with the scene times appended to them.\n\n**Note:** Cutting may not be frame-accurate. To be precise, you have to re-encode the video. Use the `--no-copy` flag to do this. The output will use libx264 encoding with CRF 23 to achieve a good balance between quality and file size. Future versions of this tool will allow you to specify your own encoding options.\n\n## Extended Usage\n\nThe command supports the following arguments and options, see `scenecut-extractor -h`:\n\n```\nusage: scenecut-extractor [-h] [-t THRESHOLD] [-o {all,frames,seconds}]\n                   [-of {json,csv}] [-x] [-d OUTPUT_DIRECTORY] [--no-copy]\n                   [-p] [-v]\n                   input\n\nscenecut_extractor v0.5.0\n\npositional arguments:\n  input                 input file\n\noptions:\n  -h, --help            show this help message and exit\n  -t THRESHOLD, --threshold THRESHOLD\n                        threshold (between 0 and 1) (default: 0.3)\n  -o {all,frames,seconds}, --output {all,frames,seconds}\n                        output which information (default: all)\n  -of {json,csv}, --output-format {json,csv}\n                        output in which format (default: json)\n  -x, --extract         extract the scene cuts (default: False)\n  -d OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY\n                        Set the output directory. Default is the current\n                        working directory. (default: None)\n  --no-copy             Don't stream-copy, but re-encode the video. (default:\n                        False)\n  -p, --progress        Show a progress bar on stderr (default: False)\n  -v, --verbose         Print verbose info to stderr (default: False)\n```\n\nYou can use the `-t` parameter to set the threshold that ffmpeg internally uses (between 0 and 1) \u2013 if you set it to 0, all frames will be printed with their probabilities.\n\n## API\n\nThis program has a simple API that can be used to integrate it into other Python programs.\n\nFor more information see the [API documentation](https://htmlpreview.github.io/?https://github.com/slhck/scenecut-extractor/blob/master/docs/scenecut_extractor.html).\n\n## Alternatives\n\nFor extended scene detection features such as automatic splitting or perceptual hashing, you may want to check out [PySceneDetect](https://pyscenedetect.readthedocs.io/en/latest/).\n\n## License\n\nscenecut_extractor, Copyright (c) 2018\u20132023 Werner Robitza\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Get scenecuts from a video file using ffmpeg",
    "version": "0.6.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d64c997f2562713a72e7f6338125304cb6275e25634395c2e06c8a0dca3a930c",
                "md5": "2ae92adca1354241f22290375f2616e9",
                "sha256": "3e1925d1b1fe4879da2400ac4f9e82980e78e2ac9a7665e0977e704483b0e326"
            },
            "downloads": -1,
            "filename": "scenecut_extractor-0.6.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2ae92adca1354241f22290375f2616e9",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 9863,
            "upload_time": "2023-03-10T16:11:13",
            "upload_time_iso_8601": "2023-03-10T16:11:13.730986Z",
            "url": "https://files.pythonhosted.org/packages/d6/4c/997f2562713a72e7f6338125304cb6275e25634395c2e06c8a0dca3a930c/scenecut_extractor-0.6.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3b74326f924ff7ad8b04bff4ed9e514016db6e77303864ed4aae97cfbff7379",
                "md5": "43ff44f490a5016cc6e7060e93d82e09",
                "sha256": "6a0f410360c0f17c932d1eb439f94a1a3e28da2481bba9325e781c7c004b9cc0"
            },
            "downloads": -1,
            "filename": "scenecut_extractor-0.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "43ff44f490a5016cc6e7060e93d82e09",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11370,
            "upload_time": "2023-03-10T16:11:15",
            "upload_time_iso_8601": "2023-03-10T16:11:15.166719Z",
            "url": "https://files.pythonhosted.org/packages/b3/b7/4326f924ff7ad8b04bff4ed9e514016db6e77303864ed4aae97cfbff7379/scenecut_extractor-0.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-10 16:11:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "slhck",
    "github_project": "scenecut-extractor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "scenecut-extractor"
}
        
Elapsed time: 0.04169s