9. Examples

In this document you’ll find some of the many ways you can utilize video-pipeline’s infrastructure. This document assumes you’ve gone through Getting Started.

9.1. Streaming with a Filter

Video streaming is relatively straight forward but sometimes I need to “filter” (aka pre-process) my image before streaming it.

The following example utilizes the built-in gray-scale filter to apply to every image frame in the hosted video stream.

  1. Run the following command to start streaming video from your webcam through a gray-scale filter:

    video-pipeline --host 0.0.0.0 --port 8000 --source os --filter gray-scale
    
  2. Use vlc to view the video stream. Replacing HOSTNAME with your hostname:

    vlc "tcp/mjpeg://@HOSTNAME:8000/"
    

9.2. Custom Filters

While it’s nice to use the built-in filters of video-pipeline sometimes you need the ability to customize the filter’s image manipulation logic.

The following creates a always_coffee.py filter that will be applied to every image frame in the hosted video stream.

  1. Create a python script called always_coffee.py with the following:

    Note: The following uses scikit-image coffee .

    from video_pipeline.frame_filter import FrameFilter
    import skimage
    
    class AlwaysCoffeeFrameFilter(FrameFilter):
        def process_frame(self, frame):
            return skimage.data.coffee()
    
  2. In the same directory run the following command to start streaming video from your webcam through your custom filter by importing the script and specifying the filter:

    video-pipeline start --source os --filter always_coffee.py --transport tcp-server transport-host=0.0.0.0 transport-port=8000
    
  3. Use vlc to view the video stream. Replacing HOSTNAME with your hostname:

    vlc "tcp/mjpeg://@HOSTNAME:8000/"