I’ve updated comcut with command line arguments for the following:
--ffmpeg=/path/to/ffmpeg allows ability to specify path to ffmpeg if needed
--comskip=/path/to/comskip allows ability to specity path to comskip if needed
--lockfile=/path/to/lockfile allows ability to specify a lockfile which makes the script wait until the file no longer exists
--keep-edl tells comcut to not delete the edl file when done (this is helpful for testing so you dont have to wait for comskip to complete every time when debugging)
--keep-meta tells comcut to not delete the ffmeta file when done. Not sure how this would be helpful, but what the hell
I’ve also changed the shebang to get bash, this should help when bash itself is located elsewhere.
comchap will have the same changes done. Probably later today.
@Bollar, I think these changes would make it so your branch is mostly no longer necessary. I know there are differences with mktemp. I think I’ll make another change so it doesn’t even call mktemp, just generate the temporary file names manually with some naming convention. Do you have any input/concerns?
@bjs1400 said: @Bollar, I think these changes would make it so your branch is mostly no longer necessary. I know there are differences with mktemp. I think I’ll make another change so it doesn’t even call mktemp, just generate the temporary file names manually with some naming convention. Do you have any input/concerns?
Sure, if it works in FreeBSD with Plex, I’m pleased to deprecate mine. I think you need to add a command line argument to call a specific comskip.ini (because different channels get better results with different .ini files), so that would need need to be full path and filename.
Otherwise, I was thinking about adding transcoding as an option, so maybe that could be something to consider in the future.
Does the shebang change work on your FreeBSD box? (#!/usr/bin/env bash)
I’ll also add a --comskip-ini=/path/to/comskip.ini option.
Personally I feel that transcoding should be done in a separate script. I dislike mega-scripts. This should lead to simple Plex post-processing scripts for specific use cases.
On a separate note, you may be interested in my plex-scripts GitHub repo. (https://github.com/BrettSheleski/plex-scripts). In my post-processing script on my Plex-box I’m using these scripts to send me an email which will include a screenshot of the episode recorded, a series image from fanart.tv, as well as plot synopsis of the episode from TheTVDB. It’s still a work in progress though.
@bjs1400 said:
Does the shebang change work on your FreeBSD box? (#!/usr/bin/env bash)
It worked from the command line, but not from Plex. The log shows:
Oct 19, 2016 15:23:00.798 [0x80bc54800] DEBUG - MediaGrabber: Freed a tuner (now 3 available)
Oct 19, 2016 15:23:00.798 [0x80bc54800] DEBUG - Job running: '/comskiplinux/Comskip-master/comcut.sh' '/media/dvr/.grab/de44b0d62e990980bbecb3eb3028876614d521c3/Three\'s Company (1977) - S06E17 - Urban Plowboy.ts'
Oct 19, 2016 15:23:00.856 [0x809814800] ERROR - JobManager: child process returned: 127 (Unknown error: 127)
Oct 19, 2016 15:23:00.856 [0x80bc54800] DEBUG - Jobs: '/comskiplinux/Comskip-master/comcut.sh' exit code is 127
Oct 19, 2016 15:23:00.856 [0x80bc54800] ERROR - MediaRecorder: Postprocessing script '/comskiplinux/Comskip-master/comcut.sh' exited with error code 127.
Oct 19, 2016 15:23:00.856 [0x80bc54800] DEBUG - Activity: Ended activity a8cdbb84-dc7d-4aa7-9131-d89511ce28fe.
Oct 19, 2016 15:23:00.856 [0x80bc54800] DEBUG - MediaGrabber: Operation for Three's Company - S6 E17 - Urban Plowboy completed with status 5 (An error occurred while postprocessing the recording.)
Oct 19, 2016 15:23:00.997 [0x80bc54800] DEBUG - MediaGrabber: Scheduling 'Three's Company - S6 E17 - Urban Plowboy' for post-processing.
Oct 19, 2016 15:23:00.997 [0x809814400] WARN - MediaGrabber: Final status was 5, not going to postprocess.
Hmmmm… My guess would be an environment variable difference. Perhaps you could make a wrapper-script which modifies the PATH environment variable including wherever your bash lives then call comcut. I assume you’d have to write a wrapper-script anyway specifying ffmpeg and comskip paths, so it shouldn’t be a big deal.
@bjs1400 said:
Does the shebang change work on your FreeBSD box? (#!/usr/bin/env bash)
It worked from the command line, but not from Plex. The log shows:
Oct 19, 2016 15:23:00.798 [0x80bc54800] DEBUG - MediaGrabber: Freed a tuner (now 3 available)
Oct 19, 2016 15:23:00.798 [0x80bc54800] DEBUG - Job running: '/comskiplinux/Comskip-master/comcut.sh' '/media/dvr/.grab/de44b0d62e990980bbecb3eb3028876614d521c3/Three\'s Company (1977) - S06E17 - Urban Plowboy.ts'
Oct 19, 2016 15:23:00.856 [0x809814800] ERROR - JobManager: child process returned: 127 (Unknown error: 127)
Oct 19, 2016 15:23:00.856 [0x80bc54800] DEBUG - Jobs: '/comskiplinux/Comskip-master/comcut.sh' exit code is 127
Oct 19, 2016 15:23:00.856 [0x80bc54800] ERROR - MediaRecorder: Postprocessing script '/comskiplinux/Comskip-master/comcut.sh' exited with error code 127.
Oct 19, 2016 15:23:00.856 [0x80bc54800] DEBUG - Activity: Ended activity a8cdbb84-dc7d-4aa7-9131-d89511ce28fe.
Oct 19, 2016 15:23:00.856 [0x80bc54800] DEBUG - MediaGrabber: Operation for Three's Company - S6 E17 - Urban Plowboy completed with status 5 (An error occurred while postprocessing the recording.)
Oct 19, 2016 15:23:00.997 [0x80bc54800] DEBUG - MediaGrabber: Scheduling 'Three's Company - S6 E17 - Urban Plowboy' for post-processing.
Oct 19, 2016 15:23:00.997 [0x809814400] WARN - MediaGrabber: Final status was 5, not going to postprocess.
I assume you’ve run your script as the plex-user and no issues. I had a similar issue when testing comchap/comcut and turned out to be an environment variable issue.
How about modifying your script as the following:
#!/bin/csh
# write the environment variables to file for comparison
env >> /tmp/comchap.env
echo Processing: "$1" >> /tmp/comchap.log
#redirect stdout and stderr to the log file
/usr/local/bin/bash /comchap/comcut --ffmpeg=/usr/local/bin/ffmpeg --comskip=/comskiplinux/Comskip-master/comskip --lockfile=/tmp/comchap.lock --comskip-ini=/comskiplinux/Comskip-master/comskip.ini "$1" >> /tmp/comchap.log 2>&1
echo Completed: "$1" >> /tmp/comchap.log
Thanks. There are several idiosyncrasies with FreeBSD jails and permissions, but this script appears to work. I’ll test it today.
#!/bin/csh
# Add bash path to Plex path.
set path = ($path /usr/local/bin)
# Sleep for a pseudorandom period (up to 10 seconds) to limit the number of instances that sta$
sleep `echo $$%10 | bc`
echo Processing: "$1" >> /tmp/comchap.log
/comchap/comcut --ffmpeg=/usr/local/bin/ffmpeg --comskip=/comskiplinux/Comskip-master/comskip $
Had to add the random sleep line to keep all of the jobs hitting the processing script all at once.
I can add a --output option for this which would be used to pass to comskip as well as where the ffmeta file is written to. The variables that hold onto the work-file names will just be modified to also look at the --output option.
@bjs1400 said:
I can add a --output option for this which would be used to pass to comskip as well as where the ffmeta file is written to. The variables that hold onto the work-file names will just be modified to also look at the --output option.
It sounds like he’s talking about Plex sometimes not moving the file even though it is the only file in the grab dir.
I’ve had Plex lose metadata for files when manually doing post-processing on files already in the library. This is why I was happy they exposed a way of post-processing DVR recordings assuming that the metadata loss would not occur. I’ve had this happen when I manually call comchap/comcut on a file already in the library which results in the original file being modified. Seems like Plex is “watching” all files and if the file is modified in any way it triggers a rescan and re-grab metadata for the file and sometimes failing or the file being matched to something else completely. I’ve noticed this happen when comchap/comcut-ing NFL recordings.
It seems like Plex is also “watching” files in the grab directory too for some reason. I’m not so sure this is a bug with Plex or not, but the two symptoms may be related.
However, since removing the work-files I have not experienced any problems with recordings being moved as they should.