Tdarr icon indicating copy to clipboard operation
Tdarr copied to clipboard

Add support for encoding using Av1an

Open lordkitsuna opened this issue 4 years ago • 7 comments

Is your feature request related to a problem? sort of, the problem is encoding with ffmpeg with av1 does not make use of all cpu. this is a limit of some of the av1 options nothing thread options can fix. Av1an fixes this by chunking out the file and encoding those chunks with different workers to make sure all cpu is used.

Describe the solution you'd like the ability to give the command i wish to have used and have TDarr call apon av1an for the encoding

Describe alternatives you've considered living with libaom shortcomings, doing av1an by hand, encoding enough things at the same time to achieve full cpu use

av1an can be found here https://github.com/master-of-zen/Av1an

lordkitsuna avatar Oct 22 '21 05:10 lordkitsuna

This, and having the possibility to provide custom av1an executable as some people use a custom fork of aomenc with av1an :D

Extarys avatar Feb 09 '22 00:02 Extarys

Bumping this to see if any devs have a reply

5731la avatar Mar 31 '22 12:03 5731la

I've been speaking to master of zen since last summer or so lol so very familiar with the project.

The issue is Av1an requires quite a few extra dependencies, whereas I like to keep Tdarr running cross-platform out of the box as much as possible so not really sure if it fits in atm.

HaveAGitGat avatar Apr 22 '22 17:04 HaveAGitGat

I've been speaking to master of zen since last summer or so lol so very familiar with the project.

The issue is Av1an requires quite a few extra dependencies, whereas I like to keep Tdarr running cross-platform out of the box as much as possible so not really sure if it fits in atm.

What if it was put in as an "optional addon" and getting deps installed was on us? So rather than include the entire project just include the ability to call it should we have it installed?

lordkitsuna avatar Apr 22 '22 18:04 lordkitsuna

Can use any cli you like in next version (2.00.20), can try here:

docker pull haveagitgat/tdarr_acc:dev_2.00.20_2023_03_07T09_59_51z
docker pull haveagitgat/tdarr_node_acc:dev_2.00.20_2023_03_07T09_59_51z

So plugin would look like this:

// eslint-disable-next-line no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
  const lib = require('../methods/lib')();
  // eslint-disable-next-line no-unused-vars,no-param-reassign
  inputs = lib.loadDefaultValues(inputs, details);
  const response = {
    processFile: false,
    preset: '',
    container: '',
    handbrakeMode: false,
    ffmpegMode: false,
    reQueueAfter: false,
    infoLog: '',
    custom: {
      args: [],
      cliPath: '',
      outputPath: ','
    }
  };

  const parts = otherArguments.cacheFilePath.split('.');

  // replace output container with mp4
  parts[parts.length - 1] = 'mp4';
  const output = parts.join('.');
  response.custom.outputPath = output;

  response.custom.cliPath = "C:/Users/H/Downloads/av1an.exe"
  response.custom.args = [
    '-i',
    `${file.file}`,
    '-v', '--cpu-used=3 --end-usage=q --cq-level=30 --threads=8',
    '-o',
      `${output}`,
  ]





  response.processFile = true;
  response.infoLog += 'File is being transcoded using custom arguments \n';
  return response;
};

otherArguments.cacheFilePath is a suggested/auto generated cache file but can make it anything you like. Just have to make sure to put the output file in both your custom transcode arguments and response.custom.outputPath so that Tdarr knows where the new file will be (without having to account for syntax of all the CLIs out there)

HaveAGitGat avatar Mar 07 '23 18:03 HaveAGitGat

I'm using Av1an mostly with the docker image to avoid the dependency nightmare (av1an:master), can we put in response.custom.cliPath something like docker run --privileged -v "$(pwd)":/videos --user $(id -u):$(id -g) -it --rm av1an:master ?

Extarys avatar Mar 09 '23 00:03 Extarys

Yep that should work

HaveAGitGat avatar Mar 09 '23 20:03 HaveAGitGat