Flussonic Media Server documentation

Contents

Thumbnails

Video is a stream of pictures. Sometimes you need to extract these pictures and handle them separately from each other. This is called thumbnails or screenshots.

Flussonic Media Server can create thumbnails of a video stream. They allow you to:

  • show an instant preview of a live stream on a web page to know what is happening there right now,
  • take a look at the quality of a stream,
  • freeze a point in time to use the screenshot somewhere else,
  • make a fast search in the DVR archive for some fragment of video identifiable by the screenshot,
  • create a wall of screenshots to quickly look at a whole day of recording,
  • do whatever else with small static images extracted from a large video stream.

Flussonic Media Server can create thumbnails in two different ways:

  • Extracting video frames as JPEG images. This is a resource-intensive operation. Flussonic can save JPEG thumbnails in the DVR archive. Learn more on this page.

  • Creating resource-saving MP4 video thumbnails. In H.264 streams with keyframes, all compressed images are available without resource-intensive processing. Flussonic Media Server takes the first keyframe from each segment and displays it as an MP4 video consisting of one frame. Learn more in Video thumbnails section.

About JPEG thumbnails

Flussonic Media Server does a rather CPU-intensive job: it takes the first keyframe of each segment, decodes it to raw video, and encodes back to a JPEG image. This seems rather simple, but when you have, say, 300 streams, this process can take a lot of CPU time.

Flussonic allows some optimization here – by changing a segment's duration you can change the total number of JPEG thumbnails. The fact that Flussonic Media Server takes only the first keyframe of a segment means that if you configure the segment duration of 3 seconds, you'll have 20 JPEGs per minute. If you configure the segment duration to be 6 seconds, you'll have 10 JPEGs per minute. If you take a stream from an IP camera, you may have 60 keyframes per minute, but Flussonic Media Server will create a smaller number of JPEGs.

Note. If you enable DVR on a stream, all of the generated JPEGs will be written to the disk.

It is possible to optimize the CPU usage by accessing thumbnails by their URL. Usually it is suitable for IP cameras because IP camera maintain fresh JPEG screenshot for the currently shown video. In this case Flussonic Media Server will download a JPEG image each time video segment starts.

Configuring JPEG thumbnail generation

To create JPEG thumbnails, Flussonic Media Server uses a built-in package (starting from v19.05).

Add the thumbnails option to the stream settings:

stream ort {
  url udp://239.255.0.100:1234;
  thumbnails;
}

This will start the flussonic-thumbnailer process. It may be rather resource-hungry - unfortunately, this is the nature of video and image compression.

All the settings for JPEG thumbnails can be specified through the administrator's panel in a stream's settings on the Output tab (Media > select a stream > Output).

thumbnails of a video stream

Configuring JPEG thumbnails generation from URLs

To reduce CPU usage on thumbnail generation, you can specify the URL where Flussonic Media Server can get thumbnails. Many cameras have a special URL for screenshots:

stream cam0 {
  url rtsp://10.0.4.3:554/h264;
  thumbnails url=http://10.0.4.3/cgi-bin/snapshot.cgi
}

You can try to find the screenshot URL in your camera's documentation, or look for that information on the web.

Getting JPEGs from live streams

After you have enabled thumbnails in Flussonic Media Server, you need to access them.

The URL for getting thumbnails is as follows:

http://flussonic:8080/ort/preview.jpg — a stream's last screenshot.

http://flussonic:8080/ort/preview.mjpeg — an MJPEG screenshot stream.

We strongly recommend that you never use the MJPEG stream because it is an uncontrollable way of streaming video with a very high bitrate. You can end up with an MJPEG stream with 50% of the original bitrate, streaming at 0.1fps. But if you still need it, you can use it.

Getting JPEGs from DVR by GMT time

Screenshots are automatically saved to the archive if DVR is turned on for the stream. They can be obtained using the HTTP API.

The best way (in terms of resources) of getting JPEG screenshots is to specify an approximate GMT time as part of the URL. Flussonic will return the URL corresponding to the nearest keyframe (an actual screenshot).

curl -v 'http://192.168.2.3:8080/ort/2018/05/02/06/59/38.jpg'
...
< HTTP/1.1 302 Found
< Location: /ort/2018/05/02/07/00/40.jpg

You then use this URL to access the screenshot.

Learn more in the article about the DVR API, in the section Requesting JPEG screenshots.

Getting JPEGs from DVR by UTC time

Important! This method is resource-intensive, we don't recommend using it. A better way is to use an approximate GMT time. Learn more in DVR API, section Requesting JPEG screenshots.

First, you need to identify a time range for which you want to get DVR. For example, right now it is 2017 April 21, 13:10 GMT, so it is 1492780200 UTC. If you want to get thumbnails for the last hour, you need to request the following URL:

curl 'http://flussonic:8080/clock/recording_status.json?from=1492776600&to=1492780200&request=brief_thumbnails'

By default, Flussonic does not include the list of timestamps in the response. To get them, we need to add request=brief_thumbnails to the query string.

The response will look like this:

[{"stream":"clock","ranges":[{"duration":3642,"from":1492776599}],"brief_thumbnails":[1492776599,1492776605,
1492776617,1492776629,1492776641,1492776653,1492776665,1492776677,1492776689,1492776701,1492776713,1492776725,
....]}]

Here you get a very long list of timestamps that you need to convert to paths to screenshots. For example, the timestamp 1492776605 will be converted to http://flussonic:8080/clock/2017/04/21/12/10/05.jpg.

You will only get a list of timestamps, you will need to get the thumbnails themselves by requesting them individually.

On-demand JPEG generation

Sometimes it is very expensive to store all JPEG images on the disk, so you can ask Flussonic Media Server to generate JPEGs on demand. In this case, you don't need to enable thumbnail generation in the stream settings.

Request a URL with a certain time:

http://flussonic:8080/clock/2017/04/21/12/10/05-preview.jpg

and Flussonic Media Server will take a segment, take the first keyframe and generate a JPEG image from it.

This method might lead to unpredictable CPU usage, so it is not recommended.

With the JPEG thumbnailer enabled, you will have smooth and moderate CPU usage, without spikes in load. With on-demand JPEG generation, you may have low CPU usage overall, but during prime time you may get spikes, and your server may become unstable.