GREEM: An Open-Source Energy Measurement Tool for Video Processing

Addressing climate change requires a global decrease in greenhouse gas (GHG) emissions. In today's digital landscape, video streaming significantly influences internet traffic, driven by the widespread use of mobile devices and the rising popularity of streaming platforms. This trend emphasizes the importance of evaluating energy consumption and the development of sustainable and eco-friendly video streaming solutions with a low Carbon Dioxide (CO2) footprint. We developed a specialized tool, released as an open-source library called GREEM, addressing this pressing concern. This tool measures video encoding and decoding energy consumption and facilitates measurement testbeds. It monitors the computational impact on hardware resources and offers various analysis cases. GREEM is helpful for developers, researchers, service providers, and policymakers interested in minimizing the energy consumption of video encoding and streaming. Github: https://github.com/cd-athena/GREEM


INTRODUCTION
Addressing the issue of climate change requires significantly reducing global greenhouse gas (GHG) emissions in various sectors [19].In the digital landscape, video streaming is responsible for 1% of the world's GHG emissions, equivalent to the  2 emissions of Spain [10].As more people work remotely, communicate through multimedia platforms like WhatsApp, Zoom, and Skype, and consume video content from YouTube and Netflix, including advanced formats like 4K, 8K, and multiview, the sustainability of video streaming decreases exponentially [18].
Video streaming relies on encoding videos into multiple representations for adaptive streaming or HTTP Adaptive Streaming (HAS), enabling users to enjoy videos seamlessly without buffering or interruptions [30].However, this encoding process consumes significant energy and resources, adding to the environmental footprint of video streaming [2,4,17].Furthermore, the energy consumption associated with video decoding is crucial for mobile devices and directly affects battery life.Therefore, there is a pressing need to measure and minimize the energy consumption of video encoding and decoding processes, striving for more environmentally friendly solutions.
One way to achieve this goal is through video encoding and decoding measurements that compare the energy consumption of different techniques and practices.These measurements can help the industry identify and adopt sustainable methods and technologies for video streaming and reduce the environmental impacts of this disruptive digital technology.The measurements can also enable developers, service providers, and policymakers to prioritize eco-friendly solutions and raise users' awareness of the environmental consequences of their online behavior.
In this paper, we propose a specialized tool called GREEM (Gaia Resource Energy and Emission Monitoring) to facilitate the implementation and energy measurements of video encoding and decoding processes.GREEM provides an automation setup that allows users to easily configure and run various experimental scenarios with different parameters and settings and compare the results.Moreover, GREEM also provides easy-to-use sequential and parallel measurement scenarios for video encoding and decoding on CPUs and GPUs covering the most common and relevant video streaming cases.For this purpose, it incorporates various tools and libraries, providing valuable insights into in-depth monitoring of the computational impact on hardware resources, including CPU and GPU utilization and memory use, to help users understand the tradeoffs and bottlenecks of different encoding and decoding techniques and platforms.GREEM stores the results in comma-separated values (CSV) [25] files.This commonly used easy-to-parse file format allows various analysis scenarios to compare and visualize the energy consumption and performance of different encoding and decoding techniques and platforms.

Contribution.
We introduce an open-source monitoring tool released under a modified BSD license, available in a GitHub repository 1 for energy measurement of video processing.The tool traces numerous hardware parameters, specifically monitoring energy consumption and GPU metrics, including core and memory utilization, temperature, and fan speed.Additionally, we offer scripts that generate analytic plots, facilitating researchers in visualizing and analyzing their generated measurement results.
The paper has eight sections.Section 2 discusses similar works on measuring the energy impact of computationally intense tasks.Section 3 provides an overview of GREEMs architecture and Section 4 discusses the significant functionalities of GREEM and explains its implementation and its used libraries in detail.Section 5 overviews available measurement testbeds and their purpose within GREEM.Subsequently, Section 6 analyzes the measurement results, and Section 7 discusses some possible measurement applications.Finally, Section 8 presents the conclusion and outlines the future work.

RELATED WORK
This section overviews the energy and power monitoring tools released in the community.
CodeCarbon [27] is a monitoring tool to measure energy consumption and corresponding  2 emissions using Intel Running Average Power Limit (RAPL) [15] interface for CPUs and pyN-VML [22] for Nvidia GPUs.Additionally, it provides default estimations based on the measured duration computations for other hardware vendors.Katsenou et al. [14] tested the accuracy of energy measurements and they found a high correlation with external power meters.GREEM extends CodeCarbon with additional monitoring metrics like GPU memory and core utilization.
PowerAPI [8] is a software library that provides an application programming interface to monitor real-time energy usage at the granularity of a system process.PowerAPI relies on energy analytical models to characterize hardware components such as CPU, memory, and disk.
DEEP-mon [9] is an open-source monitoring tool that measures the performance counters (i.e., CPU and memory use, file and network I/O) and power consumption attributed to Docker application containers running in the system.DEEP-mon aims to optimize the workload execution of power-aware schedulers and orchestrators in energy trade-off scenarios.Contrary to DEEP-mon's focus on Docker containers, GREEM focuses on system processes.
Contribution.Table 1 summarizes the differences between the GREEM and state-of-the-art power and energy monitoring tools.GREEM provides measurement scenarios for video processing energy measurements and offers more monitoring metrics, including GPU core and memory utilization, temperature, and load average over time.Additionally, it provides scripts for generating analytical plots based on measurement results.

GREEM ARCHITECTURE
Figure 1 depicts the GREEM architecture, designed to monitor the energy consumption of computing resources (CPU, GPU, and memory) during video processing in various measurement testbeds.Additionally, the tool enables the measurement of other performance metrics of resources, including utilization and temperature.
The configurator receives user parameters in configuration files, including codec, preset, resolution, and framerate.The parameters Table 1: State-of-the-art comparison.

Features CodeCarbon PowerAPI DEEP-mon GREEM
of the configuration files define how the measurements are structured and executed.The configurator combines these parameters to apply each combination to input videos.The video processor processes the input videos according to the configuration parameters.It signals the monitor component to track and measure the hardware resources during video processing.Then, it stores the processed videos in the database.
The monitor starts when the input video processing begins.It continuously monitors hardware resources, including CPU, memory, and GPU, for energy consumption, temperature, and utilization throughout the video processing and receives a stop signal from the video processor once the process is complete.The monitor component then stores the collected traces in the database for subsequent analysis.
The database stores the processed videos, the applied parameters, monitored resource values, computed metrics, and generated plots.
Finally, the analyzer reads measurement results, generates metrics, and plots the energy impact, utilization, and duration of video processing based on the configuration parameters.It displays the plots and calculated metrics to the user while storing them in the database for future reference.

IMPLEMENTATION
We implement GREEM in Python 3.10 because of its popularity in the research and data science community and ease of use.We also used Anaconda2 to create the virtual environment for GREEM, which ensures compatibility and avoids conflicts among libraries.

Tools and methodology
GREEM incorporates various tools and libraries, and their purposes are summarized in Table 2.
Configuration.Listing 1 shows an example structure for an encoding measurement scenario defined as a YAML [6] file.We implement a data class to retrieve values from the configuration file, including a function that returns a combination of all possible fields defined.We call each combined instance in the video encoding configuration file EncodingConfigDTO, containing the configuration of a specific scenario, including the encoding codec, preset, rendition, and encoding frame rate.

Category
Tool / Library Purpose Configuration YAML [6] Measurement parameter configuration in YAML format.Video processing FFmpeg [11] Encoding and decoding measurement testbeds; video metadata extraction.
Analytics pandas [24] CSV file creation from measurement results and analysis.Matplotlib [13] seaborn [28] Data analysis and visualizations based on measurement results.Video processing.GREEM uses the command line interface of FFmpeg3 , a popular cross-platform tool for video encoding and decoding, instead of the Python library since it is easier to adapt and debug.Table 3 outlines the FFmpeg libraries for encoding and decoding.

Monitoring.
We use three open-source tools as background processes to collect data from the hardware resources and ensure no interruption with the primary monitored process.
• CodeCarbon monitors energy consumption and computing resources' associated  2 emissions.
• nvitop monitors the state of the GPUs while the encoding/decoding process is being executed.Metrics collected by nvitop include GPU core and memory utilization, temperature, and fan speed.• pyNVML is a hardware interface wrapper for Python to access the GPU state for monitoring.We use pyNVML to monitor the same GPU values as nvitop through the entire measurement periodically.The user chooses between nvitop and pyNVML based on their interest or priority within the measurement testbed.
Analytics.Jupyter notebooks [16] offer interactive result analysis and visualization using three libraries: • Pandas [24] data analysis library provides efficient data manipulation techniques and built-in functionality used by GREEMto calculate metrics and retrieve insights from the measurement results.• Matplotlib [13] and seaborn [28] are statistical data visualization libraries to generate plots for measurement results.

GREEM repository structure
Figure 2 shows the structure of the GREEM repository as a visual guide for organizing files and folders.Folders are in blue text, and files are in black text with corresponding extensions.
greem.The repository's root contains several folders and files described in the following paragraphs.README.md.The guide to GREEM provides detailed information about its installation, details on measurement testbeds, and troubleshooting common issues.environment.yml.The file containing specifications for the required third-party libraries necessary for creating a virtual environment tailored to support the functionality of GREEM.
evaluation.This folder contains Jupyter Notebooks with analysis scripts to investigate the measurement results by changing the folder path to the CSV file.The notebooks use libraries for statistical data analysis that show results in visual figures and numerical metrics.
Listing 1 Encoding configuration YAML structure.
monitoring.This folder accommodates various tools designed for monitoring.nvidia_top.py is a real-time monitoring tool during the execution of the video process.pynvml_monitoring.py is a periodic monitoring tool functioning as a background task that collects and stores monitoring traces at specified time intervals.testbeds.A folder for all scripts and associated configuration files, tailored explicitly for video encoding and decoding tasks.These measurement scripts have several subfolders based on their primary encoding/ or decoding/ function.Each measurement script executes within its corresponding folder, ensuring access to the necessary configuration files.The dataset folder stores input data, such as uncompressed video files for measurement testbeds.
utility.This folder comprises a collection of utility scripts contributing with unique functionalities to GREEM: • CLI argument parser (cli_parser.py)allows users to customize and control the measurement process through the command line; • Configuration data classes (config.py)handles retrieval of configuration data for use within measurement testbeds; • Video processing (ffmpeg.py)generates FFmpeg commands for video processing; and • Video metadata (video_metadata.py)reads input video files and retrieves their metadata (e.g., resolution, bitrate).

MEASUREMENT SCENARIOS
This section introduces the video processing scenarios for energy measurements: encoding and decoding.For encoding, we define sequential and parallel methods.We decode the encoded videos using different settings and metrics.

Encoding measurements
Before encoding, GREEM chunks the videos into HTTP Adaptive Streaming (HAS) segments with defined durations using two measurement scenarios: sequential and parallel.5.1.1Sequential encoding measurements.It encodes one video at a time with a specific configuration.Sequential encoding allows for a detailed analysis of video content and encoding parameters, for example, exploring how the content of the video impacts energy consumption and analyzing the specific effects of individual encoding configuration parameters such as codec, bitrate, width, height, frame rate on energy usage.
5.1.2Parallel encoding measurements.It simultaneously encodes multiple videos with at least one encoding configuration to fully utilize the modern multiprocessing CPU and GPU resources.We propose a sliding window technique similar to [7] that contains the videos intended for encoding, and we increment it by its size upon encoding all contained input videos (see Figure 3).

Decoding measurements
The decoding measurements use previously encoded videos, monitoring resource metrics during the decoding process.This process offers customization, enabling users to conduct decoding measurements by selectively filtering videos through specific configurations defined within the decoding configuration file.Additionally, an optional operation involves upscaling the input videos to different resolutions.The monitoring results of upscaled videos are stored separately for analysis.

MEASUREMENT EXAMPLE
We conduct a measurement scenario and generate example analytic plots supported by GREEM.

Measurement setup
We conducted a sequential encoding measurement on a GPU server with an AMD EPYC 7713 CPU featuring 64 CPU cores, NVidia RTX A6000 GPU, and 1008 GB of RAM.
Video dataset.We used a video dataset [3] for the encoding measurement consisting of 500 lossless, four-second video sequences.The videos vary in their spatial and temporal complexity, making it possible to use them for a broad analysis.
Encoding configuration.We used Advanced Video Coding (AVC) [20] and High-Efficiency Video Coding (HEVC) [21], medium preset and a constant rate factor of 23.We extracted the bitrates and resolutions for each encoding codec from the Apple HLS bitrate ladder [5], for AVC defined up to full HD resolution (1920 × 1080) with a bitrate of 7800 [kb/s].

Analysis
Figure 4a shows the required energy consumption compared to the bitrates defined in the configuration in kW h per encoding codec.As expected, the more computationally complex HEVC requires more energy for encoding than AVC.Similarly, Figure 4b shows the  2 impact per bitrate for the encoding codecs AVC and HEVC.Consequently, an initial observation is that energy consumption and  2 emission closely relate to the bitrate chosen for encoding.The average utilization for CPU and memory in Figures 4c and 4d show that HEVC has a higher impact on the hardware resource, except for CPU utilization with a low bitrate encoding.Figure 4e for HEVC and Figure 4f for AVC depict the energy consumption per framerate.We observe that higher bitrates with higher framerates have more impact on energy consumption when encoding a video with HEVC, while each framerate variant for AVC has similar values.

APPLICATIONS
Leveraging GREEM for designing and conducting comprehensive measurement testbeds enables detailed insights into video processing energy consumption and  2 emissions.
Profiling energy measurements.Leveraging GREEM for comprehensive measurement testbeds enables a detailed analysis of video encoding and decoding energy consumption, considering various parameters such as codec, frame rate, bitrate, and resolution.This analysis has potential for energy optimization [14] in hardware and software, video encoding and decoding parameters, and to identify the best resource configurations for video processing [1].
Energy-efficient applications.Using GREEM to conduct numerous video encoding and decoding measurements allows the creation of datasets crucial in developing energy-efficient models through analysis and machine learning training.These models can predict energy consumption and hardware utilization, considering specific encoding parameters, video metrics, and available resources.

CONCLUSION AND FUTURE WORK
We introduced GREEM, an easy-to-use and set-up tool for comparable measurement testbeds with an in-depth collection of hardware metrics and energy measurements.GREEMincludes analytical scripts that visualize widely used metrics of measurement results.The tool also supports functionality for numerous in-depth utilities to create custom measurement testbeds with little effort.The consistent base structure across scenarios allows for easy generalization of measurement scripts and only changes the configuration file instead of using multiple measurement scripts.
In the future, we plan to create several measurement datasets and make them available on GitHub.Given that the file size of measurement results can be substantial, we will efficiently manage and share them using Git large file storage [12], integrated within the GitHub repository.Additionally, we plan to provide more platformagnostic monitoring covering the widely used hardware companies for CPU and GPU beyond NVidia nvitop GPU monitoring.
a) Energy per bitrate.b)  2 emission per bitrate.c) Avg.CPU utilization per bitrate.d) Avg.Memory utilization per bitrate.e) HEVC energy consumption per framerate.f) AVC energy consumption per framerate.

Table 2 :
Integrated tool and library overview.

Table 3 :
FFmpeg encoding and decoding libraries.