HandBrake


Recommended Posts

HandBrake is a video encoder. This container supports a GUI (RDP or web browser access) as well as a fully automated watch folder.


The container will be available in community applications shortly.

 

Put "--cap-add=SYS_NICE" into the "extra parameters" in the advanced settings of the container to allow HandBrake to be run at a lower priority.

 

Fully automated conversion: Drop files into the /watch directory, and they will be encoded into the /output directory.

 

Interactive user interface: Point your web browser to your server, port 8080, or point a remote desktop client to port 3389. Find your files in /media, and put the converted file in /media or /output.

 

For more information on usage: https://hub.docker.com/r/coppit/handbrake/

For source code: https://github.com/coppit/docker-handbrake

 

Note: I'm releasing this while sparklyballs reviews my pull requests. I will delete this container after those pull requests are accepted, to avoid unnecessarily forking the container space.

Edited by coppit
  • Upvote 3
Link to comment
On 4/24/2017 at 6:42 AM, McKentin said:

Is there a way to keep your release ?

I don't understand your question.

 

Edit: Oh, you're referring to my warning that it might go away. Yeah. I would only get rid of this one if Sparklyballs was as good or better. :-)

Edited by coppit
Link to comment
  • 3 weeks later...

Thanks for this container, @coppit! I swapped from sparklyballs as I could never get the hotfolder processing to work properly.

 

I think I've found a bug though, is anyone able to confirm they're seeing the same behaviour as me?

  1. Clean install of container, only set the folder mappings
  2. Container stops automatically (expected)
  3. Edit user and group ID in config/HandBrake.conf
  4. Start container. Starts up fine.
  5. Stop container.
  6. Edit preset in config/HandBrake.conf
  7. Start Container. Error. Container won't start.
  8. Revert change to config/HandBrake.conf
  9. Start Container. Error. Container won't start.

At this stage no matter what I do I can't get the container to start.

To restore functionality I have to delete config/HandBrake.conf and start over from step 3.

 

Funny thing is, if do the preset edit at step 3 together with the user/group edit, the container starts up fine.

It's like you only have one shot at editing config/HandBrake.conf, and subsequent edits will brake the container.

 

 

 

 

Link to comment
On 2017-05-12 at 9:23 AM, Jorgen said:

Thanks for this container, @coppit! I swapped from sparklyballs as I could never get the hotfolder processing to work properly.

 

I think I've found a bug though, is anyone able to confirm they're seeing the same behaviour as me?

  1. Clean install of container, only set the folder mappings
  2. Container stops automatically (expected)
  3. Edit user and group ID in config/HandBrake.conf
  4. Start container. Starts up fine.
  5. Stop container.
  6. Edit preset in config/HandBrake.conf
  7. Start Container. Error. Container won't start.
  8. Revert change to config/HandBrake.conf
  9. Start Container. Error. Container won't start.

At this stage no matter what I do I can't get the container to start.

To restore functionality I have to delete config/HandBrake.conf and start over from step 3.

 

Funny thing is, if do the preset edit at step 3 together with the user/group edit, the container starts up fine.

It's like you only have one shot at editing config/HandBrake.conf, and subsequent edits will brake the container.

 

 

I didn't do the exact same sequence but I ended up with the same result. I installed the container, which automatically stops. I modified the handbrake.conf and started it. It worked fine for about 48 hours.  I made no further changes. The container re-started today (backup of appdata) and now won't start. I get the following in the log:

 

*** Killing all processes...
*** Running /etc/my_init.d/00_config.sh...
*** Running /etc/my_init.d/01_user_config.sh...
usermod: no changes
usermod: no changes
usermod: no changes
*** Running /etc/my_init.d/02_app_config.sh...
*** Running /etc/my_init.d/start.sh...
Using existing configuration. May require editing.
[2017-05-14 08:52:42] User "user_99_100" already exists. Skipping creation of user and group...
[2017-05-14 08:52:42] Running command as user "user_99_100"...
Ensuring user and group exists
ln: failed to create symbolic link ‘/nobody/.config/ghb/handbrake’: File exists
*** /etc/my_init.d/start.sh failed with status 1

Edited by Kewjoe
Link to comment
So this one has a working Watching Folder?

Sure does. I think coppit outlined the changes to this watch folder in sparklyball's handbrake thread. This one is much more reliable, you can add new files at any time and they will be processed. With sparkly's I could only get it to process the first batch of added files.


Sent from my iPhone using Tapatalk
Link to comment
21 hours ago, Kewjoe said:

 

I didn't do the exact same sequence but I ended up with the same result. I installed the container, which automatically stops. I modified the handbrake.conf and started it. It worked fine for about 48 hours.  I made no further changes. The container re-started today (backup of appdata) and now won't start. I get the following in the log:

 

*** Killing all processes...
*** Running /etc/my_init.d/00_config.sh...
*** Running /etc/my_init.d/01_user_config.sh...
usermod: no changes
usermod: no changes
usermod: no changes
*** Running /etc/my_init.d/02_app_config.sh...
*** Running /etc/my_init.d/start.sh...
Using existing configuration. May require editing.
[2017-05-14 08:52:42] User "user_99_100" already exists. Skipping creation of user and group...
[2017-05-14 08:52:42] Running command as user "user_99_100"...
Ensuring user and group exists
ln: failed to create symbolic link ‘/nobody/.config/ghb/handbrake’: File exists
*** /etc/my_init.d/start.sh failed with status 1

 

That's the exact same error log I got previously.

I thought I had worked around it, but following this mornings appdata backup I'm in the same situation as you, container refuses to start.

hmm, maybe it's the appdata backup that's causing problems?

Link to comment
On 12/05/2017 at 11:23 PM, Jorgen said:

At this stage no matter what I do I can't get the container to start.

To restore functionality I have to delete config/HandBrake.conf and start over from step 3.

 

Apologies, I got that wrong. I can actually leave the file config/HandBrake.conf as it is after editing.

To get the container working again I have to delete the whole directory config/handbrake then just start the container.

The directory and files are recreated and it all works until next container restart (including scheduled appdata backups).

 

Link to comment
52 minutes ago, dlandon said:

The appdata/HandBrake folder is set to root:root ownership and not nobody:users.  The PUID and PGID settings need to be added to the docker template to set the permissions on the appdata/HandBrake folder properly (PUID=99, PGID=100) for unRAID.

 

appdata/Handbrake is set to 99:100 for me (It's possible that I've set this manually during troubleshooting)

The folder I have to delete to get it working again is: appdata/HandBrake/handbrake

That one is recreated on docker start and seems to have correct settings.

The PUID/GUID is set in the appdata/HandBrake/HandBrake.conf

root@Tower:/mnt/cache/appdata# ls -l | grep HandBrake
drwxrwxrwx  3 nobody users  117 May 15 22:22 HandBrake/
root@Tower:/mnt/cache/appdata# tree -plug /mnt/cache/appdata/HandBrake
/mnt/cache/appdata/HandBrake
├── [-rw-r--r-- nobody   users   ]  HandBrake.conf
├── [drwxr-xr-x nobody   users   ]  handbrake
│   ├── [-rw-r--r-- nobody   users   ]  Activity.log.92
│   ├── [-rw-r--r-- nobody   users   ]  ghb.pid.92
│   ├── [lrwxrwxrwx nobody   users   ]  handbrake -> /config/handbrake
│   ├── [-rw-r--r-- nobody   users   ]  preferences.json
│   └── [-rw-r--r-- nobody   users   ]  presets.json
└── [-rw-rw-rw- nobody   users   ]  processed_files.dat

 

I see that coppit is updating some files on github and it looks like the file that creates the error (/etc/my_init.d/start.sh) has been updated to remove the symlink to the handbrake config (which is part of what I'm deleteing) so maybe he's across the problem and solution already.

I'll just wait patiently for a container update...

Link to comment

It's working for me too after the update. Although i can't seem to get the watch folder working. I drop a video in there and nothing happens. This is my config file:

 

### Change monitoring settings

# If we don't see any events for $SETTLE_DURATION time, assume that it's safe to run HandBrake. Format is HH:MM:SS,
# with HH and MM optional.
SETTLE_DURATION=10

# However, if we see a stream of changes for longer than $MAX_WAIT_TIME with no break of $SETTLE_DURATION or more, then
# go ahead and run HandBrake. Otherwise we might be waiting forever for the directory to stop changing. Format is
# HH:MM:SS, with HH and MM optional.
MAX_WAIT_TIME=10:00

# After processing all the files in the watch dir, wait at least this long before doing it again, even if
# $SETTLE_DURATION time has passed after change. This controls the maximum frequency of the HandBrake runs.
MIN_PERIOD=0

# Set this to 1 to log all events, for debugging purposes. WARNING! This creates copious amounts of confusing logging!
DEBUG=0

# HandBrake doesn't write to the watch dir, so it's safe to keep watching for events.
IGNORE_EVENTS_WHILE_COMMAND_IS_RUNNING=0

#-----------------------------------------------------------------------------------------------------------------------

### HandBrake settings

# Run the program as this user and group ID, which should match up with the host. This will ensure that the resulting
# converted video has the right ownership and permissions.
# The defaults typically correspond to the "root" user in the host. To change these, run the following commands (which use the
# "nobody" user and group) in the host and set the values here.
# id -u nobody
# id -g nobody
# su -l nobody -c umask
USER_ID=99
GROUP_ID=100
UMASK=0000

# The command to run to convert the file. For a list of presets visit
# https://handbrake.fr/docs/en/latest/technical/official-presets.html
HANDBRAKE_COMMAND='HandBrakeCLI -i "$SRCDIR/$SUBDIR/$FILENAME" -o "$DESTDIR/$SUBDIR/$BASE.mp4" --preset "Super HQ 1080p30 Surround"'

 

Edited by Kewjoe
Link to comment

Worked Great. 

 

So am I to assume that after it rips a movie from the Watch Folder to the Output Folder it will periodically check for new files in the Watch Folder, but compare to already done files in the Output folder. Basically I have two copies of the same movie, but one is the original that resides in the Watch folder and the converted file in the Output folder. 

Link to comment

Something that is confusing me. 

I edited my /cache/appdata/Handbrake/Handbrake.conf to iPad2

 

I created a iPad2 preset because I want my files to be 1024x768 and now when I run this its not running. I checked my logs and its seeing the file hit the WatchFolder, but its skipping right over the files. I'm dropping files that are at least 1280x720 and it should be working. If its because of the custom preset how can I force the GUI to save any of the presets to 1024 since it keeps wanting to create new ones?

 

******Update******

Logs say iPad2 is an invalid preset.... How can you change the already set presets to a configuration that you actually need?

Link to comment
8 hours ago, kizer said:

Logs say iPad2 is an invalid preset.... How can you change the already set presets to a configuration that you actually need?

 

Hi Kizer, this is what I've done and it works for me:

 

1. From the HandBrake GUI, export your custom preset to a file and store it in your config folder. For example: appdata/HandBrake/mycustompreset.json

 

2. Edit the HANDBRAKE_COMMAND line in appdata/config/Handbrake.conf like this

Default Config

HANDBRAKE_COMMAND='HandBrakeCLI -i "$SRCDIR/$SUBDIR/$FILENAME" -o "$DESTDIR/$SUBDIR/$BASE.mp4" --preset "Very Fast 1080p30"'

New config

HANDBRAKE_COMMAND='HandBrakeCLI --import-preset-file /config/mycustompreset.json -i "$SRCDIR/$SUBDIR/$FILENAME" -o "$DESTDIR/$SUBDIR/$BASE.mp4" --preset "mycustompreset"'

IF your preset have spaces in the name, you need to enclose the name in double quotes.

More info here: https://handbrake.fr/docs/en/latest/cli/cli-guide.html

You should be able to import the preset directly from the GUI version with --import-preset-gui but I never got that to work. Plus I wanted my custom preset to be stored outside the container anyway, in case I have to re-install in the future.

 

Edited by Jorgen
Link to comment

@Jorgen

 

Thanks. I'll give that a try soon. Totally makes sense in what your saying. 

 

Knowing how picky Linux is I've always tried to keep things space proof so I'll just keep it simple and leave out spaces or do my favorite. this_is_how_I_use_spaces or this.is.how.I.use.spaces. 

 

 

I'm getting this when I run it via the Watcher. My custom file is in the same folder with the Handbrake.conf file in the /appdata/system/Handbrake/

 

152 (process ID) old priority 0, new priority 19
[10:25:28] hb_init: starting libhb thread
[10:25:28] thread 2b701f772700 started ("libhb")
unknown option (--import-preset-file)

 

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

 

Found the little mistake that was messing me up. the import and preset was swapped. Not a big deal you had me on the right direction and a little GoogleFu fixed it right up. :)

 

Old

HANDBRAKE_COMMAND='HandBrakeCLI --import-preset-file /config/mycustompreset.json -i "$SRCDIR/$SUBDIR/$FILENAME" -o "$DESTDIR/$SUBDIR/$BASE.mp4" --preset "mycustompreset"'

New

HANDBRAKE_COMMAND='HandBrakeCLI --preset-import-file /config/mycustompreset.json -i "$SRCDIR/$SUBDIR/$FILENAME" -o "$DESTDIR/$SUBDIR/$BASE.mp4" --preset "mycustompreset"'

 

Link to comment

Found the little mistake that was messing me up. the import and preset was swapped.


Oops, sorry about that. Wrote it from memory since copy-paste from ssh/mc to safari on an iPad proved a little bit too challenging... :)


Sent from my iPhone using Tapatalk
Link to comment
On 5/15/2017 at 7:48 AM, dlandon said:

The appdata/HandBrake folder is set to root:root ownership and not nobody:users.  The PUID and PGID settings need to be added to the docker template to set the permissions on the appdata/HandBrake folder properly (PUID=99, PGID=100) for unRAID.

 

Edit the USER_ID and GROUP_ID settings in the HandBrake.conf file. Setting them in the template might work, but I haven't tested it yet. Feel free to test it for me in the container config. :-)

 

AFAIK PUID and PGID are not standard. But if I'm wrong, let me know. My implementation uses USER_ID and GROUP_ID.

 

On 5/16/2017 at 7:47 AM, Jorgen said:

Latest update seem to have fixed this problem for me, thanks Coppit!

 

Yep. Sorry for the problem. Folks, yell if you're still having problems. AFAIK all known issues are fixed at this point.

 

On 5/17/2017 at 2:42 PM, Kewjoe said:

Although i can't seem to get the watch folder working. I drop a video in there and nothing happens.

 

What does the log say about it? It should say something like "change detected, waiting for folder to settle". My guess is that something is constantly writing to the folder, so that the detector is waiting for 10 minutes to elapse before giving up. You can set 10:00 to something shorter, but be aware that HandBrake might try to convert an incomplete file when the "give up" time elapses, but there is still writing going on. One thing I could do is detect when the file is open, and skip conversion of it.

 

On 5/17/2017 at 9:41 PM, kizer said:

So am I to assume that after it rips a movie from the Watch Folder to the Output Folder it will periodically check for new files in the Watch Folder, but compare to already done files in the Output folder.

 

When it sees new files, it looks at all of them. But it remembers files that were already processed before. (In the processed_files.dat file.) So if you want to reconvert a file, you have to either delete the processed_files.dat, or give it a different name.

 

On 5/18/2017 at 10:33 AM, kizer said:

I checked my logs and its seeing the file hit the WatchFolder, but its skipping right over the files.

 

If it already processed the files, it won't do it again. Try renaming a file.

 

On 5/18/2017 at 10:33 AM, kizer said:

Logs say iPad2 is an invalid preset.... How can you change the already set presets to a configuration that you actually need?

 

There's a simpler answer. The good news is that it looks like the GUI is already saving the preset changes to a file in your /config folder. So just edit HandBrake.conf to add an extra argument:

HANDBRAKE_COMMAND='HandBrakeCLI -i "$SRCDIR/$SUBDIR/$FILENAME" -o "$DESTDIR/$SUBDIR/$BASE.mp4" --preset-import-file /config/handbrake/presets.json -Z "Very Fast 1080p30"'

No need to export it yourself.
 

Link to comment
On 5/21/2017 at 0:22 PM, coppit said:

 

Edit the USER_ID and GROUP_ID settings in the HandBrake.conf file. Setting them in the template might work, but I haven't tested it yet. Feel free to test it for me in the container config. :-)

 

AFAIK PUID and PGID are not standard. But if I'm wrong, let me know. My implementation uses USER_ID and GROUP_ID.

 

 

Yep. Sorry for the problem. Folks, yell if you're still having problems. AFAIK all known issues are fixed at this point.

 

 

What does the log say about it? It should say something like "change detected, waiting for folder to settle". My guess is that something is constantly writing to the folder, so that the detector is waiting for 10 minutes to elapse before giving up. You can set 10:00 to something shorter, but be aware that HandBrake might try to convert an incomplete file when the "give up" time elapses, but there is still writing going on. One thing I could do is detect when the file is open, and skip conversion of it.

 

 

When it sees new files, it looks at all of them. But it remembers files that were already processed before. (In the processed_files.dat file.) So if you want to reconvert a file, you have to either delete the processed_files.dat, or give it a different name.

 

 

If it already processed the files, it won't do it again. Try renaming a file.

 

 

There's a simpler answer. The good news is that it looks like the GUI is already saving the preset changes to a file in your /config folder. So just edit HandBrake.conf to add an extra argument:


HANDBRAKE_COMMAND='HandBrakeCLI -i "$SRCDIR/$SUBDIR/$FILENAME" -o "$DESTDIR/$SUBDIR/$BASE.mp4" --preset-import-file /config/handbrake/presets.json -Z "Very Fast 1080p30"'

No need to export it yourself.
 

 

Sorry for my off topic, 

if I use video codec H.265 (x265) it uses 65-75% CPU, and if I use video codec H.264(x264), it uses 100% CPU. How to reduce CPU used, when I want to encode video with  H.264(x264) codec.

Thanks

Link to comment
4 hours ago, thanhtran said:

How to reduce CPU used, when I want to encode video with  H.264(x264) codec.

 

Encoding is inherently CPU intensive. You can use one of the fast presets, which will shorten the encode time. You can also make sure that --cap-add=SYS_NICE is set under extra parameters. This will let other processes take priority over the encode, so that even if it's using 100% CPU you shouldn't notice any difference for other things.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.