[Support] Djoss - HandBrake


Recommended Posts

14 hours ago, Djoss said:
On ‎3‎/‎12‎/‎2019 at 4:36 PM, chris_netsmart said:

I also like to know how I can monitor the progress of a converting file which I have place in the watch folder, as when I go to handbrake and click on queue or activity, it is not clear on want file it is doing.

You can see the progress in the container's log.  On the Docker page, click the icon in the last column.

 

are we talking about the Activity Icon ?

 

Quote

Ok, so what you would like to do exactly? You don't want to re-encode all downloaded files?

yes some of the files that I am download are MKV files which when Handbrake try's to convert are failing, and I would like to excluded them, also any NFO, Jpegs, Gifs, Txt, Thumbnails etc.   only files like AVI, Mp4,

Link to comment
9 hours ago, chris_netsmart said:

are we talking about the Activity Icon ?

On the Docker page, where all the containers are listed, there is a column "Log".  It contains an icon you can click.

9 hours ago, chris_netsmart said:

yes some of the files that I am download are MKV files which when Handbrake try's to convert are failing, and I would like to excluded them, also any NFO, Jpegs, Gifs, Txt, Thumbnails etc.   only files like AVI, Mp4,

You could try to use a pre-conversion hook (https://github.com/jlesage/docker-handbrake#hooks) to either remove an unwanted file or to move it directly to the output folder.

 

Link to comment
13 hours ago, Djoss said:

 

You could try to use a pre-conversion hook (https://github.com/jlesage/docker-handbrake#hooks) to either remove an unwanted file or to move it directly to the output folder.

 

thanks for the advice, I have looked at the pre_conversion.sh.example file and I can't make head or tails of it, I have also tried to find examples or tutorial on it, but I can't.

 

can you please point me to a good source of information on how to use the hooks.

Link to comment

Since hooks are all the rage at the moment, I’ll throw my question into the ring as well! :)

At the end of each conversion I want to check if the watch folder is empty and if it is, shut down the container.
I know I can do the first bit with a post processing hook, but is it possible to stop the container from the container shell? If it is, what’s the command?



Sent from my iPhone using Tapatalk

Link to comment
40 minutes ago, Jorgen said:

Since hooks are all the rage at the moment, I’ll throw my question into the ring as well! :)

At the end of each conversion I want to check if the watch folder is empty and if it is, shut down the container.
I know I can do the first bit with a post processing hook, but is it possible to stop the container from the container shell? If it is, what’s the command?



Sent from my iPhone using Tapatalk

Might be of use?

https://github.com/phusion/baseimage-docker/issues/451

Link to comment
6 hours ago, chris_netsmart said:

thanks for the advice, I have looked at the pre_conversion.sh.example file and I can't make head or tails of it, I have also tried to find examples or tutorial on it, but I can't.

 

can you please point me to a good source of information on how to use the hooks.

Hooks are simple shell scripts that are executed by the automatic video converter.  To enable the hook, you just need to add a shell script at the right location.  First copy the example hook:

cp /mnt/usr/appdate/HandBrake/hooks/pre_conversion.sh.example /mnt/usr/appdate/HandBrake/hooks/pre_conversion.sh

Then you can edit /mnt/user/appdata/HandBrake/hooks/pre_conversion.sh and do what ever you want.  Here is an example of what I think you try to achieve:

#!/bin/sh
#
# This is an example of a pre-conversion hook.  This script is always invoked
# with /bin/sh (shebang ignored).
#
# The first parameter is the full path where the video will be converted.
#
# The second parameter is the full path to the source file.
#
# The third argument is the name of the HandBrake preset that will be used to
# convert the video.
#

CONVERTED_FILE="$1"
SOURCE_FILE="$2"
PRESET="$3"

echo "pre-conversion: Output File = $CONVERTED_FILE"
echo "pre-conversion: Source File = $SOURCE_FILE"
echo "pre-conversion: Preset = $PRESET"

EXTENSION="$(echo "${SOURCE_FILE##*.}" | tr '[:upper:]' '[:lower:]')"
case "$EXTENSION" in
    avi|mp4)
        # Nothing to do.  Allow conversion of known video files.
        echo "pre-conversion: allowing file conversion."
        ;;
    mkv)
        # Do not convert MKVs.  Move the file to its final destination.
        EXTENSION="$(echo "${CONVERTED_FILE##*.}" | tr '[:upper:]' '[:lower:]')"
        if [ "$EXTENSION" = "mkv" ]; then
            echo "pre-conversion: file conversion not required, moving file."
            mkdir -p "$(dirname "$CONVERTED_FILE")"
            mv "$SOURCE_FILE" "$CONVERTED_FILE"
        else
            echo "ERROR: Destination file has unexpected extension '$EXTENSION'."
        fi
        ;;
    *)
        # Remove unknown files.
        echo "pre-conversion: preventing file conversion by removing file."
        rm "$SOURCE_FILE"
esac

I hope this help.

  • Like 1
Link to comment
1 hour ago, Jorgen said:

but is it possible to stop the container from the container shell?

 

1 hour ago, cybrnook said:

 

The automatic video converter and hooks run under a non-privileged user, so killing process id 1 won't work.  However, since exiting HandBrake also terminate the container, this should work:

killall -sigterm ghb

 

  • Like 2
Link to comment
 
The automatic video converter and hooks run under a non-privileged user, so killing process id 1 won't work.  However, since exiting HandBrake also terminate the container, this should work:
killall -sigterm ghb

 



Great, thanks to both of you!


Sent from my iPhone using Tapatalk
Link to comment
15 hours ago, Jorgen said:

At the end of each conversion I want to check if the watch folder is empty and if it is, shut down the container. 
I know I can do the first bit with a post processing hook, but is it possible to stop the container from the container shell? If it is, what’s the command?

 

13 hours ago, Djoss said:

The automatic video converter and hooks run under a non-privileged user, so killing process id 1 won't work.  However, since exiting HandBrake also terminate the container, this should work:


killall -sigterm ghb

 

 

Ok, "killall -sigterm ghb" works well, at least when running manually in the container shell.

But I've run into another problem. The post-conversion hook runs before the watch folder is cleaned up, so I can't look for an empty folder.

[autovideoconverter] Executing post-conversion hook...
post-conversion: Status = 0
post-conversion: Output File = /output/movie.mkv
post-conversion: Source File = /watch/movie.mp4
post-conversion: Preset = Mathias_MKV_720p30_v2
[autovideoconverter] Post-conversion hook exited with 0
[autovideoconverter] Conversion ended successfully.
[autovideoconverter] Removed /watch/movie.mp4

I could use the source file parameter to test if the watch folder only contains that file, but that has two problems:

1. Source files in sub folders will trip it up

2. Not sure if the watch folder purge have time to run before the container is shut down by the script

 

Hmm, might have to resort to a scheduled external script polling the watch folder.

 

 

Link to comment

@Communuity Developer  one question. I just added the code to my pre_conversion.sh file and kicked off a converestion.  was looking at the log file I saw this this error going through


/config/hooks/pre_conversion.sh: line 44: syntax error: unexpected end of file (expecting ";;")
is it something I need to be concern about. as I have had a look at the code, and with my very limited knowledge of coding this looks ok.

 

 

Link to comment
22 hours ago, chris_netsmart said:

@Communuity Developer  one question. I just added the code to my pre_conversion.sh file and kicked off a converestion.  was looking at the log file I saw this this error going through


/config/hooks/pre_conversion.sh: line 44: syntax error: unexpected end of file (expecting ";;")
is it something I need to be concern about. as I have had a look at the code, and with my very limited knowledge of coding this looks ok.

 

Yep, missing the last ';;'... Try this:

#!/bin/sh
#
# This is an example of a pre-conversion hook.  This script is always invoked
# with /bin/sh (shebang ignored).
#
# The first parameter is the full path where the video will be converted.
#
# The second parameter is the full path to the source file.
#
# The third argument is the name of the HandBrake preset that will be used to
# convert the video.
#

CONVERTED_FILE="$1"
SOURCE_FILE="$2"
PRESET="$3"

echo "pre-conversion: Output File = $CONVERTED_FILE"
echo "pre-conversion: Source File = $SOURCE_FILE"
echo "pre-conversion: Preset = $PRESET"

EXTENSION="$(echo "${SOURCE_FILE##*.}" | tr '[:upper:]' '[:lower:]')"
case "$EXTENSION" in
    avi|mp4)
        # Nothing to do.  Allow conversion of known video files.
        echo "pre-conversion: allowing file conversion."
        ;;
    mkv)
        # Do not convert MKVs.  Move the file to its final destination.
        EXTENSION="$(echo "${CONVERTED_FILE##*.}" | tr '[:upper:]' '[:lower:]')"
        if [ "$EXTENSION" = "mkv" ]; then
            echo "pre-conversion: file conversion not required, moving file."
            mkdir -p "$(dirname "$CONVERTED_FILE")"
            mv "$SOURCE_FILE" "$CONVERTED_FILE"
        else
            echo "ERROR: Destination file has unexpected extension '$EXTENSION'."
        fi
        ;;
    *)
        # Remove unknown files.
        echo "pre-conversion: preventing file conversion by removing file."
        rm "$SOURCE_FILE"
        ;;
esac

 

Link to comment
On 3/15/2019 at 9:14 AM, Jorgen said:

 

 

Ok, "killall -sigterm ghb" works well, at least when running manually in the container shell.

But I've run into another problem. The post-conversion hook runs before the watch folder is cleaned up, so I can't look for an empty folder.


[autovideoconverter] Executing post-conversion hook...
post-conversion: Status = 0
post-conversion: Output File = /output/movie.mkv
post-conversion: Source File = /watch/movie.mp4
post-conversion: Preset = Mathias_MKV_720p30_v2
[autovideoconverter] Post-conversion hook exited with 0
[autovideoconverter] Conversion ended successfully.
[autovideoconverter] Removed /watch/movie.mp4

I could use the source file parameter to test if the watch folder only contains that file, but that has two problems:

1. Source files in sub folders will trip it up

2. Not sure if the watch folder purge have time to run before the container is shut down by the script

 

Hmm, might have to resort to a scheduled external script polling the watch folder.

 

 

Or it might be a good feature to add...

Can you add feature request at https://github.com/jlesage/docker-handbrake/issues ?

Link to comment
17 hours ago, Djoss said:

Yep, missing the last ';;'... Try this:


#!/bin/sh
#
# This is an example of a pre-conversion hook.  This script is always invoked
# with /bin/sh (shebang ignored).
#
# The first parameter is the full path where the video will be converted.
#
# The second parameter is the full path to the source file.
#
# The third argument is the name of the HandBrake preset that will be used to
# convert the video.
#

CONVERTED_FILE="$1"
SOURCE_FILE="$2"
PRESET="$3"

echo "pre-conversion: Output File = $CONVERTED_FILE"
echo "pre-conversion: Source File = $SOURCE_FILE"
echo "pre-conversion: Preset = $PRESET"

EXTENSION="$(echo "${SOURCE_FILE##*.}" | tr '[:upper:]' '[:lower:]')"
case "$EXTENSION" in
    avi|mp4)
        # Nothing to do.  Allow conversion of known video files.
        echo "pre-conversion: allowing file conversion."
        ;;
    mkv)
        # Do not convert MKVs.  Move the file to its final destination.
        EXTENSION="$(echo "${CONVERTED_FILE##*.}" | tr '[:upper:]' '[:lower:]')"
        if [ "$EXTENSION" = "mkv" ]; then
            echo "pre-conversion: file conversion not required, moving file."
            mkdir -p "$(dirname "$CONVERTED_FILE")"
            mv "$SOURCE_FILE" "$CONVERTED_FILE"
        else
            echo "ERROR: Destination file has unexpected extension '$EXTENSION'."
        fi
        ;;
    *)
        # Remove unknown files.
        echo "pre-conversion: preventing file conversion by removing file."
        rm "$SOURCE_FILE"
        ;;
esac

 

thanks for the reply. but I am sad to report that I am still getting an error

 

pre-conversion: Preset = myh264
/config/hooks/pre_conversion.sh: line 43: syntax error: unexpected newline (expecting ")")
[autovideoconverter] Pre-conversion hook exited with 2

 

Link to comment

Hi,

 

I have been using this docker for a while now and it is perfect! Again Thanks for this.

 

Today though I am suddenly unable to write to the Handbrake output folder from my Main Rig, nothing has been changed, I have rebooted both my server and Main Rig but still no joy?  I am having to use putty to delete and move files around at the moment. 

 

I run 2 Handbrake Dockers and the output folder on the other one is still accessible.

 

the output folder is one of 5 subfolders in my Movies share on unraid, I am able to write to the other 4 with no issues

 

Any ideas?

 

image.png.f23004fec66be1459dc40f64862d98e2.png

 

image.png.f893271cee6524b8345ce9303668c2bb.png

 

 

 

Edited by mbc0
Link to comment
On 3/17/2019 at 4:13 AM, FieldGenEJ said:

I thought I would take another look into passing an Nvidia GPU into the container and then seeing the steps to getting NVENC with command line. The container isn't even seeing the GPU. Is this because there is no official support for nvidia? I'm also getting these libnvidia-encode errors.

For sure, under Linux, the UI doesn't support NVENC.  It seems that the command line could support it, but this is to validate.

 

Also, as indicated by the messages you mentioned, some libraries are missing in the container... and I'm not sure if sources are available to compile them.

Link to comment
On 3/17/2019 at 6:21 AM, chris_netsmart said:

thanks for the reply. but I am sad to report that I am still getting an error

 

pre-conversion: Preset = myh264
/config/hooks/pre_conversion.sh: line 43: syntax error: unexpected newline (expecting ")")
[autovideoconverter] Pre-conversion hook exited with 2

Try to copy-paste or download the script from https://gist.githubusercontent.com/jlesage/b2770b32bcfb8d1138887d86673ad8a8/raw/b82a2a089e7bd63d74d5d66cff4d8798763c3d1b/pre_conversion.sh.  It's working for me.

Link to comment
1 hour ago, mbc0 said:

Hi,

 

I have been using this docker for a while now and it is perfect! Again Thanks for this.

 

Today though I am suddenly unable to write to the Handbrake output folder from my Main Rig, nothing has been changed, I have rebooted both my server and Main Rig but still no joy?  I am having to use putty to delete and move files around at the moment. 

 

I run 2 Handbrake Dockers and the output folder on the other one is still accessible.

 

the output folder is one of 5 subfolders in my Movies share on unraid, I am able to write to the other 4 with no issues

 

Any ideas?

 

image.png.f23004fec66be1459dc40f64862d98e2.png

 

image.png.f893271cee6524b8345ce9303668c2bb.png

 

 

 

Are the files/folders have the same ownership and permissions (compare between a working and non-working one)?  Verify with "ls -l".

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.