Instagram proposes two video encodings that can reduce the length by 94%

Publisher:Radiant777Latest update time:2022-12-14 Source: elecfansKeywords:Instagram Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Seeing that the growth of user videos would exceed the upper limit of server computing power, and without additional servers to support it and without causing a big impact on user experience, Instagram engineers found two parts of the encoding process that were repeatedly calculated and combined them into one, thus saving considerable computing power. How did they do it?

23eb744e-768c-11ed-8abf-dac502259ad0.jpg

In their continued pursuit of efficiency, Instagram engineers have developed a new video processing method that can reduce the time required for basic video encoding by 94%.


With this approach, Meta's video infrastructure can absorb the increased load without adding more equipment.


The freed-up resources allow more users to watch high-definition encoded streams, providing a clearer and smoother video experience. This is especially beneficial for users in countries with poor network connections.


Instagram’s user base continues to grow, with more than 2 billion monthly active users. The rapid expansion of our audience also requires our server clusters to provide better performance experience. At the beginning of 2021, our forecast indicated that within the next 12 months, our existing infrastructure would no longer be sufficient to handle the video upload load of all users. However, with the constant pursuit of efficiency, Instagram engineers developed a new video processing method that can absorb more load without adding more equipment to the video infrastructure.


Instagram creates multiple encoded versions of videos uploaded by users, each with its own characteristics. By using one type of video encoding to assist in generating another type, the encoding computing resources used by videos with fewer views can be reduced by 94%. The freed-up resources can be used to generate more high-definition encoded video streams, allowing more users to get a clearer and smoother playback experience.


How Instagram allocates computing resources for video

For every video uploaded to Instagram, we generate two video encodings:

Basic encoding, which is compatible with all Instagram clients. It has a lower compression rate and can be decoded and played smoothly on older devices.


Advanced encoding uses newer compression technology to improve playback quality.

The problem is that basic video encoding takes up more than 80% of our computing resources. If we continue along this path, the basic encoding function will exhaust all of Instagram's resources within a year. By that time, users will have to wait longer for their videos to be published after uploading them, or even fail to publish them normally. In contrast, our advanced encoding only accounts for 15% of the total viewing time. It is expected that after all the computing power is spent on basic encoding, there will be no resources available for advanced video encoding.

Remove redundant workloads

For the basic video encoding part, Instagram specifically divides it into two types. For each uploaded video, we first generate the most basic adaptive bitrate (ABR) version, which is the lowest functional type. In this way, customers can choose the version that best suits the current connection speed to prevent the screen from being stuck due to bandwidth fluctuations - this is what the so-called adaptive bitrate means.

The other is the rarely used progressive encoding (another minimum functionality type), which we will also continue to produce to ensure compatibility with older versions of the Instagram app that don’t support ABR.

Traditionally, the original files we upload from the client to the backend correspond to two versions, ABR and progressive encoding. This process takes up computing resources - as shown in the following terminal command, it takes 86.17 seconds of CPU time to transcode a 23-second video to 720p.

$ TIme ffmpeg -i input.mp4 -vf scale=-1:720 -c:v libx264 output.mp4
86.17s user 1.32s system 964% cpu 9.069 total

We noticed that both sets of encodes had similar settings - using the same codec, but with slightly different encoding profiles and presets. We realized that we could replace the base ABR encodes with progressively encoded video frames, repackaging them into an ABR-capable file structure. This would eliminate the cost of generating the base ABR encodes. The following terminal command shows that it only takes 0.36 seconds to generate the manifest file and repack the video frames into an ABR-capable file structure for the same input video:

$ TIme MP4Box -add input.mp4 -dash 2000 -profile dashavc264:onDemand -out manifest.mpd 
video_output.mp4
0.36s user 2.22s system 95% cpu 2.690 total

This method saves the computing power of advanced encoding, but sacrifices the compression efficiency of our basic ABR encoding. However, we believe that increasing the generation rate of advanced encoding should be a good thing for Instagram users.

24112acc-768c-11ed-8abf-dac502259ad0.png

Building a framework to test our theory

We had to validate this theory before we put it into production. Simply comparing the percentage of basic ABR encoding before and after the change was not enough to draw meaningful conclusions. We also needed to measure the net value of the increase in the percentage of advanced encoding. As you can see in the figure below, users actually watched more advanced encoding videos after freeing up computing power from basic ABR. This should be enough to offset the compression efficiency sacrificed by the new basic ABR algorithm we invented.

2443ec96-768c-11ed-8abf-dac502259ad0.jpg

To further quantify this, we also built a test framework where the test and control pools replicated a small portion of user traffic. We saved the video encodes in each pool to different namespaces and later made them part of the video control directory or test directory. This way, when delivering, people can only see the encodes from one of the directories, helping us measure whether the new encoding scheme is better.

24600494-768c-11ed-8abf-dac502259ad0.png

In this testing, we demonstrated that while the compression efficiency of basic ABR encoding in our test pool decreased, the longer viewing time of advanced encoding videos more than offset this loss.


Keywords:Instagram Reference address:Instagram proposes two video encodings that can reduce the length by 94%

Previous article:What are the emulators needed for voice chips?
Next article:The role of ZXP0120ADB pressure sensor in wearable devices

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号