Skip to main content

Toolkits for read/write video

Project description

:movie_camera: video_toolkits

This repo provides functions to read/write a video and draw keypoints.

** Defult BGR **

Installation

git clone https://github.com/Celeste-cj/video_toolkits.git
cd video_toolkits
python setup.py install

How To Use

VideoReader

from video_toolkits import VideoReader, VideoReaderCV2

video_path = 'path to video'
reader = VideoReader(video_path)            # VideoReader - pyav, only support video file/stream
# reader = VideoReader(0)                   # webcam 0   VideoReaderCV2 support
for img in reader:
    pass

VideoWriter

from video_toolkits import VideoWriter

img_seqs = []
out_path = '{VIDEO_NAME}.mp4'                     # currently support .mp4/.avi
succeed = VideoWriter.imgseq2video(img_seqs, out_path, fps=30)

# generate video on the fly
frame_size = (720, 1280)
video_writer = VideoWriter.video_writer_generator(out_path, frame_size)
video_writer.send(None)
for img in img_seqs:
    video_writer.send(img)
video_writer.close()

Convert flv to mp4

from video_toolkits import flv2mp4

input_vid = "{INPUT_FOLDER}/{VID_NAME}.flv"
output_folder = "{OUTPUT_FOLDER}"                 # if output_folder == '', will use {INPUT_FOLDER}
succeed = flv2mp4(input_vid, out_folder=output_folder) 

Visualization

from video_toolkits import display, draw_sklts, put_text, draw_bbox
from video_toolkits import draw_points, draw_lines
                                                                   
img = None
kpts = []                       # default (22, 4)
text = ""
bbox = []

display(img)                       # plot image with matplotlib.pyplot
img = draw_sklts(img, kpts, color=None, sklts=None)          # draw skeletons
img = put_text(img, text)                                    # put text
img = draw_bbox(img, bbox)

img = draw_points(img, [[0, 0], [1, 1]])
img = draw_lines(img, [[0, 0]], [[1, 1]], arrowed=False)

load/dump json

from video_toolkits import load_json, dump_json

json_obj = []
file_path = ""

annts = load_json(file_path)
dump_json(json_obj, file_path)

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, use, compile this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

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

video_toolkits-0.5.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

video_toolkits-0.5.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file video_toolkits-0.5.0.tar.gz.

File metadata

  • Download URL: video_toolkits-0.5.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.61.2 importlib-metadata/3.10.0 keyring/23.1.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13

File hashes

Hashes for video_toolkits-0.5.0.tar.gz
Algorithm Hash digest
SHA256 606ca9e6c4b58709746f234f2bdfa6738a90932b43e2b93b14893912d4edcad3
MD5 aade36d4694b9bc0b8f696181e160418
BLAKE2b-256 b867f11ad55b4bf4fb4bd50d383e882bc037ea0d1b26d98407407f94b21995fb

See more details on using hashes here.

File details

Details for the file video_toolkits-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: video_toolkits-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.61.2 importlib-metadata/3.10.0 keyring/23.1.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13

File hashes

Hashes for video_toolkits-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ac24643d28576d80f58bce116f4d485f10640e9709e45b91aca2b7211e6caa1
MD5 a236327382a2734b016451826fa37bb6
BLAKE2b-256 7c6ebbe2961222f62da2743ee5e31008fa2dc5dee5eb394e6473dd15caf5c9ca

See more details on using hashes here.

Supported by

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