Skip to main content

No project description provided

Project description

ocrvid

PyPI Changelog Tests License

CLI tool to extract text from videos using OCR on macOS.

Installation

Install this tool using pip:

pip install ocrvid

[!NOTE] Currently, this tool only teted on macOS 13 or later.

Usage

Run OCR on a video

To extract text from a video, run:

ocrvid run path/to/video.mp4

then ocrvid generates frames from the video and runs OCR on each frame. Frames are saved in a directory named .ocrvid/frames/video/ in the current directory.

OCR results are saved in a json file named video.json in the current directory. (where video is taken from input file name video)

for example, run against the test video file at tests/video/pexels-eva-elijas.mp4 in this repo:

ocrvid run tests/video/pexels-eva-elijas.mp4

Then pexels-eva-elija.json is generated in the current directory which looks like this:

{
    "video_file":"tests/video/pexels-eva-elijas.mp4",
    "frames_dir":"xxx/.ocrvid/frames/pexels-eva-elijas",
    "frame_rate":100,
    "frames":[
        {
            "frame_file":"xxx/.ocrvid/frames/pexels-eva-elijas/frame-0.png",
            "results":[
                {
                    "text":"INSPIRING WORDS",
                    "confidence":1.0,
                    "bbox":[
                        0.17844826551211515,
                        0.7961793736859821,
                        0.3419540405273438,
                        0.10085802570754931
                    ]
                },
                {
                    "text":"\"Foar kills more dre",
                    "confidence":1.0,
                    "bbox":[
                        0.0724226723609706,
                        0.6839455987759758,
                        0.4780927975972494,
                        0.14592710683043575
                    ]
                },
                {
                    "text":"than failure ever",
                    "confidence":1.0,
                    "bbox":[
                        0.018455287246445035,
                        0.6549868414269003,
                        0.45329265594482426,
                        0.14363905857426462
                    ]
                },
                {
                    "text":"IZY KASSEM",
                    "confidence":0.5,
                    "bbox":[
                        -0.015967150208537523,
                        0.6675747977206025,
                        0.23065692583719888,
                        0.08114868486431293
                    ]
                },
                {
                    "text":"Entrepreneur",
                    "confidence":1.0,
                    "bbox":[
                        0.01941176222542875,
                        0.1353812367971159,
                        0.9058370590209961,
                        0.26137274083956863
                    ]
                }
            ]
        },
...

Interact with YouTube

Interacting YouTube? Please see yt-dlp.

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd ocrvid
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test,dev]'

To run the tests:

make test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocrvid-0.3.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

ocrvid-0.3.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file ocrvid-0.3.0.tar.gz.

File metadata

  • Download URL: ocrvid-0.3.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for ocrvid-0.3.0.tar.gz
Algorithm Hash digest
SHA256 37f9e18165abc21c82ae6ce45e034f2eecd8a063c9717e8402ee854a5b44016d
MD5 978724d6303bf9008d7f24c81fb15ae5
BLAKE2b-256 bae364aac937de32c7da5b7d48707d0a4d02e4b026cc76e704efdd545f1bf9ba

See more details on using hashes here.

File details

Details for the file ocrvid-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ocrvid-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for ocrvid-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d9d9cef4f25e107cf19b79936e609a388e126983083a23925b80cb9fc07e507
MD5 29875c349c65955b5a8fc9ff6973392b
BLAKE2b-256 c509d61c7a4fefa722348e22f867a01337d1cd6234ed31a384e168ee20fb3470

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page