GithubHelp home page GithubHelp logo

paddywaan / handbrake-daemon Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 216 KB

A daemon for HandBrakeCLI which watches directories and queues files for processing.

License: GNU General Public License v2.0

C# 76.36% Shell 21.70% Batchfile 0.23% Dockerfile 1.72%
handbrake linux windows watcher inotify transcoder handbrake-cli daemon docker systemd service

handbrake-daemon's Introduction

HandBrake-daemon

HandBrake-daemon is a cross platform (Windows, Linux) directory watcher service for HandBrakeCLI. Multiple watchers can be specified, which will queue and process media.

I am not a professional and this is my first attempt at maintaining a project, writing a service, and writing software for Linux, however I will do my best to resolve issues when they are reported. PR's, suggestions and comments are welcome.


Change log

v1.1.0

  • Added docker support and build process.
  • Added ability to specify default profiles(by name) in the profilePath configuration.

v1.0.0 - Release.

  • Watch configurations can be added via the config file.
  • Supports multiple watches.
  • Watches support a source, destination, and origin settings.
  • Watches can be individually customised to use different HandBrake encoding profiles via the profilePath setting.
  • Watches can be configured to place the output media inside of a nested, episode directory structure. i.e. /DestinationDirectory/TitleName/Season #/output.mp4
  • Watcher service scans the watched directories on start, and continues to watch the locations for new, and removed files.
  • Subtitles matching the source name (and/or extending the name with a language, or contained within a subdirectory named subs), will be embedded inside the output media.

Prerequisites

HandBrake-CLI must be added to $PATH (Windows platforms require handbrake to be added under system rather than user level environment variables): Linux, Windows 10.

Afterwards, you must either restart (windows) or source ~/.*rc, depending on which shell you use.


Linux Installation & Upgrade

Automatic method
  • Verify the contents of install.sh
  • Run the follwing command in a terminal emulator of your liking:
sudo bash -c "$(curl -s -L https://raw.githubusercontent.com/paddywaan/HandBrake-daemon/master/HandBrake-daemon/install.sh)"
Manual method

Download the zip and extract, then run the install.sh after verifying its contents. The install script will move the necessary config files to their appropriate locations.

Linux Automatic Removal / Uninstall
  • Verify the contents of uninstall.sh
  • Run the follwing command in a terminal emulator of your liking:
sudo bash -c "$(curl -s -L https://raw.githubusercontent.com/paddywaan/HandBrake-daemon/master/HandBrake-daemon/uninstall.sh)"

Windows Installation

Download and extract the zip to the desired location, then run install.cmd as administrator to register the binary as a system service. You may now manipulate the service via services.msc

Docker Installation

The docker image hes been setup to automatically create some directories and apply configurations, so you may leave the guest mountpoint /mnt/handbrake untouched if you do not have specific mounting requirements. Set the host location to be mounted and ensure the host directory exists, then run the following:

docker pull paddywaan/handbrakedaemon
sudo docker run -d -it --name handbrakedaemon -v /Host/Mount/Location:/mnt/handbrake paddywaan/handbrakedaemon handbrake-daemon

Nagivate to /Host/Mount/Location and two files, appsettings.json and handbrake-daemon.conf will have been created, alongside 3 directories. The config has been setup to automatically provide a working configuration with preset directory structure.

Restart the docker container using sudo docker restart handbrakedaemon

CAUTION: Moving files from an NTFS host will not trigger INotify on the guest system. The guest system must have the files moved or created within the context of the guest, or an ext4FS in order that INotify is triggered (This is what does the legwork for active directory watching).


Configuration

Linux platforms store the configuration in /etc/handbrake-daemon.conf Windows platforms store the configuration in the installation/extracted directory.

At least a single watcher must be defined in order for the service to run. Please make sure that you create all referenced directories and profiles with appropriate permissions before running the service

  • The source directory is used as the directory to watch for new media to process, and upon completion the output will be placed inside the destination directory.
  • If an origin directory is specified, the source file will be moved to the Original Media directory. If none is specified, the source will be deleted rather than moved.
  • Watchers will only queue file extensions which are defined in the watch config. If none are specified, they default to mp4,mkv,avi
  • Transcode settings are taken from the profilePath, which references a .json file containing a custom preset which may be exported from HandBrake's desktop UI, or if the built-in profiles are satisfactory, you may use HandBrakeCLI -z to list all available profile titles. Simply replace the profile path with the title, inclusive of spaces, no escape sequences are required.
  • The isShow boolean can be set to true in order to nest the output media inside subdirectories to aid organization of seasonal content.

Finally, you may start the service for the first time:

Windows: sc start HandBrake-daemon

Linux: sudo systemctl start handbrake-daemon.service

When you are happy with the configuration, you can enable the daemon on boot via: sudo systemctl enable handbrake-daemon.service


Logging

Linux: Logging verbosity can be changed via setting the default level in appsettings.json: Debug, Information, Warning, Error, Critical. By default, the level is set to Information, and the .json is stored alongside the binary in /usr/local/bin/ unless an alternative WorkingDirectory is specified inside the .service unit. The logs are stored at /var/log/handbrake-daemon.log by default, and an updated progress% on the current encode can be seen via: tail -f /var/log/handbrake-daemon.log.

Windows: Logging verbosity can be changed via setting the default level for the EventLog section in appsettings.json: Debug, Information, Warning, Error, Critical. By default the level is set to Information, and the logs are stored inside EventViewer: Application, under the source: HandBrake-daemon

handbrake-daemon's People

Contributors

dusbus avatar paddywaan avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

handbrake-daemon's Issues

[BUG] The profile name is not quoted when used

If you have a profile name like "High Profile Bluray mkv strong"
Then the command line supplied looks like this
--preset-import-file "/home/BLAH//High Profile Bluray mkv strong x265.json" -Z High Profile Bluray mkv strong x265

It should be
--preset-import-file "/home/BLAH//High Profile Bluray mkv strong x265.json" -Z "High Profile Bluray mkv strong x265"

PS: Thanks for this project.

[FEATURE] Suspend transcode if configurable process is detected.

Is your feature request related to a problem? Please describe.
Media transcodes can impact performance on other services, regardless of thread priority being set to minimum.

Describe the solution you'd like
Adding the option to configure a binary name which when detected will suspend the transcoding process would resolve such issues.

Describe alternatives you've considered
Another alternative is to prevent further queuing of media items, however would not resolve the immediate issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.