Skip to main content

Videogrep

Videogrep is a command line tool that searches through dialog in video files and makes supercuts based on what it finds. It will recognize .srt or .vtt subtitle tracks, or transcriptions that can be generated with vosk, pocketsphinx, and other tools.

Examples


Installation

Videogrep is compatible with Python versions 3.6 to 3.10.

pip install videogrep

If you want to transcribe videos, you also need to install ffmpeg and vosk.

If you're on a mac with homebrew you install ffmpeg with:

brew install ffmpeg

To install vosk:

pip install vosk

Note: the previous version of videogrep supported pocketsphinx for speech-to-text. Vosk seems much better so I've added support for it and will likely be phasing out support for pocketsphinx.

Usage

The most basic use:

videogrep --input path/to/video --search 'search phrase'

You can put any regular expression in the search phrase.

NOTE: videogrep requires a matching subtitle track with each video you want to use. The video file and subtitle file need to have the exact same name, up to the extension. For example, my_movie.mp4 and my_movie.srt will work, and my_movie.mp4 and my_movie_subtitle.srt will not work.

Videogrep will search for matching srt and vtt subtitles, as well as json transcript files that can be generated with the --transcribe argument.

Options

--input [filename(s)] / -i [filename(s)]

Video or videos to use as input. Most video formats should work.

--output [filename] / -o [filename]

Name of the file to generate. By default this is supercut.mp4. Any standard video extension will also work.

Videogrep will also recognize the following extensions for saving files:

  • .mpv.edl: generates an edl file playable by mpv (useful for previews)
  • .m3u: media playlist
  • .xml: Final Cut Pro timeline, compatable with Adobe Premiere and Davinci Resolve
videogrep --input path/to/video --search 'search phrase' --output coolvid.mp4

--search [query] / -s [query]

Search term, as a regular expression.

--search-type [type] / -st [type]

Type of search you want to perform. There are two options:

  • sentence: (default): Generates clips containing the full sentences of your search query.
  • fragment: Generates clips containing the exact word or phrase of your search query.

Both options take regular expressions. You may only use the fragment search if your transcript has word-level timestamps, which will be the case for youtube .vtt files, or if you generated a transcript using Videogrep itself.

videogrep --input path/to/video --search 'experience' --search-type fragment

--max-clips [num] / -m [num]

Maximum number of clips to use for the supercut.

--demo / -d

Show the search results without making the supercut.

--randomize / -r

Randomize the order of the clips.

--padding [seconds] / -p [seconds]

Padding in seconds to add to the start and end of each clip.

--resyncsubs [seconds] / -rs [seconds]

Time in seconds to shift the shift the subtitles forwards or backwards.

--transcribe / -tr

Transcribe the video using vosk. This will generate a .json file in the same folder as the video. By default this uses vosk's small english model.

NOTE: Because of some compatibility issues, vosk must be installed separately with pip install vosk.

videogrep -i vid.mp4 --transcribe

--model [modelpath] / -mo [modelpath]

In combination with the --transcribe option, allows you to specify the path to a vosk model folder to use. Vosk models are available here in a variety of languages.

videogrep -i vid.mp4 --transcribe --model path/to/model/

--export-clips / -ec

Exports clips as individual files rather than as a supercut.

videogrep -i vid.mp4 --search 'whatever' --export-clips

--ngrams [num] / -n [num]

Shows common words and phrases from the video.

videogrep -i vid.mp4 --ngrams 1

Use it as a module

from videogrep import videogrep

videogrep('path/to/your/files','output_file_name.mp4', 'search_term', 'search_type')

The videogrep module accepts the same parameters as the command line script. To see the usage check out the source.

Example Scripts

Also see the examples folder for:

Release files for videogrep 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for videogrep 2.0.1
File Size Uploaded
videogrep-2.0.1.tar.gz 41.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for videogrep 2.0.1
File Interpreter ABI Platform
videogrep-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 82.3 MB

Release files / videogrep-2.0.1.tar.gz

Download URL videogrep-2.0.1.tar.gz
Size 41.1 MB
Tags Source
SHA-256 checksum
How to use checksums
c310a2b64a34c478ee872b24964fb5030a015d4afb777917741e30c0c5d9a2bd
BLAKE2b-256 checksum
How to use checksums
e6854683e4eac949e08460dc4affbef609f848868018758567aabd0957686610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.6 Darwin/20.6.0

Release files / videogrep-2.0.1-py3-none-any.whl

Download URL videogrep-2.0.1-py3-none-any.whl
Size 41.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
af89e34544e4d5630d05c8106b5716729ebae3ecee26a49897458cd5d05eda30
BLAKE2b-256 checksum
How to use checksums
1c9fc6e5798d3206f3d2013e8cbdc2c8d98950c7611a44726949ef2963b05dc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.6 Darwin/20.6.0

Release history Release notifications | RSS feed

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

This release

2.0.1 This release

2 release files

2.0.0

2 release files

0.5.8

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page