📜 ⬆️ ⬇️

Sochi.Camera: how a regional provider raised a video broadcast site with a visit to 500,000 people per month

Sochi.Kamera is a site that broadcasts streams from over 300 webcams installed in Sochi and its surroundings. The site and the entire service is non-commercial, created and maintained at its own expense by a local Internet provider , Business Communications , for almost 10 years.

Creating the project, we tried many models of external video cameras (fixed, rotary, mobile), modifying and adapting them to our needs. We tried several server solutions, bringing them to mind with the developers. They themselves wrote mobile apps for Android and iOS. The project was very difficult, but we gradually worked out every element of the system to a state of high efficiency. The development continues, but now there is something to tell.



')
This is the first review article. In it, we will talk about how this project was launched and developed, what the technical solution consists of, how to install a webcam in a lion's cage (spoiler - agree with a lion), and why people from all over Russia look at Sochi through our website. If this post seems interesting, we can talk about the project in more detail.

On the technical side, the Sochi project. The camera is divided into three parts:

1) take a picture;

2) transfer it to the video broadcast server;

3) show stream on the site.

And all this is live.

Let's go in sequence.

Cameras.

The cameras on the network are different. For almost 10 years, many models have tried, some of the tested have been on the network. The cameras are unified, standard, the protocol we use - RTSP, is supported by almost every typical model. The cost of cameras has fallen dramatically since 2008, and the quality of the image has greatly increased. Then a simple static camera cost about 40 thousand rubles, today for the same money you can buy a full HD rotatable with the ability to “patrol the points”, put it on the tower, and it will give a dynamic image. The usual static camera today costs only 5-7 thousand (do not forget about discounts).

The quality of the image from modern cameras is practically television, not the image in the webcam to which we are all used to - a small dark square with a frequency of 1 frame per second.



Recently, we stopped at a pair of models: Hikvision
and SNR

They are quiet, with a good night shooting effect due to the modern matrix.
Each camera provides two streams: Full HD (4-6 Mbit / s) and SD (512 Kbit / s), the site has HD / SD switches. This is done so that users with non-fast Internet can enable gentle SD mode. It is also used in our mobile applications, because on a small screen the difference between Full HD and SD is almost imperceptible. Of course, there are many cameras on the market with a resolution higher than Full HD, for example 4Mp. We tried to use them, but practice has shown the unsuitability of such permissions for online broadcasts on the Internet. First of all, not every Internet channel will transmit this without loss, and not every client device will be able to safely display this stream. As a result, the broadcast can go with jerks and artifacts, after all, the Internet is not a local area network. Well, to top it off, it turned out that the overwhelming majority of users watch cameras in windowed, not fullscreen mode, that is, at the output, the difference in bitrates and resolutions is not visible to them at all. As a result, even the 4-megapixel camera, we switched to 2MP 1920x1080 mode. As for the software, in the cameras themselves the standard factory firmware, as a rule, we do not change anything there.

Now in the general access about 318 cameras. Recording is carried out on ~ 115-120 cameras, which relate to the traffic situation. Record is needed because of the need to parse the accident, which happens quite often. We do not record cameras that look at nature, at sunsets, at mountains, and so on. Record server is an expensive resource, in vain we try not to spend it.

As for privacy, the cameras are set so that faces are not read. We put panoramic cameras so that the overall scene could be seen, for example, a little yellow machine beats a blue one, a traffic light burns there and such, nothing more. Nevertheless, the traffic police and the police turn frequently, every week and even, sometimes, every day: they ask to see the records.





Installation and maintenance of cameras do through contractors. At the same time, if there are problems, then from following the instructions too precisely. We have to do more than the instructions, take into account, for example, pressure and temperature drops. In the process, there appeared some tricks, for example, the connection of an Ethernet cable inside the camera body, and not in the junction box or the standard connecting “barrel”. Isolating webcams is much more serious compared to regular means, so that they work quietly for several years without moisture getting inside.

We pay nothing for camera placement, this is a crucial moment, since our project is non-commercial - the image is in open access, we do not earn anything from it. So, if someone does not want to post for free, we don’t post there. There are many beautiful places in the city and many who want to install our cameras. Building owners quite willingly give permission for installation, simply because we are on camera giving advertising to these establishments for free. Attendance is high enough for a regional site, more than 500,000 people per month, we compete with large news local portals. So the problem is more likely to feed the channel to an interesting place, than to actually put the camera.



In general, after we have found the optimal solutions for different installation situations, the camera is about 10% of what the Sochi.Camera project consists of. The main thing is not in them, but rather in the video transmission channels and software for broadcasting on the site.

Video feeds.

"Business Communication" is an Internet provider, a telecom operator, we have our own network in the city, a large number of nodes. So we do not need to rent any channels for video transmission, neither the “last mile”, nor the main channels, nor Internet access - we already have everything.

Consumers of our services are organizations and individuals. If you look at the profile of their Internet traffic, then there is mostly incoming traffic, as a standard user, as a rule, consumes (downloads) traffic and generates very little. On average, the ratio of incoming to subscriber traffic to outgoing is 10 to 1. Channels that we rent / buy to provide Internet services from long-distance operators are synchronous, and the speed of incoming and outgoing is the same. So the reverse (outgoing channel), as a rule, with Internet providers like us is half empty. This situation is typical for most operators working with people. In data centers hosting providers and social networks, the situation is opposite, there is mainly outgoing traffic, but this is not our case.

As a result, it turns out that collecting video from cameras and broadcasting it to the Internet costs us almost nothing. In this case, the channels are needed serious, because the static camera gives about 4 Mbit / s, and the rotary - up to 10 Mbit / s at the time of changing the angle.



Multiply this by the number of simultaneous consumers, which is 2,000 or more during the daytime. Suppose that a third-party organization, not a telecom operator, wants to create a project like Sochi. Camera. In this case, all the necessary resources will need to be rented from telecommunications operators, and at current prices it will cost you a pretty penny. But if you are a telecom operator, then the flag is in your hands.

But sometimes there are difficulties with the organization of communication channels. This is due to the fact that where communication channels are present, that is, in the center of the city, there is almost nothing to watch. And where it is interesting, there are no communication channels and they have to somehow organize, allocate equipment, supplies, and human resources. For example, we are now organizing a connection to a raccoon hole in the forest.

Software for video broadcasting.

We started our project in 2008-2009, when there were no samples that could just be taken and copied. Then there were a lot of webcam aggregators who searched for them wherever possible, and presented them in one directory as if they were their own. But complex, ready-made solutions were not. To receive such a large number of cameras and distribute to many people on different devices, you need reliable and stable software. So we started to do everything ourselves, it was several years of development from scratch, starting from design, layout and ending with software architecture. No one copied, tried five versions of the engine - from primitive LinuxDVR on mjpeg, to Red 5, ffmpeg + nginx, Wowza. From the latter, by the way, they refused not for technical reasons, but because of changes in licensing conditions during the transition to the new version and the lack of a lifetime-license in the new policy of the American developer. That is, they wanted to receive money on a monthly basis, based on the actual load. And the fact that the project was non-commercial didn't bother anyone there.

In the process of developing and developing the service, we went to the Erlivideo company, which is developing the Flussonic media server. The project team from Moscow, and it was easy to find a common language with it, generally proved itself well in solving non-trivial tasks. It is impossible to say that everything was always smooth, both shoals and rakes came out. BUT. When you see a developer’s desire to improve your product, listen to and take into account customer’s remarks, and see the real results of this interaction after the next update, it’s worth a lot.



Flussonic Media Server is a video streaming server platform. With its help, you can organize the capture of any video stream, recording video in the archive and distribution to customers using various protocols and on any device, both in real time and on request. Playback is available as an endless tape, which can be viewed from any moment. Distribution can go through the protocols RTMP, RTSP, HLS, HDS, HTTP MPEG-TS, DASH and WebRTC. Also, Flussonic can transcode video by changing the codec and video parameters. In the list of supported codecs - H.264, H.265, MPEG-2, AAC, AC3, MP3, VP6, Speex and G711a / u. The platform is able to collect clusters from servers, capture more than 1600 threads and distribute hundreds of thousands of simultaneous connections. To control and monitor activity and load, you can use both embedded tools and a web interface, as well as HTTP API.

From cameras we collect streams in standard RTSP. Until recently, DASH for flash players, UDP Multicast for the internal network, and HLS for mobile applications were distributed. The last few years, the HTML5 revolution and the “funeral” of Adobe Flash were periodically announced, so we had to use a whole design that “feeds” the right type of player and stream depending on the client’s browser and OS. Despite the hype around HTML5, many popular browsers worked out the video tag very clumsily when it came to live streaming. In contrast, let's say, from playing the pre-recorded video, which has been fairly stable since the announcement of HTML5.

Now we can say that the “browser turbulence” has ended and we switched to native html5 broadcasting in browsers, completely abandoning the Flash plug-in. Thus, “in the hand” we now have only HLS and Multicast.

For our subscribers using IPTV via multicast, we made the broadcast of these cameras to a television network, that is, they see all the webcams as separate television channels on their televisions. Webcams in IPTV are sorted thematically and complement the standard set of TV channels offered by our customers.

Our other feature is the functionality of the embedded player, like on YouTube or Vimeo. From our service we give videos to some very well-known sites - these are both Krasnaya Polyana resorts and hotels. At the same time, they do not raise streaming on their side; they simply need the insert code. The embedded player can be branded as well as not have any identifying marks, which allows our partners to independently design their pages in the desired style. Examples:

One

Two

Three

Another of our chips is mobile webcams based on cell phones. We called them "Fluff", from the push video streaming method. This is a custom Android application distributed as an APK file. In the Market it is not and never will be. The idea is simple: the mobile phone has everything you need for video broadcasting: a camera, GPS positioning, a data transmission channel. We have made an application that processes the video and sends it directly to Sochi.Camera. Optionally transmitted sound and coordinates. The creation of “black holes” is envisaged, appearing in which “Fluff” suspends the broadcast. Analogs of the “Gun” are well known, for example, this is the “Periscope” for Instagram. At one time we thought to distribute this application among bloggers, but we abandoned this idea for a number of reasons. Now “Guns” work in several city buses, and closer to the season, broadcasting from excursion ships will resume their work.





The very same Sochi. The camera is made entirely in Javascript. Server - on Node.js, browser part - Angular.js

Mobile apps for Android, iOS, and Windows Phone are written using standard developer tools. It is also worth adding that there is an application for Windows Desktop, some clients prefer it to the browser, because it works faster, there is no advertising and, in general, there is minimalistic functionality without a “body kit” in the form of chats and others.
Interestingly, over the past time, ready-made complex solutions "turnkey" did not appear. Existing ready-made video systems are intended for completely different purposes, mainly for security video surveillance. There is a video wall, recording, viewing, rewinding, and so on, but they are sharpened for security surveillance, and not for the work of several thousand people at the same time. This is generally a different approach, a different architecture.

On this I would like to finish the review article. As we said above, many elements of the system can be described in more detail, they are worth it. For example, about the tricks of installing video cameras on the street in conditions of high humidity and high temperature differences, a way to organize mobile cameras on buses and motor ships or in more detail about applications for smartphones and their server part, or the choice of software for video streaming on the site. We can also tell you something about the costs of developing and maintaining such a project. Initial injections for development in the first few years, for example, amounted to about 4,000,000 rubles. But this is not the final figure.

You can ask yourself what part of the project you are interested in. We are waiting for your questions.

Source: https://habr.com/ru/post/411037/


All Articles