nebhead / PlexPostProc

Plex PostProcessing Script for DVR(Beta)
77 stars 30 forks source link

Postprocessing not working on Mac #6

Closed c0linsteele closed 6 years ago

c0linsteele commented 7 years ago

I'm using the FFMPEG branch and the post processing script fails. Exits with an error code 127 and just copies the unconverted file into my library. Has anyone seen this before and know of a solution?

Nov 21, 2017 08:00:58.706 [0x70000c283000] DEBUG - Job running: '/Users/colinsteele/PlexPostProc/PlexPostProc.sh' '/Volumes/Plex/Plex/Videos/TV Shows/.grab/88ecb30f6e0a3c720622d9c92a6a8fb936094309/Parking Wars (2008) - S06E07 - Episode 7.ts'
Nov 21, 2017 08:00:58.718 [0x70000c283000] DEBUG - Jobs: '/Users/colinsteele/PlexPostProc/PlexPostProc.sh' exit code for process 62152 is 127
Nov 21, 2017 08:00:58.718 [0x70000c283000] ERROR - DVR:Recorder: Postprocessing script '/Users/colinsteele/PlexPostProc/PlexPostProc.sh' exited with error code 127.
Nov 21, 2017 08:00:58.722 [0x70000ccbf000] DEBUG - DVR:Grabber: Postprocessing, we're going to put `Parking Wars - E7 - Episode 7` in `/Volumes/Plex/Plex/Videos/TV Shows/Parking Wars (2008)/Season 06/Parking Wars (2008) - S06E07 - Episode 7.ts`
Nov 21, 2017 08:00:59.458 [0x70000ccbf000] DEBUG - DVR:Grabber: Operation for Parking Wars - E7 - Episode 7 completed with status error (An error occurred while postprocessing the recording)
Nov 21, 2017 10:32:07.957 [0x70000c71e000] DEBUG - Request: [127.0.0.1:55249 (Loopback)] PUT /livetv/dvrs/13/prefs?startOffsetMinutes=0&endOffsetMinutes=0&useUmp=false&postprocessingScript=%2FUsers%2Fcolinsteele%2FPlexPostProc%2FPlexPostProc.sh&increasedRefreshes=false (11 live) GZIP Signed-in Token (Man0f5tee1e)
Nov 21, 2017 10:32:07.979 [0x70000b63b000] DEBUG - Completed: [127.0.0.1:55249] 200 PUT /livetv/dvrs/13/prefs?startOffsetMinutes=0&endOffsetMinutes=0&useUmp=false&postprocessingScript=%2FUsers%2Fcolinsteele%2FPlexPostProc%2FPlexPostProc.sh&increasedRefreshes=false (11 live) GZIP 21ms 3066 bytes (pipelined: 1)
calederer commented 7 years ago

I have run into this issue on FreeBSD install and haven’t found a solution yet. The script runs perfectly when I execute it manually from the command line. Things that I have checked is that permissions are set correctly (chmod 777) and that PATH includes the location of the script. Other insight would be helpful.

calederer commented 7 years ago

Just for info. Bash exit code 127 is “command not found”

c0linsteele commented 7 years ago

It seems to run fine when run manually through terminal, but Plex keeps giving me an error. The permissions (777) are set correctly and the PATH variable includes the path to the script. My only other thought might be owner and group permissions, but I'm not sure what those would need to be set to.

calederer commented 7 years ago

777 should cover the group and owner permissions. My next steps for debugging were to add some lines in the script to create a log file to see how far it gets through the script/or if it even executes the script to see where gets hung up. I just haven't gotten around to it yet. I believe it gets executed as the user 'Plex' so there may be a weird issue with permissions on some command.

calederer commented 7 years ago

debug update added to the top of the script

logfile=/usr/home/plex/bin/log.out
exec > $logfile 2>&1

when executed by plex this is the output

/mnt/DVR/.grab/412041aef5f491ecd54cde3d062e8d3098e65554/Who Wants to Be a Millionaire (2002) - S16E68 - Episode 68.ts
/tmp/tmp.nQG6RbYH.mkv
********************************************************
Starting Transcoding: Converting to H.264 w/ffmpeg @720p
********************************************************
/usr/home/plex/bin/PlexPostProc.sh: ffmpeg: not found
ERROR # 127 : Failed to convert using ffmepg

so looks like an issue with accessing ffmpeg.

calederer commented 7 years ago

So i was able to get rid of the exit code 127 by calling the full path of ffmpeg /usr/local/bin/ffmpeg -i "$FILENAME" -s hd720 -c:v libx264 -preset veryfast -vf yadif -c:a copy "$TEMPFILENAME"

nebhead commented 6 years ago

Sorry folks, was on Holiday for the past week. Looks like you were able to debug for the Mac environment by adding the path for FFMPEG. Would it help if I added a "path-to" variable definition to the script so that you can specify a directory for environments that don't have FFMPEG in the system variables path?

c0linsteele commented 6 years ago

I can confirm that it is working when the full path to FFMPEG is referenced in the script. Thanks @calederer for your debugging efforts. @nebhead I'm not sure if the "path-to" variable definition would help or not. FFMPEG is in the /usr/local/bin/ folder which should it to be executed by default without modification to the path variable and while the script runs fine without the path when you run it manually, it freaks out when Plex tries to execute it. I also ensured the location of the PlexPostProc script was added to the PATH variable and still had no luck. As soon as I added the full path for FFMPEG to the PlexPostProc script, post processing occurred as expected.

f.y.i. Did you see Plex added native commercial skipping. It's now an option under DVR settings for the latest Plex Pass build.

calederer commented 6 years ago

I'm not sure if adding a path-to variable would be warranted here. When I execute which FFMPEG I get back usr/local/bin which is as expected so something else is going on. I would recommend closing this and it can be reopened later if more users experience this issue. Might be worth noting in the readme.

nebhead commented 6 years ago

OK, sounds good @calederer and @c0linsteele! I'll go ahead and add a comment to the readme for this one.