Skip to content

LLM fragment plugin to turn a video into images of different frames

License

Notifications You must be signed in to change notification settings

simonw/llm-video-frames

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llm-video-frames

PyPI Changelog Tests License

LLM plugin to turn a video into individual frames

Installation

Install this plugin in the same environment as LLM.

llm install llm-video-frames

Requires ffmpeg installed and available on the system PATH. On macOS, you can install it using Homebrew:

brew install ffmpeg

Usage

The llm-video-frames plugin provides a fragment loader that extracts individual frames from a video file using ffmpeg.

You can use the video-frames: fragment prefix to turn a video into a series of image attachments.

Fragment syntax

video-frames:<path>?fps=N&timestamps=1
  • <path>: Path to the video file accessible to the environment where LLM runs.
  • fps=N: (optional) Number of frames per second to extract. Defaults to 1 if omitted.
  • timestamps=1: (optional) If set to 1, overlays the filename and timestamp on each extracted frame in the bottom-right corner.

Examples

Extract 1 frame per second (default) from video.mp4:

llm -f video-frames:video.mp4 'describe the key scenes in this video'

Extract 5 frames per second:

llm -f 'video-frames:video.mp4?fps=5' 'summarize the video'

Extract 2 frames per second with filename and timestamps overlayed on frames:

llm -f 'video-frames:video.mp4?fps=2&timestamps=1' 'list notable events with timestamps'

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd llm-video-frames
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

python -m pip install -e '.[test]'

To run the tests:

python -m pytest

About

LLM fragment plugin to turn a video into images of different frames

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages