Skip to content

Commit

Permalink
VmafQualityRunner finished up to feature extraction, house keeping fu…
Browse files Browse the repository at this point in the history
…nctions.
  • Loading branch information
li-zhi committed Feb 1, 2016
1 parent 0995d74 commit 02f7a89
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 63 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
python/config.py
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Add python directory to PYTHONPATH:
Add project root and python directory to PYTHONPATH:
export PYTHONPATH=[project root dir]:$PYTHONPATH

Copy config_template.py to config.py

-----------------------------------------

No need:

In config.py, set ROOT to your project root directory
ROOT = "/home/zli/Projects/stash/zli/vmaf_oss"

Add VMAF executable to PATH:
export PATH=[project root dir]/feature:$PATH

export PYTHONPATH=$PYTHONPATH:[project_root]/python
2 changes: 1 addition & 1 deletion python/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.pyc
*.pyc
File renamed without changes.
70 changes: 50 additions & 20 deletions python/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
__license__ = "LGPL Version 3"

import os

from common import Parallelizable
from tools import get_file_name_without_extension
from python.config import PYTHON_ROOT

class Asset(Parallelizable):

def __init__(self, dataset, ref_path, dis_path, asset_dict,
workdir_root="../workspace/workdir"):
workdir_root= PYTHON_ROOT + "/../workspace/workdir"):
"""
:param dataset
:param ref_path: path to reference video
Expand All @@ -23,6 +25,8 @@ def __init__(self, dataset, ref_path, dis_path, asset_dict,
self.dis_path = dis_path
self.asset_dict = asset_dict

# ==== width and height ====

@property
def ref_width_height(self):
"""
Expand Down Expand Up @@ -52,10 +56,10 @@ def dis_width_height(self):
@property
def quality_width_height(self):
"""
:return: width and height at which the quality is measured at. If None,
it signals that that the quality should be measured at ref and dis
video's native width and height (provided ref_width_height and
dis_width_height are equal).
:return: width and height at which the quality is measured at. either
'quality_width' and 'quality_height' have to present in asset_dict,
or ref and dis's width and height must be equal, which will be used
as the default quality width and height.
"""
assert ('quality_width' in self.asset_dict
and 'quality_height' in self.asset_dict) or \
Expand All @@ -64,7 +68,9 @@ def quality_width_height(self):
if 'quality_width' in self.asset_dict and 'quality_height' in self.asset_dict:
return self.asset_dict['quality_width'], self.asset_dict['quality_height']
else:
return None
return self.ref_width_height

# ==== start and end frame ====

@property
def ref_start_end_frame(self):
Expand Down Expand Up @@ -112,6 +118,8 @@ def dis_start_end_frame(self):
else:
return None

# ==== duration ====

@property
def ref_duration_sec(self):
if 'duration_sec' in self.asset_dict:
Expand Down Expand Up @@ -140,6 +148,8 @@ def dis_duration_sec(self):
else:
return None

# ==== str ====

@property
def ref_str(self):
str = ""
Expand All @@ -157,20 +167,6 @@ def ref_str(self):

return str

@property
def ref_workfile_path(self):
return "{workdir}/{ref_str}_{quality_str}".format(
workdir=self.workdir,
ref_str=self.ref_str,
quality_str=self.quality_str)

@property
def dis_workfile_path(self):
return "{workdir}/{dis_str}_{quality_str}".format(
workdir=self.workdir,
dis_str=self.dis_str,
quality_str=self.quality_str)

@property
def dis_str(self):
str = ""
Expand Down Expand Up @@ -209,6 +205,24 @@ def __str__(self):

return str

# ==== workfile ====

@property
def ref_workfile_path(self):
return "{workdir}/ref_{ref_str}_{quality_str}".format(
workdir=self.workdir,
ref_str=self.ref_str,
quality_str=self.quality_str)

@property
def dis_workfile_path(self):
return "{workdir}/dis_{dis_str}_{quality_str}".format(
workdir=self.workdir,
dis_str=self.dis_str,
quality_str=self.quality_str)

# ==== bitrate ====

@property
def ref_bitrate_kbps_for_entire_file(self):
"""
Expand All @@ -232,3 +246,19 @@ def dis_bitrate_kbps_for_entire_file(self):
self.dis_duration_sec * 8.0 / 1000.0
except:
return None

@property
def yuv_type(self):
"""
Assuming ref/dis files are both YUV and the same type, return the type
(yuv420, yuv422, yuv444)
:return:
"""
if 'yuv_type' in self.asset_dict:
if self.asset_dict['yuv_type'] in ['yuv420', 'yuv422', 'yuv444']:
return self.asset_dict['yuv_type']
else:
assert False, "Unknown YUV type: {}".\
format(self.asset_dict['yuv_type'])
else:
return 'yuv420'
Loading

0 comments on commit 02f7a89

Please sign in to comment.