Flussonic Media Server documentation

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 make thumbnails of a video stream. They allows 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 you want with small static images extracted from a large video stream.

Flussonic Media Server can create thumbnails in two fundamentally different ways:

  • Extracting video frames as JPEG images. It can save them in the DVR archive. Read about it on this page.
  • Creating MP4 video thumbnails (a cool new feature):

    In H.264 streams with keyframes, compressed images are already available. Flussonic Media Server takes the first keyframe from each segment and displays it as a video consisting of one frame. Read more in Video thumbnails.

About JPEG thumbnails Anchor Anchor x2

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. Looks rather simple, but when you have 300 streams it takes a lot of CPU time.

Flussonic allows some optimization here – by changing a segment 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 have 20 JPEGs per minute. If you configure it 6 seconds, you 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. When you enable DVR on a stream, all these JPEGs are written on 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 thumbnails generation Anchor Anchor x2

Flussonic Media Server can make JPEG from video by using the package flussonic-ffmpeg that you will need to install like below:

apt-get -y install flussonic-ffmpeg
/etc/init.d/flussonic restart

Then add the thumbnails option to the stream settings:

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

This will start the additional process flussonic-thumbnailer, and you can see from the server console that it can be rather hungry for resources. Sorry, but this is the nature of video and image compression.

All settings can be specified through the administrator's panel in a stream's settings on the Process tab.

thumbnails of a video stream

Configuring JPEG thumbnails generation from URLs Anchor Anchor x2

To reduce CPU usage on thumbnail generating, 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 URL for screenshots in documentation for your camera model, or you will need to look in the internet for this.

Getting JPEGs from live streams Anchor Anchor x2

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 MJPEG because it is an uncontrollable way of streaming video with a very high bitrate. You can get up to 50% of original bitrate for video with 0.1fps. But if you still need it, you can use it.

Getting JPEGs from DVR by GMT time Anchor Anchor x2

Screenshots are automatically saved to the archive if DVR is turned on for the stream. They can be obtained via 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 DVR API, section Requesting JPEG screenshots.

Getting JPEGs from DVR by UTC time Anchor Anchor x2

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 added request=brief_thumbnails to the query string.

The response can be 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.

So first you get a list of timestamps and then you get thumbnails by calculated URLs.

Ondemand JPEG generation Anchor Anchor x2

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 basically not recommended.

Unpredictable here means that it is really hard to predict. With enabled JPEG thumbnailer you have smooth and moderate CPU usage, but not more. With ondemand JPEG you may have low CPU usage, but during prime time you can get spike and your server may become unstable.