⬆️ ⬇️

How we did Peat TV

How the technical implementation of the Internet TV channel was created, what tasks the team faced and what tools and services helped us in the development process you can find out in this article.





Peat TV is a cultural and anthropological Internet project founded by Kirill Kislyakov. This is an author's project, respectively, with a pronounced subjective approach both to the selection of topics, the choice of characters, and to the presentation of the material. The channel covers a wide range of issues of art and education, literature and poetry, science and technology, music and history, non-political news and interesting facts in the format of short video.

Footage Peat TV come out with the accumulation of material. Each issue is a short video with a duration of 3 to 15 minutes, made in the style of video art.



â–Ś Concept



Some issues are monologues or dialogues of people, sometimes they are addressed to the viewer, and sometimes they communicate with each other, not paying attention to what they are being filmed. There are issues made in the format of documentary programs, and there are issues in the format of interviews. Sometimes the interviewer may be in the frame, like the interviewee, and sometimes it may not be visible and the viewer hears only the voice asking questions. All issues are divided by the program heading with a specific theme.

')

At the moment on the channel there are such sections as:





From the point of view of anthropology, the most interesting issues are Portrait and Brothers in the trash . So, in the first category of issues a person says what he wants to say, and in the second - what he can say. Both formats often allow for 5 minutes to tell a person more than he himself assumes.



The audience of the channel is people who are interested not only and not so much in cultural issues as an opportunity to follow the train of thought divorced from the context and time, relevant in any era and anywhere in the world, therefore, the video on the Peat is not an operational chronicle. what happens in cultural life, and an overview of what suddenly comes to the attention of the team of authors or invited characters. Sometimes, the plots can be from the past or from the future, this does not affect their relevance.



â–Ś Implementation



When we started developing the IT part of the project, we faced several tasks:







Today, as a result of trial and experiment, we have come to the most optimal, in our opinion, project architecture (the full-size image can be viewed here ):







Let's see how it all works and why we did just that.



â–Ś Player



The project has developed its own HTML5 / JS player that supports the main video formats:



For each format we create 4 video options with different resolutions:



According to statistics, most of the views accounted for video files in mp4 format with a resolution of HD and SD .



â–Ś Video preparation and publication



Over releases the team consists of several editors. The editors are located in different cities and work remotely. Each of them has FTP access to a media encoding server. Together with the original (raw) video file, the editor also uploads a text file to the server with a description of the release and a poster for the video displayed on the main page. After the video is uploaded to the server via FTP, the automatic video encoding process starts:



  1. On the encoding server, with the help of a specially developed program, the video is converted into various formats and resolutions.

  2. After the video has been encoded, the program starts uploading the video to the Rackspace CDN endpoint, from which files later get into the local CDN server.

  3. After the download is complete, a request is sent to the web application to add a new release.

  4. When a web application receives a call, the video information is added to the database and released to the site.





In the process of creating a program for converting video, it was decided to allocate the code responsible for converting into a separate library. The library is called X.Media.Encoding and can be freely downloaded from the nuget repository .



â–Ś Transition to the clouds



When we were just starting development, the site was deployed on a regular dedicated server, and at first, that was enough. However, over time, it became clear that a regular server has several drawbacks:

  1. first of all, it concerned video files - the download speed of releases left much to be desired
  2. The second problem was connected with the fact that the resource essentially works in the peak load mode - the activity of the visitors is maximum when a new release is released, and minimal between releases. Thus, you need to either acquire a more powerful server, whose resources will be idle most of the time, or switch to a platform that supports automatic scaling.




Initially, to solve problems with the speed of loading issues, we decided to use the services of CDN.UA, which provides content delivery services in Ukraine. By the way, the guys there work very professional and for our project they even made some specific settings on their servers, which allowed us to upload videos to our own HTML-5 player, rather than using the flash player that they offered initially. At this stage, for Ukrainian viewers, the problems with viewing disappeared almost completely. But for those who watched issues from Georgia, Israel and other countries, the delays didn’t go away. Therefore, the next step was to transfer the video to the international content delivery network. The choice fell on the Rackspace CDN, which in turn uses the world's largest network Akamai :





In connection with the move to a new platform, we had to slightly update the video download program. So if we uploaded video via FTP to CDN.UA, we now use to upload it to Rackspace

OpenStack SDK:
using net.openstack.Core.Domain; using net.openstack.Providers.Rackspace; using NLog; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using X.Media.Encoding; .... public bool Upload(string path) { const string container = "Video"; const string region = "DFW"; try { var cloudIdentity = new CloudIdentity { Username = _settings.StorageUserName, Password = _settings.StoragePassword }; var contentType = ContentTypeManager.GetContentType(Path.GetExtension(path)); var name = Path.GetFileName(path); _logger.Info(String.Format("Upload: {0} \t with content type: [{1}]", Path.GetFileName(path), contentType)); using (var stream = File.OpenRead(path)) { var cloudFilesProvider = new CloudFilesProvider(cloudIdentity, region, null, null); cloudFilesProvider.CreateObject(container, stream, name, contentType); _logger.Info(String.Format("Uploaded: {0}", path)); } } catch (Exception ex) { _logger.WarnException(String.Format("Error while uploading: {0}", path), ex); return false; } return true; } 






After the video content was transferred to the CDN, it was the turn of the site. Now the load on the web server is quite small compared to the loads that were originally when distributing video, but considering that the influx of visitors was uneven as before, it was decided to migrate the site to the cloud platform. Now the site is deployed in Microsoft Azure in the service WebSites. The site is supported by load balancing and automatic scaling of resources in case of a sudden increase in the number of visitors.



From an interesting point, I would like to note that the site has two display modes - night and day, which automatically changes, depending on the time of day.



â–Ś Project development and support process



Although the project development team is small (initially there were 4 people, now only 2 people are actively involved in writing the code), it was decided to optimize the process of developing and publishing the project as much as possible. We store the source code of the project in a Bitbucket private repository. The project itself, as mentioned earlier, is hosted by the Azure Website. And what makes us very happy, this service allows you to configure the process of automatic deployment of the project from GitHub and Bitbucket (in fact, the number of sources is much more, and even the publication from Dropbox is supported). In azure, we have two websites:









When a new commit hits the corresponding brunch, an automatic build of the project takes place, and in case of its successful completion, a new version of the site is published. In case, if for some reason the project was not successfully assembled in a cloudy environment, we can always see the reason for this by reviewing the deployment logs:





However, for all the time, this opportunity was useful to us only once, during the initial deployment of the project in the cloud.



â–Ś Mobile customers



After a year after the start of the project, we realized that it would be more convenient for many viewers to watch the releases not only from the computer, but also using their smartphones. It was decided to make a mobile client. We have made three versions of mobile clients for three main mobile platforms:





The logic of mobile clients is as simple as possible. In the xml-format, they receive from the site information about releases of available programs and video releases. Also, the url of the video file located in the CDN is sent to the mobile client, from where it later downloads the video.



Also, the project has an “inner voice”. He communicates with those who installed the Peat TV mobile app on their smartphone. Sometimes users come announcements of releases, and sometimes just interesting thoughts and expressions. Works "internal voice" on the basis of Azure Mobile Services. Since, at the time of the creation of the “inner voice”, Mobile Services had only just been released, the logic was written in JavaScript. Later, the ability to write the logic of mobile services in C # was added, but since everything works well, I could rewrite this piece of code from steel.



Interestingly, at the moment, about half of the video views occur through mobile applications.



â–Ś Useful information







â–Ś Notes


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



All Articles