Git Product home page Git Product logo

rtc-video-quality's Introduction

Measuring Video Codec Performance

This is not an official Google product.

Example graph of SSIM-Y over multiple bitrates Example graph of per-frame SSIM-Y inside a single clip

This project contains a couple of scripts that can be used to generate quality metrics and graphs for different video codecs, encoders and settings.

Quality metrics can be generated for .y4m as well as .yuv raw I420 video files. .yuv files require the special format clip.WIDTH_HEIGHT.yuv:FPS since width, height and fps metadata are not available in this containerless format.

A set of industry-standard clips that can be used are available at Xiph.org Video Test Media, aka. "derf's collection".

Dependencies

To build pinned versions of dependencies, comparison tools and libvpx run:

$ ./setup.sh

This requires git and build dependencies for libvpx that are not listed here. See build instructions for libvpx for build dependencies.

To use .y4m files as input (instead of .yuv), mediainfo and ffmpeg are both required (to extract metadata and convert to .yuv). They can either be built and installed from source or likely by running (or similar depending on distribution):

$ sudo apt-get install ffmpeg mediainfo

Encoders

After building dependencies with ./setup.sh libvpx encoders are available. Additional encoders have to be fetched and built by using their corresponding setup scripts.

libvpx-rt:vp8 and libvpx-rt:vp9 use libvpx encoders with settings as close as possible to settings used by Chromium's WebRTC implementation.

TODO(pbos): Add reasonable non-realtime settings for --good and --best settings as libvpx-good and libvpx-best encoders for comparison with aom-good.

libyami

To build pinned versions of libyami, VA-API and required utils run:

$ ./setup_yami.sh

Using libyami encoders (yami:vp8, yami:vp9) requires VA-API hardware encoding support that's at least available on newer Intel chipsets. Hardware encoding support can be probed for with vainfo.

aomedia

To build pinned versions of aomedia utils run:

$ ./setup_aom.sh

This permits encoding and evaluating quality for the AV1 video codec by running the encoder pair aom-good:av1. This runs a runs aomenc with --good configured as a 2-pass non-realtime encoding. This is significantly slower than realtime targets but provides better quality.

There's currently no realtime target for AV1 encoding as the codec isn't considered realtime ready at the point of writing. When it is, aom-rt should be added and runs could then be reasonably compared to other realtime encoders and codecs.

OpenH264

To build pinned versions of OpenH264, run:

$ ./setup_openh264.sh

OpenH264 is a single-pass encoder used in WebRTC both in Chrome and Firefox. This adds the openh264:h264 which runs h264enc with settings that are intended to be close to WebRTC's implementation.

Generating Data

To generate graph data (after building and installing dependencies), see:

$ ./generate_data.py --help

Example usage:

$ ./generate_data.py --out=libvpx-rt.txt --encoders=libvpx-rt:vp8,libvpx-rt:vp9 clip1.320_240.yuv:30 clip2.320_180.yuv:30 clip3.y4m

This will generate libvpx-rt.txt with an array of Python dictionaries with metrics used later to build graphs. This part takes a long time (may take hours or even days depending on clips, encoders and configurations) as multiple clips are encoded using various settings. Make sure to back up this file after running or risk running the whole thing all over again.

To preserve encoded files, supply the --encoded-file-dir argument.

VMAF

Graph data can be optionally supplemented with VMAF metrics. To build a pinned version of VMAF, run:

$ ./setup_vmaf.sh

This requires several additional dependencies that are not listed here. See build instructions for VMAF for build dependencies.

To enable the creation of VMAF metrics, supply the --enable-vmaf argument to generate_data.py.

System Binaries

To use system versions of binaries (either installed or otherwise available in your PATH variable), supply --use-system-path to generate_data.py. This will fall back to locally-compiled binaries (but warn) if the encoder commands are not available in PATH.

Dumping Encoder Commands

For debugging and reproducing (if you're working on encoders) it can be useful to know which encoder command produced a certain data point.

To dump the commands used to generate data instead of running them, supply --dump-commands to generate_data.py.

Generating Graphs

To generate graphs from existing graph data run:

$ generate_graphs.py --out-dir OUT_DIR graph_file.txt [graph_file.txt ...]

This will generate several graph image files under OUT_DIR from data files generated using generate_data.py, where each clip and temporal/spatial configuration are grouped together to generate graphs comparing different encoders and layer performances for separate SSIM, AvgPSNR and GlbPSNR metrics. Multiple encoders and codecs are placed in the same graphs to enable a comparison between them.

The script also generates graphs for encode time used. For speed tests it's recommended to use a SSD or similar, along with a single worker instance to minimize the impact that competing processes and disk/network drive performance has on time spent encoding.

The scripts make heavy use of temporary filespace. Every worker instance uses disk space roughly equal to a few copies of the original raw video file that is usually huge to begin with. To solve or mitigate issues where disk space runs out during graph-data generation, either reduce the amount of workers used with --workers or use another temporary directory (with more space available) by changing the TMPDIR environment variable.

Adding or Updating Encoder Implementations

Adding support for additional encoders are encouraged. This requires adding an entry under generate_data.py which handles the new encoder, optionally including support for spatial/temporal configurations.

Any improvements upstream to encoder implementations have to be pulled in by updating pinned revision hashes in corresponding setup/build scripts.

rtc-video-quality's People

Contributors

jason-cooke avatar pbos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rtc-video-quality's Issues

libvpx vp9enc rt encoding is way off the target bitrate due to cpu-used option

using rtc-video-quality for vp9enc will set --cpu-used=7. When setting the target bitrate to 400Kbps this is the result

{ 'actual-bitrate-bps': 547721.7882352942,
'actual-encode-time-ms': 77934.56983566284,
'avg-psnr': 35.749396,
'avg-psnr-u': 41.3453,
'avg-psnr-v': 41.440348,
'avg-psnr-y': 34.403333,
'bitrate-config-kbps': [400],
'bitrate-utilization': 1.3693044705882353,
'codec': 'vp9',
'encode-time-utilization': 2.750631876552806,
'encoder': 'libvpx-rt',
'fps': 30.0,
'frame-bytes': [ 16980,
2780,
2634,
2368,
2551,
3169,

whle with yami the result is

[{ 'actual-bitrate-bps': 418750.87058823527,
'actual-encode-time-ms': 4427.440881729126,
'avg-psnr': 33.7104,
'avg-psnr-u': 39.335324,
'avg-psnr-v': 39.315309,
'avg-psnr-y': 32.367415,
'bitrate-config-kbps': [400],
'bitrate-utilization': 1.0468771764705882,
'codec': 'vp9',
'encode-time-utilization': 0.15626261935514563,
'encoder': 'yami',
'fps': 30.0,
'frame-bytes': [ 14768,
303,
320,
383,
491,

By picking --cpu-used=4 is a good compromise. This was run on a Yoga 910 with Fedora 25

{ 'actual-bitrate-bps': 414493.55294117646,
'actual-encode-time-ms': 326446.2540149689,
'avg-psnr': 34.466931,
'avg-psnr-u': 39.994153,
'avg-psnr-v': 40.389453,
'avg-psnr-y': 33.112922,
'bitrate-config-kbps': [400],
'bitrate-utilization': 1.0362338823529411,
'codec': 'vp9',
'encode-time-utilization': 11.52163249464596,
'encoder': 'libvpx-rt',
'fps': 30.0,
'frame-bytes': [ 11657,
1465,
1030,
860,
850,
954,
905,

Allow user to specify a temporary folder for storage

On my Fedora 25 installation /tmp is a tmpfs mount that is used for cache and normally pretty full. The files stored there by rtc-video-quality will not fit so it would be good if user can specify another temp folder location.

Allow user to provide system installed libraries

This could help with debugging. For example, I want to have my own compiled version of libvpx, libyami and company on a dedicated folder in my path. I don't want to run the setup* scripts but use that instead.

As a result, rtc-video-quality should report when an option on the libraries is not supported.

Try to remove ffmpeg/mediainfo dependency

At bare minimum ffmpeg invocation should fall back to avconv when one is present but not the other, but ideally light-weight tools should be checked into libvpx/tools/ and built in setup.sh to remove dependencies on both.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.