{"id":13613676,"url":"https://github.com/Kidsnd274/Av1anStaxRipWrapper","last_synced_at":"2025-04-13T15:33:43.930Z","repository":{"id":65100784,"uuid":"576693616","full_name":"Kidsnd274/Av1anStaxRipWrapper","owner":"Kidsnd274","description":"Wrapper script to use Av1an with StaxRip","archived":false,"fork":false,"pushed_at":"2024-06-30T17:50:14.000Z","size":105,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-02T20:45:43.206Z","etag":null,"topics":["aomenc","av1-codec","av1an","ffmpeg","python-script","rav1e","staxrip","svt-av1","video"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kidsnd274.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-10T17:15:46.000Z","updated_at":"2024-07-01T05:12:46.000Z","dependencies_parsed_at":"2024-01-16T23:30:34.330Z","dependency_job_id":"39c8ea99-ea56-4229-90df-051ccfbf2dda","html_url":"https://github.com/Kidsnd274/Av1anStaxRipWrapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kidsnd274%2FAv1anStaxRipWrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kidsnd274%2FAv1anStaxRipWrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kidsnd274%2FAv1anStaxRipWrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kidsnd274%2FAv1anStaxRipWrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kidsnd274","download_url":"https://codeload.github.com/Kidsnd274/Av1anStaxRipWrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223592697,"owners_count":17170547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aomenc","av1-codec","av1an","ffmpeg","python-script","rav1e","staxrip","svt-av1","video"],"created_at":"2024-08-01T20:00:52.502Z","updated_at":"2024-11-07T21:31:29.205Z","avatar_url":"https://github.com/Kidsnd274.png","language":"Python","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# Av1anStaxRipWrapper\nPython wrapper script to use Av1an with StaxRip\n\n[Av1anStaxRipWrapperRav1e](README_RAV1E.md) (OUTDATED rav1e specialized script README)\\\n[INSTALL AND USAGE GUIDE (YouTube)](https://youtu.be/a7IPQcNVwTY)\n\n## Contents\n- [Av1anStaxRipWrapper](#av1anstaxripwrapper)\n  - [Contents](#contents)\n  - [Usage](#usage)\n  - [Requirements](#requirements)\n  - [Setup](#setup)\n    - [Portable Installation (Recommended)](#portable-installation-recommended)\n    - [Alternative Installation (install tools to system PATH)](#alternative-installation-install-tools-to-system-path)\n  - [Command Line Options](#command-line-options)\n  - [Automatic Thread Detection](#automatic-thread-detection)\n  - [Override Worker Count and Threads Per Local Machine](#override-worker-count-and-threads-per-local-machine)\n    - [Setting the override worker count](#setting-the-override-worker-count)\n    - [Check to see if it's working](#check-to-see-if-its-working)\n    - [Structure of override-workers.json](#structure-of-override-workersjson)\n\n## Usage\nThis script makes use of the Command Line option in StaxRip. There are some required arguments needed in the command that allows Av1an to work with StaxRip. Namely `-i \"%source_file%\" -o \"%encoder_out_file%\" -t \"%temp_dir%av1an_temp\"`. `-s \"%startup_dir%\"` is needed if you want a portable installation. Portable installation is described in more detail at the [Setup](#setup) section.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1343896/209460663-fa6ac57b-ec77-48d7-b993-ba67bf0d56a1.png\" alt=\"staxrip_image\" width=\"500\"/\u003e\n\nA good starting command would be:\n\n```\n\"%startup_dir%\\Apps\\Encoders\\Av1anStaxRipWrapper\\VapourSynth\\python.exe\" \"%startup_dir%\\Apps\\Encoders\\Av1anStaxRipWrapper\\Av1anStaxRipWrapper.py\" -s \"%startup_dir%\" -i \"%source_file%\" -o \"%encoder_out_file%\" -t \"%temp_dir%av1an_temp\" --pix-format yuv420p10le -e rav1e --photon-noise 2 --chroma-noise --sc-downscale-height 540 -v \"--quantizer 60 --speed 6 --tiles 2 --threads 2\"\n```\nEverything after the `-t` parameter will affect the encoding parameters (either Av1an or the selected encoder). Refer to [Command Line Options](#command-line-options) section for more information.\n\nThis starting command uses the rav1e encoder and uses the encoding parameters passed in by the argument `-v`.\n\n## Requirements\n- [ffmpeg](https://ffmpeg.org/download.html) (with shared libraries) (Av1an requirement)\n- [aomenc](https://aomedia.googlesource.com/aom/) or\n- [rav1e](https://github.com/xiph/rav1e/releases) or\n- [SVT-AV1](https://gitlab.com/AOMediaCodec/SVT-AV1)\n- [StaxRip](https://github.com/staxrip/staxrip/releases)\n\nThis script also requires the `psutil` module in Python to automatically detect CPU core counts to pass into av1an.\n - You can run with the `--disable-automatic-thread-detection` flag to disable this feature and requirement\n\n## Setup\n### Portable Installation (Recommended)\nSince Av1an requires `ffmpeg`, `aomenc` or `rav1e` or `SVT-AV1`, `VapourSynth` to be in PATH, this script can automatically help you add important folders (from StaxRip) temporarily to PATH when it's being run (for portable installation). In this way, your actual system PATH is not affected when running Av1an. However, this means that you need to install the tools in specific folders in StaxRip as the wrapper script looks for them there.\n\nPortable mode is enabled when the `-s` flag is used with the StaxRip startup directory.\n\n1. **Clone** this repository (or download the files) into `StaxRip\\Apps\\Encoders\\Av1anStaxRipWrapper`\n\nYou can run `git clone https://github.com/Kidsnd274/Av1anStaxRipWrapper.git\"` in `StaxRip\\Apps\\Encoders`\n\n2. Ensure encoders, **Av1an and the wrapper script** are extracted in the right directories\n - Av1an: `StaxRip\\Apps\\Encoders\\Av1an` (IMPORTANT)\n - aomenc: `StaxRip\\Apps\\Encoders\\aomenc`\n - rav1e: `StaxRip\\Apps\\Encoders\\rav1e`\n - SVT-AV1: `StaxRip\\Apps\\Encoders\\SVT-AV1` or `StaxRip\\Apps\\Encoders\\SVT-AV1\\SvtAv1EncApp`\n - FFMPEG: `StaxRip\\Apps\\Encoders\\Av1an` (moving it to an `ffmpeg` folder would interfere with StaxRip's own ffmpeg)\n - Wrapper Script: `StaxRip\\Apps\\Encoders\\Av1anStaxRipWrapper`\n3. Run the `setup_py_vp_environment.bat` script from the Av1anStaxRipWrapper folder to install required Python modules and VapourSynth plugins\n4. Use the **Command Line** encoder profile to create an Av1an Encoder Profile\n\u003cimg src=\"https://user-images.githubusercontent.com/1343896/209458682-9e42b62f-22d2-4efb-a84d-47da50c1921f.png\" alt=\"staxrip_image\" width=\"200\"/\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/1343896/209460663-fa6ac57b-ec77-48d7-b993-ba67bf0d56a1.png\" alt=\"staxrip_image\" width=\"500\"/\u003e\n\nGood starting command (v2.40.0 and above):\n```\n\"%startup_dir%\\Apps\\Encoders\\Av1anStaxRipWrapper\\VapourSynth\\python.exe\" \"%startup_dir%\\Apps\\Encoders\\Av1anStaxRipWrapper\\Av1anStaxRipWrapper.py\" -s \"%startup_dir%\" -i \"%source_file%\" -o \"%encoder_out_file%\" -t \"%temp_dir%\\av1an_temp\" --pix-format yuv420p10le -e rav1e --photon-noise 2 --chroma-noise --sc-downscale-height 540 -v \"--quantizer 60 --speed 6 --tiles 2 --threads 2\"\n```\nBelow v2.40.0\n```\n\"%startup_dir%\\Apps\\Encoders\\Av1anStaxRipWrapper\\VapourSynth\\python.exe\" \"%startup_dir%\\Apps\\Encoders\\Av1anStaxRipWrapper\\Av1anStaxRipWrapper.py\" -s \"%startup_dir%\" -i \"%source_file%\" -o \"%encoder_out_file%\" -t \"%temp_dir%av1an_temp\" --pix-format yuv420p10le -e rav1e --photon-noise 2 --chroma-noise --sc-downscale-height 540 -v \"--quantizer 60 --speed 6 --tiles 2 --threads 2\"\n```\n\n**IMPORTANT**: Make sure to change **Output File Type** to `mkv`!\n\n5. Save this Encoder Profile with the name `AV1 | av1an`, and it will appear in the AV1 drop-down menu.\n![image](https://user-images.githubusercontent.com/1343896/209458707-bca3edda-36af-4d3d-b4a5-899160a5e8d9.png)\n\n\n### Alternative Installation (install tools to system PATH)\nBasically, just make sure `Av1an`, `ffmpeg`, `aomenc`, `rav1e`, `SVT-AV1`, `Python`, `VapourSynth` are all accessible from PATH and follow the steps above from Step 2.\n\nThe command in StaxRip used is\\\n`python \"%startup_dir%\\Apps\\Encoders\\Av1anStaxRipWrapper\\Av1anStaxRipWrapperRav1e.py\" -i \"%source_file%\" -o \"%encoder_out_file%\" -t \"%temp_dir%av1an_temp\" --pix-format yuv420p10le -e rav1e --photon-noise 2 --chroma-noise --sc-downscale-height 540 -v \"--quantizer 60 --speed 6 --tiles 2 --threads 2\"`\n\n## Command Line Options\n```\noptions:\nAv1an wrapper for StaxRip\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --version             Print Av1an, ffmpeg and the encoders' versions\n  -i INPUT              Input File (for StaxRip)\n  -o OUTPUT             Output File (for StaxRip)\n  -t TEMPDIR            Temp Directory (for StaxRip)\n  -s STAXRIP_STARTUP_DIR, --staxrip-startup-dir STAXRIP_STARTUP_DIR\n                        Specify StaxRip Startup Directory so that the wrapper script will automatically add important\n                        folders to PATH for av1an to detect (only needed for portable installations)\n\n# Av1an parameters\n  -e ENCODER, --encoder ENCODER\n                        Video encoder to use. [default: aom][possible values: aom, rav1e, vpx, svt-av1, x264, x265]\n  -v ENCODER_ARGS, --video-params ENCODER_ARGS\n                        Arguments passed to video encoder\n  -a OTHER_ARGS, --other-args OTHER_ARGS\n                        Other Av1an arguments\n  -f FFMPEG_OPTIONS, --ffmpeg FFMPEG_OPTIONS\n                        FFmpeg filter options\n  --photon-noise PHOTON_NOISE\n                        Generates a photon noise table and applies it using grain synthesis [strength: 0-64] (disabled\n                        by default) (Av1an parameter)\n  --chroma-noise        Adds chroma grain synthesis to the grain table generated by `--photon-noise`. (Default: false)\n                        (Av1an parameter)\n  --sc-downscale-height SC_DOWNSCALE_HEIGHT\n                        Optional downscaling for scene detection. By default, no downscaling is performed. (Av1an\n                        parameter)\n  --pix-format PIX_FORMAT\n                        FFmpeg pixel format\n\n# Threading parameters (Using any of these would disable the wrapper's Automatic Thread Detection feature)\n  --workers WORKERS     Number of workers to spawn [0 = automatic] (Av1an Paramter)\n  --set-thread-affinity SET_THREAD_AFFINITY\n                        Pin each worker to a specific set of threads of this size (disabled by default) (Av1an\n                        parameter)\n  --disable-automatic-thread-detection\n                        Disable the wrapper's automatic thread detection\n  --set-worker-override\n                        Set the override workers count and thread affinity count for local computer\n```\n\n## Automatic Thread Detection\nIn my testing, I found that I get the best utilization and encoding speeds when creating the same number of workers as the number of physical cores available in your system. Along with having the number of threads per worker be 2 if your system supports hyperthreading/SMT and 1 if your system does not.\n\nWith automatic thread detection, the wrapper script will automatically detect and pass in the relevant parameters to Av1an. For example,\n\n```\nRyzen 7 5800X\n  Physical Cores: 8 cores\n  Logical Cores: 16 cores\n  Hyperthreading/SMT: Enabled\n  Threading Parameters: --workers 8 --set-thread--affinity 2\n  \nIntel i5-6600K\n  Physical Cores: 4 cores\n  Logical Cores: 4 cores\n  Hyperthreading/SMT: Disabled\n  Threading Parameters: --workers 4 --set-thread-affinity 1\n```\n\nIf your system uses an Intel 12th Gen chip and above (with the new hybrid architecture with P-cores and E-cores), this feature is disabled.\n\nIf you do not want to use this feature, you can use the `--disable-automatic-thread-detection` flag or any of the Threading parameters under [Command Line Options](#command-line-options). Using any the Threading parameters would disable this feature.\n\n## Override Worker Count and Threads Per Local Machine\nWhen using StaxRip in a networked environment (where multiple computers access the same StaxRip install), you might want to override the Automatic Thread Detection feature for some computers, but not affect other machines. This feature allows you to do so without modifying the command line option, by storing a configuration file in a local computer.\n\n* Note that this will override the `--workers` and `--set-thread-affinity` flags for the script. If you include these flags in the `--other-args` flag, both of them will be sent to Av1an. Not sure what will happen there but you are welcome to find out.\n\n### Setting the override worker count\nTo set the override feature, run the script with the `--set-worker-override` flag.\n```\npython Av1anStaxRipWrapper.py --set-worker-override\n```\nFollow the instructions shown in the cmd window and the script should store a configuration file in this location. `%LOCALAPPDATA%\\Av1anStaxRipWrapper\\override-workers.json`\n\n### Check to see if it's working\nThe next time a job is being run, the script will show in its logs that the override file is found. For example:\n```\n=================================================\nAv1anStaxRipWrapper\nhttps://github.com/Kidsnd274/Av1anStaxRipWrapper\n=================================================\n[INFO] Found override-workers.json\n[INFO] Overriding CPU Workers = 4 and CPU Thread Affinity = 2\n[INFO] Automatic Thread Detection Disabled\nTHREADING INFORMATION:\n  Automatic Thread Detection: DISABLED\nStarting av1an... Check new console window for progress\n```\n\n### Structure of override-workers.json\nThe json file stores two keys for worker count and thread affinity (at the moment both keys must exist). The values must be in integers.\nExample:\n```\n{\n    \"cpu_workers\": 4,\n    \"cpu_thread_affinity\": 4\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKidsnd274%2FAv1anStaxRipWrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKidsnd274%2FAv1anStaxRipWrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKidsnd274%2FAv1anStaxRipWrapper/lists"}