mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.52k stars 202 forks source link

Docker sonarr/radarr-sma on synology NAS #1640

Closed MrGibbage closed 1 year ago

MrGibbage commented 1 year ago

Describe the bug Maybe not a bug but just user error on my part. I installed the radarr & sonarr-sma docker containers on my synology DS920+. I'm not exactly sure I did it right, but manual.py does work. It was strange because I had to install python dependencies, which I have never done before for a docker container (requests, subliminal, guessit, etc). Anyway, like I said, I can run manual.py and it converts the input file as I would expect. But getting radarr & sonarr to do it automatically, no luck.

I was following the steps for sonarr/radarr and went to add a connection (custom script). Browsed to /usr/local/sma/postSonarr.py and clicked the test button, and I got an error that the script exited with -1. I am wondering if it has something to do with this instruction:

For Sonarr V3 you'll need to make a .sh or .bat file to combine your path to python and script

I don't know what it means to "combine my path to python and script"

Sonarr & radarr work. They are sending requests to sab and the files are downloaded and placed where they are supposed to go. But they aren't being post-processed yet because I haven't been able to get the custom script connected.

Any ideas on how to fix this?

Command or context you are trying to run manual.py works fine.

autoProcess.ini settings Please sensor API keys/private information but include all other settings

[Converter] ffmpeg = ffmpeg ffprobe = ffprobe threads = 0 hwaccels = hwaccel-decoders = hwdevices = hwaccel-output-format = output-directory = output-format = mp4 output-extension = mp4 temp-extension = minimum-size = 250 ignored-extensions = nfo, dsstore copy-to = move-to = delete-original = True process-same-extensions = False bypass-if-copying-all = False force-convert = False post-process = False wait-post-process = False detailed-progress = False opts-separator = , preopts = postopts = regex-directory-replace = [^\w-. ]

[Permissions] chmod = 0644 uid = -1 gid = -1

[Metadata] relocate-moov = True full-path-guess = True tag = True tag-language = eng download-artwork = poster sanitize-disposition = strip-metadata = False keep-titles = False

[Video] codec = h264, x264 max-bitrate = 0 bitrate-ratio = crf = -1 crf-profiles = preset = codec-parameters = dynamic-parameters = False max-width = 0 profile = max-level = 0.0 pix-fmt = prioritize-source-pix-fmt = True filter = force-filter = False

[HDR] codec = pix-fmt = space = bt2020nc transfer = smpte2084 primaries = bt2020 preset = codec-parameters = filter = force-filter = False profile =

[Audio] codec = aac languages = default-language = include-original-language = True first-stream-of-language = False channel-bitrate = 128 variable-bitrate = 0 max-bitrate = 0 max-channels = 0 filter = profile = force-filter = False sample-rates = sample-format = copy-original = False aac-adtstoasc = False ignored-dispositions = force-default = False unique-dispositions = False stream-codec-combinations =

[Audio.Sorting] sorting = language, channels.d, map, d.comment default-sorting = channels.d, map, d.comment codecs =

[Universal Audio] codec = aac channel-bitrate = 128 variable-bitrate = 0 first-stream-only = False filter = profile = force-filter = False

[Audio.ChannelFilters]

[Subtitle] codec = mov_text codec-image-based = languages = en default-language = include-original-language = False first-stream-of-language = False encoding = burn-subtitles = False burn-dispositions = embed-subs = False embed-image-subs = False embed-only-internal-subs = False filename-dispositions = forced ignore-embedded-subs = False ignored-dispositions = force-default = False unique-dispositions = False attachment-codec = remove-bitstream-subs = False

[Subtitle.Sorting] sorting = language, d.comment, d.default.d, d.forced.d codecs = burn-sorting = language, d.comment, d.default.d, d.forced.d

[Subtitle.CleanIt] enabled = False config-path = tags =

[Subtitle.FFSubsync] enabled = False

[Subtitle.Subliminal] download-subs = False download-forced-subs = False include-hearing-impaired-subs = False providers =

[Subtitle.Subliminal.Auth]

[Sonarr] host = 127.0.0.1 port = 8989 apikey = XXX ssl = False webroot = force-rename = False rescan = True block-reprocess = False

[Radarr] host = 127.0.0.1 port = 7878 apikey = XXX ssl = False webroot = force-rename = False rescan = True block-reprocess = False

[Sickbeard] host = localhost port = 8081 ssl = False apikey = webroot = username = password =

[Sickrage] host = localhost port = 8081 ssl = False apikey = webroot = username = password =

[SABNZBD] convert = True sickbeard-category = sickbeard sickrage-category = sickrage sonarr-category = sonarr radarr-category = radarr bypass-category = bypass output-directory = path-mapping =

[Deluge] sickbeard-label = sickbeard sickrage-label = sickrage sonarr-label = sonarr radarr-label = radarr bypass-label = bypass convert = True host = localhost port = 58846 username = password = output-directory = remove = False path-mapping =

[qBittorrent] sickbeard-label = sickbeard sickrage-label = sickrage sonarr-label = sonarr radarr-label = radarr bypass-label = bypass convert = True action-before = action-after = host = localhost port = 8080 ssl = False username = password = output-directory = path-mapping =

[uTorrent] sickbeard-label = sickbeard sickrage-label = sickrage sonarr-label = sonarr radarr-label = radarr bypass-label = bypass convert = True webui = False action-before = action-after = host = localhost ssl = False port = 8080 username = password = output-directory = path-mapping =

[Plex] host = localhost port = 32400 refresh = False token = XXX

Log files Include log files for the specific job (not just a dump of all your logs for the past month) that's causing the issue. Please turn on debug level logging Log files are found in your script root config folder ./sma/config/sma.log

When I try to add the custom script in Sonarr/radarr, and press the test button, I get an error that the script exited with a -1, and nothing is logged. I did set [handler_fileHandler] section level = DEBUG.

FFMpeg headers Run ffmpeg and post the headers, example [headers]https://github.com/mdhiggins/sickbeard_mp4_automator/wiki/FFMPEG-Headers

System Information Container installed on a synology DS920+ NAS

   sonarr:
    container_name: sonarr
   image: mdhiggins/sonarr-sma:latest
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-file: ${DOCKERLOGGING_MAXFILE}
        max-size: ${DOCKERLOGGING_MAXSIZE}
    ports:
      - 8989:8989
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${DOCKERCONFDIR}/sma:/usr/local/sma/config
      - ${DOCKERCONFDIR}/sonarr:/config
      - /volume1/data/media/tv:/tv
      - /volume1/data/downloads:/downloads

Expected behavior Expected behavior is that I can add SMA as a custom script in sonarr/radarr and have it automatically convert downloaded files.

Additional context Do I need to create a custom script or should the docker installation work out of the box?

Issues posted without any logs or autoProcess settings will be closed logs and autoprocess.ini were included above.

mdhiggins commented 1 year ago

My guess is you're trying to run the script using the default python environment and not the virtual python environment inside the containers that contains all the preset requirements and configuration

The .sh script is also included in the docker containers and does not need to manually be created

If you look at the readme for the docker containers https://github.com/mdhiggins/sonarr-sma#configuring-sonarr note that the path you're supposed to use is

/usr/local/sma/postSonarr.sh and NOT /usr/local/sma/postSonarr.py

mdhiggins commented 1 year ago

Similarly to run manual.py from inside the containers you have to point it to the virtual environment as well

/usr/local/sma/venv/bin/python3 /usr/local/sma/manual.py

MrGibbage commented 1 year ago

Thanks for the help!

Well, your suspicion was correct. I was trying to run postSonarr.py, not .sh.

However, I changed it to the .sh and when I do a test now, I get an exit code of 1, and still nothing in the log file.

mdhiggins commented 1 year ago

Might want to do a clean image given the new information and previous modifications you made and see if that persists. If it does, check the Sonarr logs to see what the error is that's giving the exit code. If you're getting nothing in the SMA logs it's probably an import exception of some kind

MrGibbage commented 1 year ago

That did it! Rebuilt the containers and everything is working. I ran a test with radarr and sab, and it took 4 hours to convert a file. Any ideas of how I can speed it up? Here's the log: https://gist.github.com/MrGibbage/c56b912bc209fd871c482f60b5f1aff2

Thanks again for the help!

mdhiggins commented 1 year ago

Depends on your hardware, but video transcoding is always going to take a while compared to just audio

The script is a wrapper for FFMPEG so you'll need to look in to how to improve your FFMPEG transcoding times

Best bet is to try to remux video streams when possible, that will give you the no quality loss and be the fastest (so for example, don't download h265 10 bit sources and then transcode down to h264 sdr when possible, just get h264 sources)

If you must transcode, adjusting quality can allow transcoding faster

Using hardware transcoding if you have supported hardware will help as well

https://trac.ffmpeg.org/wiki/HWAccelIntro

And general h264 transcoding information for your reference

https://trac.ffmpeg.org/wiki/Encode/H.264