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 201 forks source link

postSonarr.py hanging #1682

Closed sowie2016 closed 11 months ago

sowie2016 commented 1 year ago

Could anyone advise if having a similar issue roughly every 24 hours postSonarr.py process is hanging when everything appears complete. Episode is converted renamed and Sonarr has dropped into the correct category.

No other conversion will start until I kill the hanging process.

Can anyone point me in the correct direction to troubleshoot? I've turned on debug logging in Sonarr but all appears normal apart from the next conversion doesnt start.

This is an intermittent issues, I could complete 20 conversions before this happens again.

mdhiggins commented 1 year ago

Can you share the logs from one of these hangs? Both the SMA logs and accompanying Sonarr logs would be helpful.

Not seeing any issues on my end personally. No hangs

sowie2016 commented 1 year ago

I will have to wait till this happens again to grab them. I wonder if the issue could be related to the Plex refresh called at the end of the script. As my storage is now mounted to my PMS by NFS mount due to Plex restricting access to a certain hosting company I have to enable full folder scans when conversions are complete instead of Plex detecting library changes.

Could this possibly be the cause?

sowie2016 commented 1 year ago

Ok its hanging now... some logs below

I have changed the plex config now so it no longer connects to my plex instance to rule that out.

SMA Log

2023-10-03 19:29:19 - resources.readsettings - INFO - /usr/bin/python3
2023-10-03 19:29:19 - resources.readsettings - INFO - Loading config file /home/tv/sickbeard_mp4_automator/config/autoProcess.ini.
2023-10-03 19:29:19 - resources.readsettings - WARNING - Force-convert is true, so process-same-extensions is being overridden to true as well
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Processing /home/tv/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mkv.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Input Data
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - {
    "format": "matroska,webm",
    "format-fullname": "Matroska / WebM",
    "video": {
        "index": 0,
        "codec": "h264",
        "pix_fmt": "yuv420p",
        "profile": "high",
        "fps": 25.0,
        "framedata": {
            "pix_fmt": "yuv420p",
            "side_data_list": [
                {
                    "side_data_type": "H.26[45] User Data Unregistered SEI message"
                }
            ]
        },
        "dimensions": "1280x720",
        "level": 4.1,
        "field_order": "progressive"
    },
    "audio": [
        {
            "index": 1,
            "codec": "ac3",
            "bitrate": 640000,
            "channels": 2,
            "samplerate": 48000,
            "language": "eng",
            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired"
        }
    ],
    "subtitle": [],
    "attachment": []
}
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Reading video stream.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Video codec detected: h264.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Pix Fmt: yuv420p.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Profile: high.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Video codec parameters None.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Creating h264 video stream from source stream 0.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Reading audio streams.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Audio detected for stream 1 - ac3 eng 2 channel.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Creating libfdk_aac audio stream from source stream 1.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Default audio stream set to eng libfdk_aac 2 channel stream [default-more-channels: True].
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Reading subtitle streams.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Scanned for external subtitles and found 0 results in your approved languages.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Output Data
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - {
    "source": [
        "/home/tv/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mkv"
    ],
    "format": "mp4",
    "video": {
        "codec": "h264",
        "map": 0,
        "bitrate": 4500,
        "crf": -1,
        "maxrate": null,
        "bufsize": null,
        "level": 4.1,
        "profile": "main",
        "preset": null,
        "pix_fmt": null,
        "field_order": "progressive",
        "width": null,
        "filter": null,
        "params": null,
        "framedata": null,
        "title": "HD",
        "debug": "video.max-bitrate.profile"
    },
    "audio": [
        {
            "map": 1,
            "codec": "libfdk_aac",
            "channels": 2,
            "bitrate": 256,
            "filter": null,
            "samplerate": null,
            "language": "eng",
            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired",
            "bsf": null,
            "title": "Stereo",
            "debug": "universal-audio"
        }
    ],
    "subtitle": [],
    "attachment": []
}
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Preopts
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - []
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Postopts
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - [
    "-threads",
    "0",
    "-metadata:g",
    "encoding_tool=SMA"
]
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Starting conversion.
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - FFmpeg command:
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - ======================
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - /root/bin/ffmpeg -i "/home/tv/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mkv" -vcodec libx264 -map 0:0 -field_order progressive -vb 4500k -metadata:s:v BPS=4500000 -metadata:s:v BPS-eng=4500000 -metadata:s:v title="HD" -metadata:s:v handler_name="HD" -profile:v main -level 4.1 -c:a:0 libfdk_aac -map 0:1 -ac:a:0 2 -b:a:0 256k -metadata:s:a:0 BPS=256000 -metadata:s:a:0 BPS-eng=256000 -metadata:s:a:0 title="Stereo" -metadata:s:a:0 handler_name="Stereo" -metadata:s:a:0 language=eng -disposition:a:0 +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f mp4 -threads 0 -metadata:g encoding_tool=SMA -y "/home/tv/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mp4"
2023-10-03 19:29:19 - resources.mediaprocessor - INFO - ======================
2023-10-03 19:40:06 - resources.mediaprocessor - INFO - /home/tv/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mp4 created.`

Sonarr Log

`2023-10-03 19:29:19.1|Debug|postSonarr.py|Starting /home/(removed)/sickbeard_mp4_automator/postSonarr.py 
2023-10-03 19:29:19.3|Debug|Api|[GET] /api/v3/command: 200.OK (1 ms)
2023-10-03 19:29:19.5|Debug|postSonarr.py|2023-10-03 19:29:19 - SonarrPostProcess - INFO - Sonarr extra script post processing started.
2023-10-03 19:29:19.5|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.readsettings - INFO - /usr/bin/python3
2023-10-03 19:29:19.5|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.readsettings - INFO - Loading config file /home/(removed)/sickbeard_mp4_automator/config/autoProcess.ini.
2023-10-03 19:29:19.5|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.readsettings - WARNING - Force-convert is true, so process-same-extensions is being overridden to true as well
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Processing /home/(removed)/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mkv.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Input Data
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - {
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "format": "matroska,webm",
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "format-fullname": "Matroska / WebM",
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "video": {
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "index": 0,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "codec": "h264",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "pix_fmt": "yuv420p",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "profile": "high",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "fps": 25.0,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "framedata": {
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "pix_fmt": "yuv420p",
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "side_data_list": [
2023-10-03 19:29:19.7|Debug|postSonarr.py|                {
2023-10-03 19:29:19.7|Debug|postSonarr.py|                    "side_data_type": "H.26[45] User Data Unregistered SEI message"
2023-10-03 19:29:19.7|Debug|postSonarr.py|                }
2023-10-03 19:29:19.7|Debug|postSonarr.py|            ]
2023-10-03 19:29:19.7|Debug|postSonarr.py|        },
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "dimensions": "1280x720",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "level": 4.1,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "field_order": "progressive"
2023-10-03 19:29:19.7|Debug|postSonarr.py|    },
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "audio": [
2023-10-03 19:29:19.7|Debug|postSonarr.py|        {
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "index": 1,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "codec": "ac3",
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "bitrate": 640000,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "channels": 2,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "samplerate": 48000,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "language": "eng",
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired"
2023-10-03 19:29:19.7|Debug|postSonarr.py|        }
2023-10-03 19:29:19.7|Debug|postSonarr.py|    ],
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "subtitle": [],
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "attachment": []
2023-10-03 19:29:19.7|Debug|postSonarr.py|}
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Reading video stream.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Video codec detected: h264.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Pix Fmt: yuv420p.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Profile: high.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Video codec parameters None.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Creating h264 video stream from source stream 0.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Reading audio streams.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Audio detected for stream 1 - ac3 eng 2 channel.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Creating libfdk_aac audio stream from source stream 1.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Default audio stream set to eng libfdk_aac 2 channel stream [default-more-channels: True].
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Reading subtitle streams.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Scanned for external subtitles and found 0 results in your approved languages.
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Output Data
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - {
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "source": [
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "/home/(removed)/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mkv"
2023-10-03 19:29:19.7|Debug|postSonarr.py|    ],
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "format": "mp4",
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "video": {
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "codec": "h264",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "map": 0,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "bitrate": 4500,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "crf": -1,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "maxrate": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "bufsize": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "level": 4.1,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "profile": "main",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "preset": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "pix_fmt": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "field_order": "progressive",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "width": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "filter": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "params": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "framedata": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "title": "HD",
2023-10-03 19:29:19.7|Debug|postSonarr.py|        "debug": "video.max-bitrate.profile"
2023-10-03 19:29:19.7|Debug|postSonarr.py|    },
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "audio": [
2023-10-03 19:29:19.7|Debug|postSonarr.py|        {
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "map": 1,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "codec": "libfdk_aac",
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "channels": 2,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "bitrate": 256,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "filter": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "samplerate": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "language": "eng",
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired",
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "bsf": null,
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "title": "Stereo",
2023-10-03 19:29:19.7|Debug|postSonarr.py|            "debug": "universal-audio"
2023-10-03 19:29:19.7|Debug|postSonarr.py|        }
2023-10-03 19:29:19.7|Debug|postSonarr.py|    ],
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "subtitle": [],
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "attachment": []
2023-10-03 19:29:19.7|Debug|postSonarr.py|}
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Preopts
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - []
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Postopts
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - [
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "-threads",
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "0",
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "-metadata:g",
2023-10-03 19:29:19.7|Debug|postSonarr.py|    "encoding_tool=SMA"
2023-10-03 19:29:19.7|Debug|postSonarr.py|]
2023-10-03 19:29:19.7|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - Starting conversion.
2023-10-03 19:29:19.8|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - FFmpeg command:
2023-10-03 19:29:19.8|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - ======================
2023-10-03 19:29:19.8|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - /root/bin/ffmpeg -i "/home/(removed)/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mkv" -vcodec libx264 -map 0:0 -field_order progressive -vb 4500k -metadata:s:v BPS=4500000 -metadata:s:v BPS-eng=4500000 -metadata:s:v title="HD" -metadata:s:v handler_name="HD" -profile:v main -level 4.1 -c:a:0 libfdk_aac -map 0:1 -ac:a:0 2 -b:a:0 256k -metadata:s:a:0 BPS=256000 -metadata:s:a:0 BPS-eng=256000 -metadata:s:a:0 title="Stereo" -metadata:s:a:0 handler_name="Stereo" -metadata:s:a:0 language=eng -disposition:a:0 +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f mp4 -threads 0 -metadata:g encoding_tool=SMA -y "/home/(removed)/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mp4"
2023-10-03 19:29:19.8|Debug|postSonarr.py|2023-10-03 19:29:19 - resources.mediaprocessor - INFO - =====================
2023-10-03 19:40:06.0|Debug|postSonarr.py|2023-10-03 19:40:06 - resources.mediaprocessor - INFO - /home/(removed)/pt/tvshows/tvshows/M-P/Mrs Brown's Boys/Season 01/Mrs Brown's Boys - S01E03 - Mammy's Merchandise.mp4 created.
sowie2016 commented 1 year ago

Think I found it the process just finished.

Check sma.log and this was the first line, so it seemed to hang for 1 hour 40 mins trying to retrieve rating... any ideas?

2023-10-03 21:24:57 - resources.metadata - ERROR - Unable to retrieve rating.

Hmmm, I wonder due to me moving my sonarr installation and it appears to be redownloading all new coverart if I've hit the api limits on this ip which is also why the script is hanging at this stage. Could this be linked?

mdhiggins commented 1 year ago

Its possible though I wouldn't think if it was a simple request denial that it should take that long to time out

See if this update helps

a9926bc9a254ec1a06816bb1c8e3e6696fbd3534

Added a timeout to tmdbsimple and tweaked the error to include a little more info

sowie2016 commented 1 year ago

Thanks.

I've tried this will report back tomorrow

mdhiggins commented 1 year ago

Might also be worth making sure your tmdbsimple package is up to date