Skip to main content

Processing Video Files

Process a Single Video#

To run Stream on a video file (e.g. mp4), specify the video filename.

  1. Make sure that the video file is stored within the Stream folder.
  2. For example, with the Stream directory c:\stream and the file c:\stream\Videos\my_video.mp4
  3. Edit url parameter in configurations file:
    url = /user-data/Videos/my_video.mp4
  4. After editing, start or restart the container

If the configurations file is edited, the container needs to be restarted.

File Upload API#

If you need to check a variety of video files, so that you don't have to restart the container, you can use the stream as webservice.

  1. Edit url parameter in configurations file:
    url = file-upload
  2. Run the container with -p 8081:80. For example:
docker run --restart="unless-stopped" -t --name stream -p 8081:80 -v c:\users\kyt\documents\stream:/user-data -e LICENSE_KEY=XXXXX -e TOKEN=YYYYY platerecognizer/alpr-stream
  1. Run the following command
curl -F "upload=@/path/to/car.avi" http://localhost:8081

For a Python example, see this File Upload script.

Detection Zones#

The endpoint accepts an optional mask_id parameter. It can be used to override the detection zone mask. By default, Stream looks for a detection zone named camera_id. When mask_id is present, Stream looks for a detection zone named mask_id.

Here's an example, in config.ini I have a camera-1 with url = file-upload. By default, the detection zone camera-1 will be used. If I want to use camera-2 instead, I do: curl -F "upload=@/path/to/car.avi" -F mask_id=camera-2 http://localhost:8081.

Before starting Stream, your Stream folder should have zone-camera-2.png in it. That file can be created and downloaded from Detection Zones.

Process an Entire Folder of Videos#

The API above can be used to process all the videos in a folder. This Python script takes as input a folder and processes all the files in it. Windows users can also use this executable.

 python -f /path/to/folder -s http://localhost:8081