After running “Ad Detection” AKA comskip on libraries that are not being used for recordings (by enabling “Ad Detection” “For All Items”), I have noticed what I think are 2 issues, can anyone confirm that this is correct:
When new episodes in a show are added, and I select “Analyze” from the show’s main menu, it appears to re-analyze every episode in that entire show, even though most of them have already been analyzed, and commercial skip was already generated. It seems like Plex is not keeping track of anything it analyzed already, and it just does them all again.
Even though I have enabled ad detection for all items, it does not do any comskip analysis automatically as new items are added to the library, I have to manually choose “Analyze” in order to get it to run Ad detection. This is most likely caused because it is not keeping track of what it already analyzed (see point 1).
Any ideas on how to do this more effectively? right now, I have to check once a day to see if new items were added to the library, and then manually run analyze on them to get commercial detection; and if I do it by show, then it needlessly re-analyzes every episode, which is OK for a couple of episodes, but it gets out-of-hand really quickly when there are 15-20 episodes
Are these shows/episodes which actually have ads, and which have been previously had commercial markers added? Plex doesn’t check to see if an episode/movie has been previously checked for commercials; rather it checks to see if an episode/movie has commercial markers added for it. If not, it attempts to perform detection.
So, if you have a library of items which have no commercials, and you have the library configured to detect ads for all items, it will continue to check for commercials in that media whenever it is instructed to do so (either during maintenance or when media analysis is performed).
This is, as far as I know, the intended behavior. There are no settings in Plex which dictate when ad detection is performed, such as there are for intro or credit detection. It either happens during maintenance, or manually when analysis is performed.
Are these shows/episodes which actually have ads, and which have been previously had commercial markers added?
Yes, all the new shows added to the library will have ads; they are simply recorded using NextPVR from live TV feeds, and placed somewhere that Plex is monitoring
Plex doesn’t check to see if an episode/movie has been previously checked for commercials; rather it checks to see if an episode/movie has commercial markers added for it. If not, it attempts to perform detection.
Yes, that’s what I would expect; so it would know that some episodes have already been marked with commercials, but that doesn’t seem to be the case. Since there is no insight into exactly what Plex is doing with comskip (like there is e.g. for optimize and conversion activity), it is impossible to tell exactly, but the more episodes there are, the longer it seems to take to run “Analyze”, even though it already ran and found commercials on nearly all the episodes.
It either happens during maintenance, or manually when analysis is performed.
What do you mean by maintenance? I have both “Scan my library automatically” and “run a partial scan when changes are detected” set, but I do not have “Scan my library periodically” set, because it causes scans and high CPU usage at inconvenient times (BTW: it would be really nice if I could say “scan my library at 2:00 AM”, but I can’t). How do I get Plex to perform maintenance? This could be a useful fix if I can get Plex to do it automatically at some off-hour, like 2:00 AM
@pshanew Thanks for the hint, I just found the “Scheduled Tasks” section in my settings, I’m going try to get it to schedule analysis at some off hour to see if it works. I’ll let you know.
Yep, sorry about that. I waffle between referring to it as “maintenance” and “scheduled tasks.”
Our use cases are similar. I use NextPVR myself for some series (where I need a bit more flexibility in scheduling). I don’t see the behavior you’re describing. That’s why I was curious whether or not you were mixing recorded material with non-recorded.
For troubleshooting, you can view your logs and search for “Plex Commercial” after analysis. Something like:
OK, thanks. I have “Upgrade media analysis during maintenance” checked, so let’s see if it manages to find the commercials overnight. I’m kind-of OK with it taking a long time to run if it does it while I’m asleep.
Once it is done, I’ll check the logs to see which shows it analyzed, and whether it is trying to do some multiple times.
@pshanew OK, I checked the logs and I’ve found the issue. It does, in fact, only analyze anything that does not already have comskip data, which is a good thing, but it does not take account of “Plex Versions”, which I have auto generated. So, if I set the show to be optimized so that it makes another version, then comskip runs twice on the same show, once for the original recording, and once for the Plex Version, and if I have multiple different versions, it runs once for every version. Moreover, if I make the versions at a later time (e.g. make versions of 10 episodes for mobile playback), even though comskip has run on the originals of the show, it’s not smart enough to realize that the other files in “Plex Versions” are just the same show with the same markers, and it runs comskip on them again unnecessarily. This is what was causing my issue. I guess at least I know now, and if I want to keep multiple versions I have to take the hit.
I’m still not sure it is running comskip during “Scheduled Tasks”. Unfortunately it only keeps 5 historic log files at about 10 meg each, and I’m writing enough logs to burn through them all in less than an hour, so I only have one hours worth of log history. From what I can see, comskip was not run last night, but I need to play with the log settings to know for sure.
So, it does run a commercial scan as part of Scheduled Tasks, but there is no way to control what order it scans in; it seems to go by library, and then directory within the library, starting with the oldest files first, but I’m not entirely certain.
Because I have very big libraries enabled for commercial scanning, and many of the files in the library have either not previously been scanned for commercials, or don’t contain any commercials, comscan ends up running for pretty much the entire maintenance window, and only gets through a small percentage of the library, and it’s mostly old stuff that I won’t watch again for a while; it never makes it to my more current recordings.
What I’m going to do to solve the problem, is set the Scheduled Tasks window to the entire 24 hours in a day, and just let it run for a day or two to scan everything in the libraries so that it catches up, and then once it is up-to-date, I’ll set the window back to an 8 hour period at night.
So, summary for anyone reading this at a later time (which I will mark as the solution)
comskip is not run on non-recorded items when Plex detects that it was added to the library; it is only run periodically during the “Scheduled Tasks” window, which can be set in the settings
You can override this by manually choosing “Analyze” on any episode, the entire show, or the movie, or the entire library, and comskip will run immediately. I have found that “Analyze” on the entire library doesn’t seem to work properly, but that is taken care of in “Scheduled Tasks” (see below)
If there are multiple versions of the same episode or movie (e.g. because optimize has been used and the file was placesd in “Plex Versions”), Plex Commercial Skipping is not smart enough to work out that it is the same video, and it will run comskip over again on every version of the same video file.
During “Scheduled Tasks”, there is no control over the order in which files are chosen for comskip processing; it will run on the entire library. If you have a large library which has been marked for commercial skipping, it may literally take days to get through it all. All the files are processed, including the ones which are already watched, there is no control over this. This happens even if the file has no commercials; comskip needs to be run on it to determine that, and it takes just as long to run whether the video has commercials or not. All versions of every video in a library will be processed individually regardless of settings, but Plex does mark that they have been processed and will not run comskip on them multiple times.
You just need to be aware of all these caveats if you enable commercial skipping on an existing library which has a lot of videos (including all the various versions of them)
Footnote: Note that the only way to get any insight into what comskip is doing is to look at the Plex logs (as @pshanew mentioned). These logs are purged after 5 files of 10 meg each. For me, that’s only about an hour of log history.
For anyone interested in gathering historical information about what files were already processed (or are being processed) by comskip (Linux/UNIX only). I added the following to my crontab
What this will do is run a job every 10 minutes to find any files that were (or are being) processed by “Commercial Skipper”. It uses a combination of grep and sed to find the file in the Plex server log, and then appends it to comskip_done.log in the Plex log directory…being an old UNIX hack, this kind of thing is easy for me to knock up (one of several reasons why I run Linux on all my servers)
Do you have verbose logging enabled under Settings → [Server Name] → General? If so, that will burn through the default number of log files to be kept (5) pretty quickly. Verbose is generally not needed (or wanted) for most situations for exactly this reason. Though, you can increase the number of past log files to retain by adjusting the hidden server setting LogNumFiles.
I did, but I turned it off and saved. It didn’t seem to make much difference to the size.
There is a chance that the media server won’t pick it up until next restart I guess. Being a Linux server box (i.e. way more reliable than Windows), my machine will run 24x7 for months without a restart; and I don’t usually get much of a window to schedule a plex server restart, it is always processing something or another. I have a plexmediaserver restart scheduled over the weekend, if I can get the family to stop watching and recording stuff, so I’ll see if that fixes it.
Having said that, I like the idea keeping a historical log of what comskip did anyway, that way I know if a particular show has been processed.
Yep, there was a change made to the server October of last year to require a server restart whenever the its log-level was downgraded. So hopefully that’ll kick in on your next server restart. If nothing else, it will save some “disk” I/O. Verbose is very, well, verbose.
I always had verbose logging off, and only debug logging on. I guess my server just generates a lot of logs.
I might set up a cron job to archive them from my system disk (small NVME drive) to my larger (multi-terabyte) mechanical media drive, but a job for another day I guess.