initial commit

This commit is contained in:
Nikolas
2024-08-16 14:32:16 -07:00
parent 909c2918c3
commit 51b5982eb5
9 changed files with 524 additions and 0 deletions

3
.gitignore vendored
View File

@@ -23,6 +23,9 @@ sphfract.scn
output.ppm
tq_dlss_explained_1080*
xz_5.6.2_x86*
*.y4m
*.exe
*.mp4
# python
__pycache__/

View File

@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
Changes are grouped by the date they are merged to the main branch of the repository and are ordered from newest to oldest. Dates use the ISO 8601 extended calendar date format, i.e. YYYY-MM-DD.
## 2024-08-16
- Add handbrake test harness.
## 2024-07-29
- Update Y Cruncher test to use version 0.8.5.9543 of Y Cruncher

View File

@@ -94,3 +94,6 @@ def find_blender():
version_ls = info['FileVersionLS']
version = f"{HIWORD (version_ms)}.{LOWORD (version_ms)}.{HIWORD (version_ls)}.{LOWORD (version_ls)}"
return executable_path, version
copy_from_network_drive()

127
handbrake/handbrake.py Normal file
View File

@@ -0,0 +1,127 @@
"""test script for handbrake encoding tests"""
from argparse import ArgumentParser
import os
import re
from handbrake_utils import HANDBRAKE_EXECUTABLE, current_time_ms, handbrake_present, is_video_source_present, copy_video_source, copy_handbrake_from_network_drive
import logging
import subprocess
import sys
from pathlib import Path
sys.path.insert(1, os.path.join(sys.path[0], ".."))
from harness_utils.output import (
DEFAULT_DATE_FORMAT,
DEFAULT_LOGGING_FORMAT,
write_report_json
)
SCRIPT_DIR = Path(__file__).resolve().parent
LOG_DIR = SCRIPT_DIR.joinpath("run")
LOG_DIR.mkdir(exist_ok=True)
LOG_FILE = LOG_DIR / "harness.log"
logging.basicConfig(
filename=LOG_FILE,
format=DEFAULT_LOGGING_FORMAT,
datefmt=DEFAULT_DATE_FORMAT,
level=logging.DEBUG
)
console = logging.StreamHandler()
formatter = logging.Formatter(DEFAULT_LOGGING_FORMAT)
console.setFormatter(formatter)
logging.getLogger("").addHandler(console)
def main():
"""entrypoint"""
parser = ArgumentParser()
parser.add_argument("-e", "--encoder", dest="encoder",
help="encoder", metavar="encoder", required=True)
args = parser.parse_args()
encoder_to_preset = {
"h264": {
"file": "./presets/h264_bigbuckbunny_1080p_cpu_test.json",
"name": "CPU 1080p BBB H264"
},
"h265": {
"file": "./presets/h265_bigbuckbunny_1080p_cpu_test.json",
"name": "CPU 1080p BBB H265"
},
"av1": {
"file": "./presets/av1-svt_bigbuckbunny_1080p_cpu_test.json",
"name": "CPU 1080p BBB AV1"
}
}
if args.encoder not in list(encoder_to_preset.keys()):
logging.error(f"Invalid encoder selection: {args.encoder}")
sys.exit(1)
try:
score = 0
preset = encoder_to_preset[args.encoder]
if handbrake_present() is False:
logging.info("copying handbrake from network drive")
copy_handbrake_from_network_drive()
else:
logging.info("detected handbrake")
if is_video_source_present() is False:
logging.info("copying big buck bunny from network drive")
copy_video_source()
else:
logging.info("detected big buck bunny source file")
logging.info("starting benchmark, this may take a few minutes")
logging.info(
"you can ensure the test is running by checking that cpu usage is 100% in task manager")
command = f"{SCRIPT_DIR}\\{HANDBRAKE_EXECUTABLE}"
start_time = current_time_ms()
avgencoding_pattern = r'average encoding speed for job is (\d+\.\d+) fps'
output = subprocess.check_output([
command,
"-i",
"big_buck_bunny_1080p24.y4m",
"-o",
"bbboutput.mp4",
"--preset-import-file",
preset['file'],
"--preset",
preset['name']],
text=True,
stderr=subprocess.STDOUT)
end_time = current_time_ms()
logging.getLogger("").removeHandler(console)
logging.info(output)
logging.getLogger("").addHandler(console)
match = re.search(avgencoding_pattern, output)
if not match:
raise Exception("score was not found in the process output!")
score = match.group(1)
logging.info(f"Average Encoding Speed: {score}")
logging.info(f"Finished in: {(end_time - start_time) / 1000} seconds")
end_time = current_time_ms()
report = {
"test": f"HandBrake Encoding BBB {args.encoder.upper()}",
"score": score,
"unit": "frames per second",
"version": "1.8.1",
"start_time": start_time,
"end_time": end_time
}
write_report_json(LOG_DIR, "report.json", report)
except Exception as e:
logging.error("Something went wrong running the benchmark!")
logging.exception(e)
sys.exit(1)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,41 @@
"""utility functions for running handbrake tests"""
import os
from pathlib import Path
import time
import shutil
HANDBRAKE_EXECUTABLE = "HandBrakeCLI.exe"
SOURCE_VIDEO_NAME = "big_buck_bunny_1080p24.y4m"
SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__)))
def handbrake_present() -> bool:
"""Check if handbrake is present on the system"""
return os.path.isfile(Path(SCRIPT_DIR / HANDBRAKE_EXECUTABLE))
def copy_handbrake_from_network_drive():
"""copy handbrake cli from network drive"""
source = Path("\\\\Labs\\labs\\01_Installers_Utilities\\Handbrake\\X86\\HandBrakeCLI-1.8.1-win-x86_64\\")
copy_souce = source / HANDBRAKE_EXECUTABLE
destination = SCRIPT_DIR / HANDBRAKE_EXECUTABLE
shutil.copyfile(copy_souce, destination)
def is_video_source_present() -> bool:
"""check if big buck bunny video source is present"""
return os.path.isfile(Path(SCRIPT_DIR / SOURCE_VIDEO_NAME))
def copy_video_source():
"""copy big buck bunny source video to local from network drive"""
source = r"\\Labs\labs\03_ProcessingFiles\Handbrake Test\big_buck_bunny_1080p24.y4m"
root_dir = os.path.dirname(os.path.realpath(__file__))
destination = os.path.join(root_dir, SOURCE_VIDEO_NAME)
shutil.copyfile(source, destination)
def current_time_ms():
"""Get current timestamp in milliseconds since epoch"""
return int(time.time() * 1000)

13
handbrake/manifest.yaml Normal file
View File

@@ -0,0 +1,13 @@
friendly_name: "Handbrake"
executable: "handbrake.py"
process_name: "HandBrakeCLI.exe"
disable_presentmon: true
output_dir: run
options:
- name: preset
type: select
values:
- h264
- h265
- av1
tooltip: Select which preset to use

View File

@@ -0,0 +1,111 @@
{
"PresetList": [
{
"AlignAVStart": true,
"AudioCopyMask": [
"copy:aac"
],
"AudioEncoderFallback": "av_aac",
"AudioLanguageList": [],
"AudioList": [
{
"AudioBitrate": 160,
"AudioCompressionLevel": 0,
"AudioEncoder": "av_aac",
"AudioMixdown": "stereo",
"AudioNormalizeMixLevel": false,
"AudioSamplerate": "auto",
"AudioTrackQualityEnable": false,
"AudioTrackQuality": -1,
"AudioTrackGainSlider": 0,
"AudioTrackDRCSlider": 0
}
],
"AudioSecondaryEncoderMode": true,
"AudioTrackSelectionBehavior": "first",
"ChapterMarkers": true,
"ChildrenArray": [],
"Default": false,
"FileFormat": "av_mp4",
"Folder": false,
"FolderOpen": false,
"Optimize": false,
"Mp4iPodCompatible": false,
"PictureCropMode": 0,
"PictureBottomCrop": 0,
"PictureLeftCrop": 0,
"PictureRightCrop": 0,
"PictureTopCrop": 0,
"PictureDARWidth": 1920,
"PictureDeblockPreset": "off",
"PictureDeblockTune": "medium",
"PictureDeblockCustom": "strength=strong:thresh=20:blocksize=8",
"PictureDeinterlaceFilter": "decomb",
"PictureCombDetectPreset": "default",
"PictureCombDetectCustom": "",
"PictureDeinterlacePreset": "default",
"PictureDeinterlaceCustom": "",
"PictureDenoiseCustom": "",
"PictureDenoiseFilter": "off",
"PictureSharpenCustom": "",
"PictureSharpenFilter": "off",
"PictureSharpenPreset": "medium",
"PictureSharpenTune": "none",
"PictureDetelecine": "off",
"PictureDetelecineCustom": "",
"PictureColorspacePreset": "off",
"PictureColorspaceCustom": "",
"PictureChromaSmoothPreset": "off",
"PictureChromaSmoothTune": "none",
"PictureChromaSmoothCustom": "",
"PictureItuPAR": false,
"PictureKeepRatio": true,
"PicturePAR": "auto",
"PicturePARWidth": 1,
"PicturePARHeight": 1,
"PictureWidth": 1920,
"PictureHeight": 1080,
"PictureUseMaximumSize": true,
"PictureAllowUpscaling": false,
"PictureForceHeight": 0,
"PictureForceWidth": 0,
"PicturePadMode": "none",
"PicturePadTop": 0,
"PicturePadBottom": 0,
"PicturePadLeft": 0,
"PicturePadRight": 0,
"PresetDescription": "This is the standard preset for our CPU encoding test for AV1 Big Buck Bunny at 1080p",
"PresetName": "CPU 1080p BBB AV1",
"Type": 1,
"SubtitleAddCC": false,
"SubtitleAddForeignAudioSearch": true,
"SubtitleAddForeignAudioSubtitle": false,
"SubtitleBurnBehavior": "foreign",
"SubtitleBurnBDSub": false,
"SubtitleBurnDVDSub": false,
"SubtitleLanguageList": [],
"SubtitleTrackSelectionBehavior": "none",
"VideoAvgBitrate": 0,
"VideoColorMatrixCode": 0,
"VideoEncoder": "svt_av1",
"VideoFramerateMode": "cfr",
"VideoGrayScale": false,
"VideoScaler": "swscale",
"VideoPreset": "7",
"VideoTune": "",
"VideoProfile": "main",
"VideoLevel": "5.1",
"VideoOptionExtra": "",
"VideoQualityType": 2,
"VideoQualitySlider": 20,
"VideoMultiPass": true,
"VideoTurboMultiPass": true,
"x264UseAdvancedOptions": false,
"PresetDisabled": false,
"MetadataPassthrough": true
}
],
"VersionMajor": 53,
"VersionMicro": 0,
"VersionMinor": 0
}

View File

@@ -0,0 +1,111 @@
{
"PresetList": [
{
"AlignAVStart": true,
"AudioCopyMask": [
"copy:aac"
],
"AudioEncoderFallback": "av_aac",
"AudioLanguageList": [],
"AudioList": [
{
"AudioBitrate": 160,
"AudioCompressionLevel": 0,
"AudioEncoder": "av_aac",
"AudioMixdown": "stereo",
"AudioNormalizeMixLevel": false,
"AudioSamplerate": "auto",
"AudioTrackQualityEnable": false,
"AudioTrackQuality": -1,
"AudioTrackGainSlider": 0,
"AudioTrackDRCSlider": 0
}
],
"AudioSecondaryEncoderMode": true,
"AudioTrackSelectionBehavior": "first",
"ChapterMarkers": true,
"ChildrenArray": [],
"Default": false,
"FileFormat": "av_mp4",
"Folder": false,
"FolderOpen": false,
"Optimize": false,
"Mp4iPodCompatible": false,
"PictureCropMode": 0,
"PictureBottomCrop": 0,
"PictureLeftCrop": 0,
"PictureRightCrop": 0,
"PictureTopCrop": 0,
"PictureDARWidth": 1920,
"PictureDeblockPreset": "off",
"PictureDeblockTune": "medium",
"PictureDeblockCustom": "strength=strong:thresh=20:blocksize=8",
"PictureDeinterlaceFilter": "decomb",
"PictureCombDetectPreset": "default",
"PictureCombDetectCustom": "",
"PictureDeinterlacePreset": "default",
"PictureDeinterlaceCustom": "",
"PictureDenoiseCustom": "",
"PictureDenoiseFilter": "off",
"PictureSharpenCustom": "",
"PictureSharpenFilter": "off",
"PictureSharpenPreset": "medium",
"PictureSharpenTune": "none",
"PictureDetelecine": "off",
"PictureDetelecineCustom": "",
"PictureColorspacePreset": "off",
"PictureColorspaceCustom": "",
"PictureChromaSmoothPreset": "off",
"PictureChromaSmoothTune": "none",
"PictureChromaSmoothCustom": "",
"PictureItuPAR": false,
"PictureKeepRatio": true,
"PicturePAR": "auto",
"PicturePARWidth": 1,
"PicturePARHeight": 1,
"PictureWidth": 1920,
"PictureHeight": 1080,
"PictureUseMaximumSize": true,
"PictureAllowUpscaling": false,
"PictureForceHeight": 0,
"PictureForceWidth": 0,
"PicturePadMode": "none",
"PicturePadTop": 0,
"PicturePadBottom": 0,
"PicturePadLeft": 0,
"PicturePadRight": 0,
"PresetDescription": "This is the standard preset for our CPU encoding test for H264 Big Buck Bunny at 1080p.",
"PresetName": "CPU 1080p BBB H264",
"Type": 1,
"SubtitleAddCC": false,
"SubtitleAddForeignAudioSearch": true,
"SubtitleAddForeignAudioSubtitle": false,
"SubtitleBurnBehavior": "foreign",
"SubtitleBurnBDSub": false,
"SubtitleBurnDVDSub": false,
"SubtitleLanguageList": [],
"SubtitleTrackSelectionBehavior": "none",
"VideoAvgBitrate": 0,
"VideoColorMatrixCode": 0,
"VideoEncoder": "x264",
"VideoFramerateMode": "cfr",
"VideoGrayScale": false,
"VideoScaler": "swscale",
"VideoPreset": "slow",
"VideoTune": "",
"VideoProfile": "high",
"VideoLevel": "5.1",
"VideoOptionExtra": "",
"VideoQualityType": 2,
"VideoQualitySlider": 20,
"VideoMultiPass": true,
"VideoTurboMultiPass": true,
"x264UseAdvancedOptions": false,
"PresetDisabled": false,
"MetadataPassthrough": true
}
],
"VersionMajor": 53,
"VersionMicro": 0,
"VersionMinor": 0
}

View File

@@ -0,0 +1,111 @@
{
"PresetList": [
{
"AlignAVStart": true,
"AudioCopyMask": [
"copy:aac"
],
"AudioEncoderFallback": "av_aac",
"AudioLanguageList": [],
"AudioList": [
{
"AudioBitrate": 160,
"AudioCompressionLevel": 0,
"AudioEncoder": "av_aac",
"AudioMixdown": "stereo",
"AudioNormalizeMixLevel": false,
"AudioSamplerate": "auto",
"AudioTrackQualityEnable": false,
"AudioTrackQuality": -1,
"AudioTrackGainSlider": 0,
"AudioTrackDRCSlider": 0
}
],
"AudioSecondaryEncoderMode": true,
"AudioTrackSelectionBehavior": "first",
"ChapterMarkers": true,
"ChildrenArray": [],
"Default": false,
"FileFormat": "av_mp4",
"Folder": false,
"FolderOpen": false,
"Optimize": false,
"Mp4iPodCompatible": false,
"PictureCropMode": 0,
"PictureBottomCrop": 0,
"PictureLeftCrop": 0,
"PictureRightCrop": 0,
"PictureTopCrop": 0,
"PictureDARWidth": 1920,
"PictureDeblockPreset": "off",
"PictureDeblockTune": "medium",
"PictureDeblockCustom": "strength=strong:thresh=20:blocksize=8",
"PictureDeinterlaceFilter": "decomb",
"PictureCombDetectPreset": "default",
"PictureCombDetectCustom": "",
"PictureDeinterlacePreset": "default",
"PictureDeinterlaceCustom": "",
"PictureDenoiseCustom": "",
"PictureDenoiseFilter": "off",
"PictureSharpenCustom": "",
"PictureSharpenFilter": "off",
"PictureSharpenPreset": "medium",
"PictureSharpenTune": "none",
"PictureDetelecine": "off",
"PictureDetelecineCustom": "",
"PictureColorspacePreset": "off",
"PictureColorspaceCustom": "",
"PictureChromaSmoothPreset": "off",
"PictureChromaSmoothTune": "none",
"PictureChromaSmoothCustom": "",
"PictureItuPAR": false,
"PictureKeepRatio": true,
"PicturePAR": "auto",
"PicturePARWidth": 1,
"PicturePARHeight": 1,
"PictureWidth": 1920,
"PictureHeight": 1080,
"PictureUseMaximumSize": true,
"PictureAllowUpscaling": false,
"PictureForceHeight": 0,
"PictureForceWidth": 0,
"PicturePadMode": "none",
"PicturePadTop": 0,
"PicturePadBottom": 0,
"PicturePadLeft": 0,
"PicturePadRight": 0,
"PresetDescription": "This is the standard preset for our CPU encoding test for H265 Big Buck Bunny at 1080p",
"PresetName": "CPU 1080p BBB H265",
"Type": 1,
"SubtitleAddCC": false,
"SubtitleAddForeignAudioSearch": true,
"SubtitleAddForeignAudioSubtitle": false,
"SubtitleBurnBehavior": "foreign",
"SubtitleBurnBDSub": false,
"SubtitleBurnDVDSub": false,
"SubtitleLanguageList": [],
"SubtitleTrackSelectionBehavior": "none",
"VideoAvgBitrate": 0,
"VideoColorMatrixCode": 0,
"VideoEncoder": "x265",
"VideoFramerateMode": "cfr",
"VideoGrayScale": false,
"VideoScaler": "swscale",
"VideoPreset": "slow",
"VideoTune": "",
"VideoProfile": "main",
"VideoLevel": "5.1",
"VideoOptionExtra": "",
"VideoQualityType": 2,
"VideoQualitySlider": 20,
"VideoMultiPass": true,
"VideoTurboMultiPass": true,
"x264UseAdvancedOptions": false,
"PresetDisabled": false,
"MetadataPassthrough": true
}
],
"VersionMajor": 53,
"VersionMicro": 0,
"VersionMinor": 0
}