Skip to main content

Extract frames from videos and convert them to images or gifs.

Project description

videoxt

videoxt is a Python library and command-line tool that allows you to convert video frames to images, or create a GIF between two points in a video.

https://user-images.githubusercontent.com/3451528/222927520-6fd23a1f-b5f1-45db-b1db-2aa7e2566e47.mp4


InstallationExamplesOptionsUsed by


Installation

pip install videoxt

or

git clone https://github.com/gurrutia/videoxt.git

Examples

NOTE: All command-line examples are run from the directory where the video is located. You can run the commands from any directory by specifying the full path to the video.

Example 1: Extract all video frames.

from videoxt.extractors import VideoToImage

vti = VideoToImage("C:/Users/gurrutia/Videos/video.mp4")

vti.extract_images()

Command-line equivalent:

vxt images video.mp4

videoxt_example_1

Example 2: Extract every 30th frame from 50 seconds to the end of the video, save the images as png, resize the frames by 50% and rotate the frames by 180 degrees.

from videoxt.extractors import VideoToImage

vti = VideoToImage(
  "C:/Users/gurrutia/Videos/video.mp4",
  start_time=50,
  capture_rate=30,
  image_format="png",
  resize=0.5,
  rotate=180,
)

vti.extract_images()

Command-line equivalent:

vxt images video.mp4 --start-time 50 --capture-rate 30 --image-format png --resize 0.5 --rotate 180

videoxt_example_2

Example 3: Create a GIF between 01:10 and 01:12 of the video at 1/4 the video speed, and resize the GIF to 640x480.

from videoxt.extractors import VideoToGIF

vtg = VideoToGIF(
  "C:/Users/gurrutia/Videos/video.mp4",
  start_time="01:10",
  stop_time="01:12",
  speed=.25,
  dimensions=(640, 480),
)

vtg.create_gif()

Command-line equivalent:

vxt gif video.mp4 --start-time 01:10 --stop-time 01:12 --speed 0.25 --dimensions 640 480

videoxt_example_2

Options

Options / Shared

Argument                   Description
video_path Path to the video file with the extension. (Required)

Example: C:/Users/gurrutia/Videos/video.mp4
--start-time Specify the video extraction start time, in seconds or as a timestamp in the format HH:MM:SS, H:MM:SS, MM:SS or M:SS.

Example: --start-time 1:30 or --start-time 90

Default: the start of the video.
--stop-time Specify the video extraction stop time, in seconds or as a timestamp in the format HH:MM:SS, H:MM:SS, MM:SS or M:SS.

Example: --stop-time 2:00 or --stop-time 120

Default: the end of the video.
--fps Number of frames per second in the video file, overrides the video metadata frames per second. Use this option sparingly and only when the video metadata fps is incorrectly detected.

Example: --fps 30

Default: the video metadata fps.
--dimensions Specify the media output dimensions as space-separated values.

Example: --dimensions 1920 1080

Default: the native video dimensions.
--resize Resize the media output by a factor of n.

Example: --resize 1.5 to increase the media output size by 50%

Default: 1.0, no resize.
--rotate Rotate the media output by 90, 180, or 270 degrees.

Valid rotate values: 0, 90, 180, 270

Example: --rotate 270 to rotate the media counter-clockwise by 90 degrees.

Default: 0, no rotation.
--output-dir Directory to save the media output to.

Example: --output-dir C:/Users/gurrutia/Videos/custom_folder

Default for images: same/directory/as/video/video_frames
Default for gif: same/directory/as/video.
--output-filename Specify the file name of the media output.

Example for images: --output-filname my_images, which will name all the images as my_images_*.jpg where * is the frame number.
Example for gif: --output-filename my.gif

Default for images: video_filename_*.jpg
Default for gif: video_filename.gif
--quiet Disable extraction details in terminal.

Example: --quiet to disable extraction details from being printed.

Default: False
--emoji Enable emoji's in terminal. Added by special request 👍.

Example: --emoji to enable emoji's.

Default: False

Options / Images

Argument                   Description
---capture-rate Capture every nth video frame.

Example: --capture-rate 30 to every 30th frame.

Default: 1, every frame.
--image-format Specify the image format to save the frames as.

Valid image formats: bmp, dib, jpeg, jpg, png, tiff, tif, webp

Example: --image-format png or --image-format .png

Default: jpg

Options / GIF

Argument                   Description
--speed Speed of the GIF animation.

Example: --speed 0.5 to create a GIF at half the video speed.

Default: 1.0, same speed as the video.

Used by

  • Grand St. Settlement (non-profit) filmmaking instructors to gather film stills that aid in constructing lesson plans for their youth workshops. Download workshop example here.

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

videoxt-0.1.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

videoxt-0.1.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file videoxt-0.1.1.tar.gz.

File metadata

  • Download URL: videoxt-0.1.1.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for videoxt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e8f76c8ac2127ba39c075f84285a2512a706aaa6d2466cd8c6805203b3b9a606
MD5 4fdd53be61ad5805bba6c7604105d97e
BLAKE2b-256 86a0691eb2f48a2bf376a3dfc31626efb6accb5333c47c451bf3812efcbc98de

See more details on using hashes here.

Provenance

File details

Details for the file videoxt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: videoxt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for videoxt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd2bf3900f2e1a6b954ade52861857b79da0455b3ab1dddec0984eb70e3acc1b
MD5 cbb720c1400ab30e8166e137fd0e456b
BLAKE2b-256 a2c8fcf9ef7ce755812c254e903320a7e3229ce215045f929d65839c745e6590

See more details on using hashes here.

Provenance

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