Skip to content

Visillect/videoreader

Repository files navigation

VideoReader

c++/c/python wrapper for

Installation

FFmpeg in Debian based distributions

apt install libavcodec-dev libavdevice-dev libavformat-dev libswscale-dev.

Set FFMPEG_DIR environment variable when setting custom ffmpeg directory. See Findffmpeg.cmake

uri = 'test/big_buck_bunny_480p_1mb.mp4'
uri = 'https://example.com/hls/stream.m3u8'

See all supported protocols by running

ffmpeg -protocols

Daheng cameras

Download galaxy SDK. Then set GALAXY_DIR environment variable to the SDK directory. See Findgalaxy.cmake for exact logic of finding galaxy SDK.

uri = 'galaxy://192.168.0.13'

Basler cameras

Download pylon SDK. Then set PYLON_DIR environment variable to the SDK directory. See Findpylon.cmake for exact logic of finding pylon SDK.

uri = 'pylon://'

iDatum cameras (contrastech)

Download iDatum SDK. Then set IDATUM_DIR environment variable to the SDK directory. See Findidatum.cmake for exact logic of finding iDatum SDK.

uri = 'idatum://192.168.0.13'
uri = 'idatum://usb_name'

Installation using pip

pip install -v git+https://github.com/Visillect/videoreader

When the SDKs aren't in default locations, the user can specify directories explicitly: FFMPEG_DIR=... GALAXY_DIR=... PYLON_DIR=... IDATUM_DIR=... pip install git+https://github.com/Visillect/videoreader

Examples:

VideoReader with numpy backend

from videoreader.numpy import VideoReaderNumpy as VideoReader

uri = 'test/big_buck_bunny_480p_1mb.mp4'
reader = VideoReader(uri, extras=["pkt_dts", "pts"])
for image, number, timestamp, extras in reader:
    print(f"{image.shape} {image.dtype} {number}, {timestamp:g}, {extras}")

VideoWriter with numpy backend

from videoreader.numpy import VideoWriterNumpy as VideoWriter

writer = VideoWriter(
    'out.mkv', 640, 480, arguments=[], log_callback=print, realtime=True
)

for image, number, timestamp, extras in reader:
    ret = writer.push(image, timestamp)
    if not ret:
        print(f"skipping frame {number}!")

About

c++ ffmpeg wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors