Commercial detection running every night on same files

Server Version#: 1.41.0.8911
Player Version#: N/A

Very simply, comskip runs over the same files many times. This chews up CPU time and energy for no reason. There don’t appear to be any errors or other failure signals in the logs.

Presumably this is not how the feature is supposed to work as it seems very wasteful.

Here’s an extract from my logs which shows the same recording is scanned for commercials (you’ll have to trust me that this is coming from commercial detection) every night for the last week.

2024-09-20 05:33:57.969	
	"[...]/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts"
	
	
2024-09-21 05:33:07.205	
	"[...]/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts"
	
	
2024-09-22 05:34:49.578	
	"[...]/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts"
	
	
2024-09-23 05:28:21.456	
	"[...]/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts"
	
	
2024-09-24 05:32:22.164	
	"[...]/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts"
	
	
2024-09-25 05:32:03.170	
	"[...]/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts"
	
	
2024-09-26 05:35:01.412	
	"[...]/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts"

I would be interested to understand this behaviour if possible.

2 Likes

Please post the entire XML info for one of the files being repeatedly scanned for commercials. It will show if there are commercial markers; if not, it is expected that it will continue to be scanned for them.

<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="1" allowSync="1" identifier="com.plexapp.plugins.library" librarySectionID="2" librarySectionTitle="Series" librarySectionUUID="c823326a-d87a-48f3-b717-c1880f9154b1" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1724315646">
<Video ratingKey="72198" key="/library/metadata/72198" parentRatingKey="71910" grandparentRatingKey="71863" guid="plex://episode/5fc6e26a3f000e002dfa8764" parentGuid="plex://season/5fc6aafb3f000e002df573c7" grandparentGuid="plex://show/5fc6aafb3f000e002df573c7" type="episode" title="Get Grilling" grandparentKey="/library/metadata/71863" parentKey="/library/metadata/71910" librarySectionTitle="Series" librarySectionID="2" librarySectionKey="/library/sections/2" grandparentTitle="Barefoot Contessa: Back to Basics" parentTitle="Season 13" summary="The delightful Ina Garten reveals her cooking tips. Ina prepares a delicious grilled feast of Indonesian swordfish and later, a chef Joe Realmuto concocts a punchy BBQ sauce." index="17" parentIndex="13" lastRatedAt="0" year="2010" thumb="/library/metadata/72198/thumb/1725516000" art="/library/metadata/72198/art/1725516000" grandparentThumb="/library/metadata/71863/thumb/1724390999" grandparentArt="/library/metadata/71863/art/1724390999" duration="1796760" originallyAvailableAt="2010-01-30" addedAt="1725515999" updatedAt="1725516000">
<Media id="148778" duration="1796760" bitrate="4146" width="1024" height="576" aspectRatio="1.78" audioChannels="2" audioCodec="mp2" videoCodec="h264" videoResolution="576" container="mpegts" videoFrameRate="PAL" channelIdentifier="5fc76db2052f6f002e031bbe-5fc706063f45c6002eab58cf" mediaGrabBeginsAt="1725514200" mediaGrabDevice="device://tv.plex.grabbers.hdhomerun/1232F697" mediaGrabStatus="complete" origin="dvr" videoProfile="main" hasVoiceActivity="0">
<Part accessible="1" exists="1" id="155435" key="/library/parts/155435/1725515999/file.ts" duration="1796760" file="/data/media/DVR/TV/Barefoot Contessa Back to Basics (2002)/Season 13/Barefoot Contessa Back to Basics (2002) - S13E17 - Get Grilling.ts" size="963900064" container="mpegts" deepAnalysisVersion="6" indexes="sd" packetLength="188" requiredBandwidths="7016,6291,5372,5145,5145,5145,5145,5145" videoProfile="main">
<Stream id="336739" streamType="1" codec="h264" index="0" bitrate="4010" bitDepth="8" chromaLocation="left" chromaSubsampling="4:2:0" codedHeight="576" codedWidth="1024" frameRate="25.000" hasScalingMatrix="0" height="576" level="31" profile="main" refFrames="4" requiredBandwidths="6878,6153,5232,5014,5014,5014,5014,5014" scanType="progressive" streamIdentifier="256" width="1024" displayTitle="480p (H.264)" extendedDisplayTitle="480p (H.264)">
</Stream>
<Stream id="336740" streamType="2" selected="1" codec="mp2" index="1" channels="2" bitrate="128" language="English" languageTag="en" languageCode="eng" audioChannelLayout="stereo" requiredBandwidths="128,128,128,128,128,128,128,128" samplingRate="48000" streamIdentifier="257" displayTitle="English (MP2 Stereo)" extendedDisplayTitle="English (MP2 Stereo)">
</Stream>
<Stream id="336741" streamType="3" canAutoSync="0" codec="dvb_subtitle" index="2" bitrate="8" language="English" languageTag="en" languageCode="eng" requiredBandwidths="12,12,12,12,12,12,12,12" streamIdentifier="258" displayTitle="English (DVB_SUBTITLE)" extendedDisplayTitle="English (DVB_SUBTITLE)">
</Stream>
</Part>
</Media>
<Image alt="Get Grilling" type="coverPoster" url="/library/metadata/71863/thumb/1724390999" />
<Image alt="Get Grilling" type="snapshot" url="/library/metadata/72198/thumb/1725516000" />
<Image alt="Get Grilling" type="background" url="/library/metadata/72198/art/1725516000" />
<UltraBlurColors topLeft="24340c" topRight="35461e" bottomRight="1e1f09" bottomLeft="120d0b" />
<Genre id="186299" filter="genre=186299" tag="Cooking" />
<Genre id="186300" filter="genre=186300" tag="How-to" />
<Genre id="186293" filter="genre=186293" tag="Entertainment" />
<Genre id="186301" filter="genre=186301" tag="Food + Home" />
<Channel id="186302" filter="channel=186302" tag="043 FOODNET (Food Network)" />
<Marker final="1" id="32956" type="credits" startTimeOffset="1751084" endTimeOffset="1796760">
<Attributes id="32956" version="4" />
</Marker>
<Field locked="1" name="thumb" />
<Field locked="1" name="art" />
<Extras size="0">
</Extras>
<Related>
</Related>
</Video>
</MediaContainer>

It would seem not to have any commercial markers. Presumably this could simply be because the programme doesn’t have commercials (though in this case it does, they’re just not detected), so it seems strange not to have recorded a ‘no commercials found’ marker or similar to prevent endless, futile rework.

Why should a video file be scanned more than one time if the video file did not change?

I’m not saying that it should be, only that it will be. Plex stores no information about whether or not commercial skipping has been performed on a file; it bases its decision to scan for them upon the presence or absence of the markers.

This is based on experience, and not just conjecture. If you’ve got a library configured to detect commercials, and there are files within which contain none, it will attempt to scan them.

@_j You’re correct, this file has not ad markers and as such will continue to be scanned. I think there may be a feature request to change this behavior, but I can’t find it right now.

I consider this to be a bug. It simply does not make sense. If somebody from Plex could please confirm this?

@tom80H @sa2000 @OttoKerner Anybody?

I would like to have some kind of “official” info - and if this is not a bug but intended behavior then I need to switch that off permanently in my TV show libraries. Most of my several thousands of episodes have no commercials.

I’m not familiar with this feature (yet).
It looks like you should be able to disable it for each library:
> Manage Library > Edit...Advanced > Ad detection = Disabled

On Linux you can review the journal to see what Plex is doing:

sudo journalctl -u plexmediaserver

Should see something like

 Plex Commercial Skipper, made using ffmpeg
 Donator build
 The commandline used was:
 [21.0K blob data]
 109242 frames decoded in 281.53 seconds (388.03 fps)
         "/usr/lib/plexmediaserver/Plex Commercial Skipper"
         "--ini=/plex/Library/Application Support/Plex Media Server/DVR/comskip.ini"
         "--output=/plex/tv/60 Minutes (1968)/Season 56"
         -t
         --quiet
         "/plex/tv/60 Minutes (1968)/Season 56/60 Minutes (1968) - S56E52 - Crisis at Pearl Harbor; Dr Kuznetsov; Indian Relay.ts"
 Setting ini file to /plex/Library/Application Support/Plex Media Server/DVR/comskip.ini as per commandline
 Using /plex/Library/Application Support/Plex Media Server/DVR/comskip.ini for initiation values.
 Auto selecting the PID.
 Commercials were not found.

Commercials weren’t found because there was a stationary storm warning logo that was present through the whole program blocking detection. I just watch and delete, primary reason to keep the DVR libraries separate from the everything else.

1 Like

This seems to be a regression as PMS-Linux v.1.32.8.7639 didn’t have this issue. After upgrading to the latest version with saved DVR recordings that were present before the upgrade this issue occurs daily. Files with this issue don’t have any commercial skip markers when looking at the XML. I keep some DVR recordings, so this issue is a problem.

The workaround seems to be disabling the Library Ad detection noted here: Commercial detection running every night on same files - #7 by tom80H
and then enabling ad detection per DVR recording as this option is still present in current PMS versions. I have verified that disabling the Library Ad detection does not re-trigger a daily commercial skip scan of DVR recordings.

Edit: I was able to see the issue in the PMS supervisord.log before using the workaround. This OTA DVR recording was set to “Detect and Delete Commercials” from: Live TV / DVR Schedule. Notice the original recording successfully detected and deleted commercials. Afterwards, the feature in “TV Shows Library / Ad detection” ran again since the DVR recording has no ad markers probably since the “Commercial Skipper” feature removed them previously:

PMS supervisord.log of the original OTA DVR recording:

2024-09-30 22:32:02,191 DEBG 'plexmediaserver' stderr output:

1223238 frames decoded in 2821.51 seconds (433.54 fps)

2024-09-30 22:32:03,759 DEBG 'plexmediaserver' stdout output:
	"/usr/lib/plexmediaserver/Plex Commercial Skipper"
	--ini=/usr/lib/plexmediaserver/Resources/comskip.ini
	"--output=/media/Media/TV Shows/.grab/5f1e3913c1b37be2ba75ba17ad02af5e2b90a497-9f0dbe7938b03467e0933e871d1783775ac68ece"
	-t
	--quiet
	"/media/Media/TV Shows/.grab/5f1e3913c1b37be2ba75ba17ad02af5e2b90a497-9f0dbe7938b03467e0933e871d1783775ac68ece/NFL Football (2002) - 2024-09-30 06 00 00 - Seattle Seahawks at Detroit Lions.ts"

Setting ini file to /usr/lib/plexmediaserver/Resources/comskip.ini as per commandline
Using /usr/lib/plexmediaserver/Resources/comskip.ini for initiation values.
Auto selecting the PID.
Commercials were found.

PMS supervisord.log of the TV Shows Library / Ad detection which ran again since the DVR recording has no ad markers probably since the “Commercial Skipper” feature removed them previously:

2024-10-01 03:06:23,135 DEBG 'plexmediaserver' stderr output:

594140 frames decoded in 1438.92 seconds (412.91 fps)

2024-10-01 03:06:23,409 DEBG 'plexmediaserver' stdout output:
	"/usr/lib/plexmediaserver/Plex Commercial Skipper"
	--ini=/usr/lib/plexmediaserver/Resources/comskip.ini
	"--output=/media/Media/TV Shows/NFL Football (2002)/Season 2024"
	-t
	--quiet
	"/media/Media/TV Shows/NFL Football (2002)/Season 2024/NFL Football (2002) - 2024-09-30 06 00 00 - Seattle Seahawks at Detroit Lions.ts"

Setting ini file to /usr/lib/plexmediaserver/Resources/comskip.ini as per commandline
Using /usr/lib/plexmediaserver/Resources/comskip.ini for initiation values.
Auto selecting the PID.
Commercials were found.
1 Like

Thanks @Bladerun1, that’s particularly interesting as it would strongly imply that this is indeed not the intended behaviour.

I’ve disabled the feature at the library level as you suggest and will observe the results over the next couple of days.

The obvious next question is how this issue would best make its way into a bug report in the proper place (appreciating that it may or may not end up being fixed). Am I right in thinking that this happens effectively by chance—if some suitably empowered person happens to look at this thread and take sufficient interest in it?

Following up on this, unfortunately the suggestion of disabling ad detection at the library level but enabling it at the DVR and programme level does not seem to have had the desired effect. Whilst I can see from the logs that comskip runs and detects commercials at the end of the recording session, when the recording then lands in the library its XML info contains no commercial markers.

The documentation isn’t clear about how the DVR-, programme-, and library-level settings interact. My observations would suggest that turning off at the library level prevents the skip markers being saved after detection. Clarification would be very welcome!

This then, sadly, takes me back to square one: the process re-running over the same files every night if I want to be able to skip commercials. Given power consumption was front and centre at this year’s Plex Pro week, it would be great to find a proper resolution to this somehow.

I was tremendously excited to see the following in yesterday’s release of PMS:

NEW:

  • (AdDetection) Ad detection can now be run on media add (PM-1988)

After some searching around in the relevant settings pages, I think this is referring to the addition of the following. Sadly, I don’t think this is of any benefit to the issue described here :cry:.

  • Settings →
    • Library →
      • Generate ad video markers →
        • as a scheduled task and when media is added

Please do jump in if I’m missing something. Continuing to hope for some improvement. Further electricity will be wasted in the meantime :money_with_wings:.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.