chris_netsmart Posted March 13, 2019 Share Posted March 13, 2019 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, Quote Link to comment
Djoss Posted March 14, 2019 Author Share Posted March 14, 2019 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. Quote Link to comment
chris_netsmart Posted March 14, 2019 Share Posted March 14, 2019 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. Quote Link to comment
Jorgen Posted March 14, 2019 Share Posted March 14, 2019 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 Quote Link to comment
cybrnook Posted March 14, 2019 Share Posted March 14, 2019 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 Quote Link to comment
Djoss Posted March 14, 2019 Author Share Posted March 14, 2019 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. 1 Quote Link to comment
Djoss Posted March 14, 2019 Author Share Posted March 14, 2019 1 hour ago, Jorgen said: but is it possible to stop the container from the container shell? 1 hour ago, cybrnook said: Might be of use? https://github.com/phusion/baseimage-docker/issues/451 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 2 Quote Link to comment
Jorgen Posted March 15, 2019 Share Posted March 15, 2019 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 Quote Link to comment
Jorgen Posted March 15, 2019 Share Posted March 15, 2019 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. Quote Link to comment
chris_netsmart Posted March 15, 2019 Share Posted March 15, 2019 @Community Developer thanks for the code. I will give it a try. Quote Link to comment
chris_netsmart Posted March 15, 2019 Share Posted March 15, 2019 @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. Quote Link to comment
trurl Posted March 15, 2019 Share Posted March 15, 2019 46 minutes ago, chris_netsmart said: @Communuity Developer Hey @Advanced Member, who are you calling @Community Developer? 1 Quote Link to comment
chris_netsmart Posted March 15, 2019 Share Posted March 15, 2019 1 hour ago, trurl said: Hey @Advanced Member, who are you calling @Community Developer? Djoss. Quote Link to comment
Djoss Posted March 16, 2019 Author Share Posted March 16, 2019 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 Quote Link to comment
Djoss Posted March 16, 2019 Author Share Posted March 16, 2019 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 ? Quote Link to comment
Jorgen Posted March 17, 2019 Share Posted March 17, 2019 9 hours ago, Djoss said: Or it might be a good feature to add... Can you add feature request at https://github.com/jlesage/docker-handbrake/issues ? Done. Let me know if/when you need help with testing. Thanks for all your work on this container, it's very very useful. Quote Link to comment
FieldGenEJ Posted March 17, 2019 Share Posted March 17, 2019 Hey @Djoss, 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. Quote Link to comment
chris_netsmart Posted March 17, 2019 Share Posted March 17, 2019 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 Quote Link to comment
mbc0 Posted March 19, 2019 Share Posted March 19, 2019 (edited) 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? Edited March 19, 2019 by mbc0 Quote Link to comment
Djoss Posted March 19, 2019 Author Share Posted March 19, 2019 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. Quote Link to comment
Djoss Posted March 19, 2019 Author Share Posted March 19, 2019 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. Quote Link to comment
Djoss Posted March 19, 2019 Author Share Posted March 19, 2019 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? Are the files/folders have the same ownership and permissions (compare between a working and non-working one)? Verify with "ls -l". Quote Link to comment
Djoss Posted March 20, 2019 Author Share Posted March 20, 2019 18 hours ago, mbc0 said: So your "handbrakedocker" folder seems to have the correct/normal ownership/permissions. Likely a permission issue with SMB? Quote Link to comment
mbc0 Posted March 20, 2019 Share Posted March 20, 2019 Unfortunately a bit over my head to be honest, I just chmod -R 777 and now working fine... All my SMB Shares (I have a lot!) are working normally with correct access except my Handbrakedocker folder so I wouldn't know where to begin! Quote Link to comment
Recommended Posts
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.