LOGO

YouTube Battery Drain: Fix High Usage in Chrome & Firefox

September 9, 2015
YouTube Battery Drain: Fix High Usage in Chrome & Firefox

YouTube Performance Issues: CPU Usage and Battery Drain

Are you experiencing stuttering videos, increased laptop temperatures, loud fan noise, or high CPU utilization while watching YouTube? It’s highly probable that YouTube within the Chrome browser is consuming excessive battery power, even if this isn't immediately apparent.

Similar to other performance concerns within Chrome, this issue tends to be particularly pronounced on Macintosh computers.

The Root Cause: HTML5 Video and Codec Incompatibilities

The core of the problem stems from the transition to HTML5 video and specific inconsistencies in the video codecs employed by YouTube when accessed through Chrome, compared to other web browsers.

Let's delve into the reasons behind Google's decision to implement YouTube playback in a manner that results in such inefficiency. It's important to note that Firefox may also exhibit similar performance drawbacks.

Understanding the Technical Details

  • The shift to HTML5 video was intended to provide a more standardized and open platform for video playback.
  • However, the specific video codecs used by YouTube, when decoded by Chrome, require significantly more processing power.
  • This increased processing demand translates directly into higher CPU usage, greater heat generation, and reduced battery life.

The discrepancy in efficiency arises from how different browsers handle these video codecs. Chrome's implementation appears to be less optimized than that of other browsers.

While the move to HTML5 was a positive step overall, the current implementation on Chrome presents a noticeable performance challenge for users.

HTML5, H.264, VP8, and VP9

YouTube has transitioned away from the Flash video plug-in, now primarily utilizing HTML5 for video playback. However, HTML5 video playback lacks a universal standard.

Different web browsers have the flexibility to select their preferred video codec, meaning there isn't a single codec universally supported across all platforms.

The Role of H.264

Previously, when YouTube relied on Flash, the H.264 codec was employed for video playback. Videos encoded with H.264 commonly feature the .mp4 file extension and are frequently termed MP4 videos.

This codec has become a widely accepted industry standard, extending beyond just web browser compatibility.

Safari, Internet Explorer, Microsoft Edge, Chrome, and Firefox all offer support for H.264-encoded videos. Notably, Firefox initially resisted incorporating this support.

Google's Codec Initiatives: VP8 and VP9

While Apple and Microsoft exclusively support H.264 for video playback within their browsers, Google has actively promoted its own codecs.

Google acquired the VP8 codec and integrated it into Chrome, with Firefox subsequently adopting it as well.

Currently, Google is championing the next-generation VP9 codec, which is now included in both Chrome and Firefox.

Files utilizing the VP9 codec typically have the .webm file extension and are also known as WebM files.

Here's a summary of the key codecs:

  • H.264: A widely supported codec, often found in .mp4 files.
  • VP8: Developed by Google and implemented in Chrome and Firefox.
  • VP9: The next-generation codec from Google, also supported by Chrome and Firefox.

The variety of codecs highlights the ongoing evolution of video technology on the web.

Understanding these codecs is crucial for optimizing video content for broad browser compatibility.

why-youtube-in-chrome-and-firefox-is-draining-your-laptops-battery-and-how-to-fix-it-1.jpgThe Genesis of VP8 and VP9: Google's Motivation

Despite the widespread adoption of H.264 as an industry standard for video compression, a notable issue exists. The core technologies powering H.264 are protected by numerous patents.

Implementing these technologies, such as within a new product, necessitates the payment of licensing fees to the H.264 patent holders.

This was the primary reason for Mozilla's initial resistance to H.264; the organization advocated for a web built upon open standards, free from royalty obligations.

Google addressed this concern by introducing VP8 and subsequently VP9, accompanied by a binding and perpetual patent pledge.

This pledge guarantees users the freedom to utilize these codecs without fear of future patent claims or licensing costs from Google.

Currently, Cisco bears the financial burden of H.264 licensing and provides a complimentary plugin for Firefox users.

Firefox automatically acquires and installs this plugin, thereby enabling H.264 video playback capabilities.

The Core Benefit: Patent Freedom

VP8 and VP9 were specifically designed to offer a royalty-free alternative to patented video codecs like H.264.

This allows developers and content creators to avoid the complexities and expenses associated with patent licensing.

The irrevocable patent promise from Google ensures long-term stability and predictability for those utilizing these codecs.

  • H.264 requires licensing fees.
  • VP8 and VP9 are royalty-free.
  • Google guarantees no future patent claims.

Limited Adoption of VP8

Despite its development, VP8 did not achieve widespread acceptance. In early 2011, Google declared its intention to phase out H.264 support within Chrome, prioritizing open codecs such as VP8 and Theora. However, this transition never materialized, and the initial commitment has remained unfulfilled for over four years.

Mozilla’s continued support for open codecs was likely contingent upon Google’s adherence to its stated plans. Since Google ultimately failed to deliver on this promise, Mozilla eventually conceded and incorporated H.264 support into its browser. Currently, H.264 functions as the dominant codec, regardless of preference, and remains the sole option available when utilizing browsers from Apple or Microsoft.

The practical necessity of H.264 extends to mobile browsing environments as well. Numerous websites have implemented HTML5 video functionality exclusively with H.264 support. Without H.264 compatibility, browsers like Chrome and Firefox would be unable to render these videos.

why-youtube-in-chrome-and-firefox-is-draining-your-laptops-battery-and-how-to-fix-it-2.jpg

The Core Issue: Hardware Acceleration Capabilities

The central challenge lies in a single, fundamental aspect. Decoding, or playing back, H.264 video is typically handled through hardware acceleration. This signifies that the graphics processing unit (GPU) undertakes the computational workload of video playback with significantly improved efficiency.

Without hardware decoding, the central processing unit (CPU) would be solely responsible for this task, resulting in reduced efficiency. Consequently, this leads to diminished battery life and increased heat production. Furthermore, smoother video reproduction can be achieved if the CPU is unable to manage the demands of video playback independently.

Virtually all contemporary hardware platforms now incorporate support for H.264 hardware-accelerated decoding. This encompasses a wide range of devices, including smartphones, tablets, personal computers, Macintosh computers, and Chromebooks. When a web browser, such as Chrome, renders H.264 video content, the processing is delegated to the GPU. Even older technologies like Adobe Flash included hardware acceleration for H.264 video.

The VP8 and VP9 Dilemma

However, currently, no available hardware provides acceleration for VP8 and VP9 video codecs. Following Google’s introduction of VP8 in mid-2010, several prominent companies, including nVIDIA, AMD, and Qualcomm, declared their intention to integrate VP8 support into their products.

Despite these announcements, over five years passed without the emergence of any devices featuring hardware-accelerated VP8 decoding capabilities. Google’s subsequent announcement of VP9 included claims that “more than 20 device partners” would release VP9-compatible products in 2015 and beyond.

The same announcement highlighted VP9’s advantages, such as achieving comparable video quality with smaller file sizes. Intel, nVIDIA, AMD, and others committed to supporting hardware-accelerated decoding for VP9. Our investigation to locate hardware with VP9 hardware acceleration revealed only that Intel released updated Haswell and Broadwell drivers for Windows in early 2015, offering “partial hardware acceleration support” for VP9.

It’s evident that substantial further development is required in this area.

Performance Discrepancies and Mac Considerations

Similar to other performance issues within Chrome, this problem may be more pronounced on Macintosh systems. Chrome developers addressed a bug report concerning elevated CPU usage and heat generation on MacBooks by stating, “CPU usage during VP9 playback on a Mac is not a bug.”

While technically accurate, Google should reconsider serving VP9 videos to Chrome users on Macs if high CPU utilization is considered normal behavior. This practice may inadvertently encourage Mac users to switch to alternative browsers like Safari.

why-youtube-in-chrome-and-firefox-is-draining-your-laptops-battery-and-how-to-fix-it-3.jpg

Optimizing YouTube Video Playback for Efficiency

A cyclical issue exists regarding video codecs – hardware manufacturers are hesitant to prioritize hardware acceleration for VP9 until its adoption becomes widespread. Google addressed this by integrating VP8 and VP9 support directly into Chrome, and then directing YouTube to deliver videos in these formats to Chrome users.

YouTube may also utilize VP8 and VP9 when serving videos to Firefox browsers. While this approach can potentially reduce download times, it often results in increased battery consumption and higher CPU usage within Chrome.

On devices equipped with less powerful processors, this can manifest as video stuttering or choppy playback, rather than a smooth viewing experience.

An alternative solution involves switching to browsers like Safari, Microsoft Edge, or Internet Explorer. However, this isn't always necessary.

The h264ify browser extension for Chrome provides a convenient workaround, compelling Chrome to request H.264 videos from YouTube. The visual quality remains identical, but playback performance is improved.

Where to Obtain h264ify

  • Download h264ify for Chrome.
  • Get h264ify for Firefox.
  • Further information and project details are available on the GitHub project page.

By utilizing h264ify, users can experience smoother and more efficient YouTube video playback within their Chrome browsers.

This is particularly beneficial for laptops and devices where conserving battery life and minimizing CPU strain are important considerations.

Determining the Codec Used by YouTube: H.264, VP8, or VP9

Identifying the video codec YouTube delivers to your browser is a straightforward process. During video playback, simply right-click within the video player window.

From the context menu that appears, choose the option labeled "Stats for nerds." This will display detailed technical information about the stream.

Locate the "Mime Type" entry in the displayed statistics. For videos encoded with H.264, you will observe "video/mp4" alongside the "avc" codec identifier.

Identifying VP8 and VP9 Streams

YouTube utilizes the WebM container format for VP8 and VP9 encoded videos. Consequently, you'll see "video/webm" listed as the "Mime Type."

The specific codec in use will be indicated by either "vp9" or "vp8" following the "video/webm" designation.

Codec Choice and its Implications

Google’s ongoing adoption of VP9 has the potential to benefit the internet ecosystem in the future. This could stimulate the development of hardware capable of accelerated VP9 decoding.

However, currently, selecting H.264 video can result in improved battery performance and enhanced laptop efficiency. This is particularly relevant if you wish to avoid participating in Google’s codec experimentation.

Choosing H.264 can be a practical solution for optimizing resource usage.

Image Credit: Esther Vargas on Flickr

#YouTube#battery drain#Chrome#Firefox#laptop battery#power consumption