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?
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.
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.
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.
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.
Previous article:What are the emulators needed for voice chips?
Next article:The role of ZXP0120ADB pressure sensor in wearable devices
- Popular Resources
- Popular amplifiers
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Inverter air conditioner outdoor unit control system based on Zhongying SH32F205
- Common Verilog Syntax for FPGA Design
- The interfaces of LED unit boards are all HUB75E, so they cannot be used interchangeably by different brands?
- C2000 MCU Boot Process Analysis - Taking TMS320F28069 as an Example
- Question: Risks of MOS tube switching circuit
- ADI ADUM7702 16-bit isolated Sigma-Delta 24-bit AD7793+ADU5401 isolator data
- DSP F2812 Interrupt
- Problems with the Arteli AT-LINK-EZ virtual serial port
- EEWORLD University Hall----Black technology probe: know the current size by touching it (English, foreign netizens' evaluation)
- Detailed explanation of Zigbee networking principle