# FFmpeg Quality Metrics
[![PyPI version](https://badge.fury.io/py/ffmpeg_quality_metrics.svg)](https://badge.fury.io/py/ffmpeg_quality_metrics)
Simple script for calculating quality metrics with FFmpeg.
Currently supports PSNR, SSIM and VMAF. It will output:
- the per-frame metrics
- metrics for each component (Y, U, V)
- global statistics (min/max/average/standard deviation)
Author: Werner Robitza <werner.robitza@gmail.com>
Contents:
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Running with Docker](#running-with-docker)
- [Output](#output)
- [License](#license)
------
## Requirements
- Python 3.6 or higher
- FFmpeg:
- download a static build from [their website](http://ffmpeg.org/download.html))
- put the `ffmpeg` executable in your `$PATH`
Optionally, you may install FFmpeg with `libvmaf` support to run VMAF score calculation. Under Linux and macOS, this can be done with the following steps:
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-libvmaf
```
This may take a while.
Under Windows, you have to install ffmpeg and VMAF manually, or using [helper scripts](https://github.com/rdp/ffmpeg-windows-build-helpers).
## Installation
pip3 install ffmpeg_quality_metrics
Or clone this repository, then run the tool with `python3 -m ffmpeg_quality_metrics`
## Usage
In the simplest case, if you have a distorted (encoded, maybe scaled) version and the reference:
```
ffmpeg_quality_metrics distorted.mp4 reference.avi
```
The distorted file will be automatically scaled to the resolution of the reference.
### Extended Options
See `ffmpeg_quality_metrics -h`:
```
usage: [-h] [-n] [-v] [-ev] [-m MODEL_PATH] [-p] [-dp]
[-s {fast_bilinear,bilinear,bicubic,experimental,neighbor,area,bicublin,gauss,sinc,lanczos,spline}]
[-of {json,csv}] [-r FRAMERATE] [-t THREADS]
dist ref
positional arguments:
dist input file, distorted
ref input file, reference
optional arguments:
-h, --help show this help message and exit
-n, --dry-run Do not run command, just show what would be done
(default: False)
-v, --verbose Show verbose output (default: False)
-ev, --enable-vmaf Enable VMAF computation; calculates VMAF as well as
SSIM and PSNR (default: False)
-m MODEL_PATH, --model-path MODEL_PATH
Set path to VMAF model file (.pkl) (default: None)
-p, --phone-model Enable VMAF phone model (default: False)
-dp, --disable-psnr-ssim
Disable PSNR/SSIM computation. Use VMAF to get YUV
estimate. (default: False)
-s {fast_bilinear,bilinear,bicubic,experimental,neighbor,area,bicublin,gauss,sinc,lanczos,spline}, --scaling-algorithm {fast_bilinear,bilinear,bicubic,experimental,neighbor,area,bicublin,gauss,sinc,lanczos,spline}
Scaling algorithm for ffmpeg (default: bicubic)
-of {json,csv}, --output-format {json,csv}
output in which format (default: json)
-r FRAMERATE, --framerate FRAMERATE
force an input framerate (default: None)
-t THREADS, --threads THREADS
Number of threads to do the calculations (default: 0)
```
### Specifying VMAF Model
If you are running Windows, or if you want to specify a different VMAF model file than the default, you need both a `.pkl` and a `.pkl.model` file in the same path for VMAF to be able to load the model.
Use the `-m/--model-path` option to set the path to the model file, by pointing it to the `.pkl` file (not the `.pkl.model` file!).
For example, if you have the model files saved at:
```
/usr/local/opt/libvmaf/share/model/vmaf_v0.6.1.pkl
/usr/local/opt/libvmaf/share/model/vmaf_v0.6.1.pkl.model
```
Run the command with:
```
ffmpeg_quality_metrics dist.mkv ref.mkv -m /usr/local/opt/libvmaf/share/model/vmaf_v0.6.1.pkl
```
## Running with Docker
If you don't want to deal with dependencies, build the image with Docker:
```
docker build -t ffmpeg_quality_metrics .
```
This installs `ffmpeg` with all dependencies. You can then run the container, which basically calls the Python script. To help you with mounting the volumes (since your videos are not stored in the container), you can run a helper script:
```
./docker_run.sh
```
Check the output of the above command for more help.
## Output
JSON or CSV, including individual fields for Y, U, V, and averages, as well as frame numbers.
JSON example:
```
➜ ffmpeg_quality_metrics test/dist-854x480.mkv test/ref-1280x720.mkv --enable-vmaf
{
"vmaf": [
{
"adm2": 0.69908,
"motion2": 0.0,
"ms_ssim": 0.89698,
"psnr": 18.58731,
"ssim": 0.92415,
"vif_scale0": 0.53962,
"vif_scale1": 0.71805,
"vif_scale2": 0.75205,
"vif_scale3": 0.77367,
"vmaf": 14.07074,
"n": 1
},
{
"adm2": 0.69846,
"motion2": 0.35975,
"ms_ssim": 0.89806,
"psnr": 18.60299,
"ssim": 0.9247,
"vif_scale0": 0.54025,
"vif_scale1": 0.71961,
"vif_scale2": 0.75369,
"vif_scale3": 0.77607,
"vmaf": 14.48034,
"n": 2
},
{
"adm2": 0.69715,
"motion2": 0.35975,
"ms_ssim": 0.89879,
"psnr": 18.6131,
"ssim": 0.92466,
"vif_scale0": 0.5391,
"vif_scale1": 0.71869,
"vif_scale2": 0.75344,
"vif_scale3": 0.77616,
"vmaf": 14.27326,
"n": 3
}
],
"psnr": [
{
"n": 1,
"mse_avg": 536.71,
"mse_y": 900.22,
"mse_u": 234.48,
"mse_v": 475.43,
"psnr_avg": 20.83,
"psnr_y": 18.59,
"psnr_u": 24.43,
"psnr_v": 21.36
},
{
"n": 2,
"mse_avg": 535.29,
"mse_y": 896.98,
"mse_u": 239.4,
"mse_v": 469.49,
"psnr_avg": 20.84,
"psnr_y": 18.6,
"psnr_u": 24.34,
"psnr_v": 21.41
},
{
"n": 3,
"mse_avg": 535.04,
"mse_y": 894.89,
"mse_u": 245.8,
"mse_v": 464.43,
"psnr_avg": 20.85,
"psnr_y": 18.61,
"psnr_u": 24.22,
"psnr_v": 21.46
}
],
"ssim": [
{
"n": 1,
"ssim_y": 0.934,
"ssim_u": 0.96,
"ssim_v": 0.942,
"ssim_avg": 0.945
},
{
"n": 2,
"ssim_y": 0.934,
"ssim_u": 0.96,
"ssim_v": 0.943,
"ssim_avg": 0.946
},
{
"n": 3,
"ssim_y": 0.934,
"ssim_u": 0.959,
"ssim_v": 0.943,
"ssim_avg": 0.945
}
],
"global": {
"ssim": {
"average": 0.9453333333333332,
"stdev": 0.00047140452079103207,
"min": 0.945,
"max": 0.946
},
"psnr": {
"average": 20.84,
"stdev": 0.008164965809278536,
"min": 20.83,
"max": 20.85
},
"vmaf": {
"average": 14.27478,
"stdev": 0.16722195390159322,
"min": 14.07074,
"max": 14.48034
}
},
"input_file_dist": "test/dist-854x480.mkv",
"input_file_ref": "test/ref-1280x720.mkv"
}
```
CSV example:
```
➜ ffmpeg_quality_metrics test/dist-854x480.mkv test/ref-1280x720.mkv --enable-vmaf -of csv
n,adm2,motion2,ms_ssim,psnr,ssim,vif_
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | ffmpeg_quality_metrics-0.8.0.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 190 浏览量
2022-01-11
08:03:42
上传
评论
收藏 14KB GZ 举报
温馨提示
资源来自pypi官网。 资源全名:ffmpeg_quality_metrics-0.8.0.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
ffmpeg_quality_metrics-0.8.0.tar.gz (14个子文件)
ffmpeg_quality_metrics-0.8.0
setup.py 2KB
ffmpeg_quality_metrics.egg-info
top_level.txt 23B
SOURCES.txt 391B
PKG-INFO 14KB
entry_points.txt 81B
dependency_links.txt 1B
requires.txt 7B
MANIFEST.in 18B
setup.cfg 38B
README.md 10KB
PKG-INFO 14KB
test
test.py 2KB
ffmpeg_quality_metrics
__init__.py 22B
__main__.py 14KB
共 14 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功