Jump to content

ComSkipper ... A Emby Plugin that skips commercials


BillOatman

Recommended Posts

vdrover

Performance testing 2: live- vs. post-processing

In my first performance analysis, I described in detail the methodology I used to monitor the effects of multithreading and low resolution detection on server performance and commercial detection time while using comskip. 

I used the same methodology in this analysis, so I won't repeat it here. However, my goal was the same: to find the most efficient way to use comskip while keeping my server load at or below 3. 

Live detection has the advantage of being able to skip commercials while shows are still recording. At the same time, it might be an added burden on your server. To determine if this was the case, I measured server load while recording shows and detecting commercials. 

Effects of post-processing

In my first test, I monitored server load in a seventy minute interval starting when a new recording began. I knew from my earlier analysis that 70 minutes would be enough time to record a 60-minute show and complete the detection of commercials after the recording was complete ("post processing"). 

As you can see below, the server load hovered just above or just below the baseline (shown in blue) during the 60 minute recording interval. When recording one or two shows, not much change was observed when detecting commercials in the 60-70 minute interval after recording had finished.

However, there was a clear spike in server load in the post processing window when 3 shows were recorded at once. Even 15 minutes after recording completed, the server load had not yet returned to baseline.

comskip-post.png.3a5ba60c6b44106e5b933a03a2ff9230.png

Effects of live-processing

Next, I repeated my server load measurements for the same 70-minute interval, but with live commercial detection (live processing). When recording a single show, the server load hovered just above or just below the baseline. 

When recording 2 or 3 shows at once, the server load trended higher than baseline with a few spikes evident in first 60 minutes (example, 35 minutes). However, once recording was complete, the server returned to baseline within 2 minutes regardless of the number of shows being recorded.

comskip-live.png.png.22b96532ea51aaf23f6debda6ce1c5da.png

Recording 3 shows

Since 3 simultaneous recordings put the most strain on the server, I thought it might be helpful to compare the post- and live-processing data on the same graph to get a relative idea of the peaks in load. As you can see, live processing shows a number of load spike while recording, with post-processing showing a large spike after recording with a slow return to baseline. 

3-shows-compared.png.2a304d7969005fc81f53c28b41106b2d.png

Comparing peak server load

As shown above, the spike in server load when post-processing 3 shows is higher than any spike when live-processing commercial detection. I processed the existing data to isolate and plot the peak server load for all of the conditions above. As expected, the highest server load occurs when post-processing 3 shows.

However, this was not a consistent trend. The peak server load when recording one show was higher for post-processing. But live-processing was higher when recording two shows. This is likely due to the variability in server load, which is quite high even when no recording or commercial detection  is in progress, and the low sample size (n=1). 

peak-server-loads.png.661f992e3f3a0116b3469190aca4cf06.png

Comparing average server load

Due to the inherent variability in server load and small sample size, I thought average server load might be informative. As you can see below, the average server loads over the entire 70-minute interval did not exceed 2.25. This is well within my goal of keeping server load at or below 3.

avg-server-load.png.df960ea8d06c869745ad61bea492bf32.png

Conclusions

Based on the data presented above, I make the following conclusions:

  1. Average server load is comparable when detecting commercials with comskip either post-processing or live-processing.
  2. Post-processing with 3 shows simultaneously causes the largest peak in server load.
  3. Post-processing takes longer to complete then live processing.

Given these conclusions, I will definitely be using live processing for commercial detection. Although average server loads may be a marginally higher in some cases, the peak server load is generally lower for live processing, the detection process completes sooner, and commercials can be skipped when watching a show that is still recording.

Edited by vdrover
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

ttgapers

This is awesome @vdrover :)

@BillOatman I can confirm this is working with the latest server beta and Firestick client.

Edited by ttgapers
  • Like 1
  • Agree 1
  • Thanks 1
Link to comment
Share on other sites

Spaceboy

while this was well done research, it didnt really confirm anything that wasnt expected.

i'd have been more interested in the impact of the detection method on accuracy of detection as i believe its possible that detection post recording is more accurate than in progress

  • Like 1
  • Agree 1
Link to comment
Share on other sites

vdrover

That’s a good idea. I’ll test that.  
 

 I was expecting live processing to be more cpu intense based on the documentation in the plug-in. 

  • Like 2
  • Agree 1
Link to comment
Share on other sites

reneboulard
22 hours ago, Spaceboy said:

while this was well done research, it didnt really confirm anything that wasnt expected.

i'd have been more interested in the impact of the detection method on accuracy of detection as i believe its possible that detection post recording is more accurate than in progress

It is a fact that postprocessing detection is more accurate, since comskip use the data for the complete show before making decision on cuts.   On live show it only make decision on cut on small segment of the show.  But it also depend on the show and the channel the processing is done.  When the logo detection is accurate usely preprocessing is very accurate.  When commecial are separated from the show with black frames the detection is also very accurate.  I found that live show like news casts or sport are less accurate.

I keep the logo detection done by comskip on postprocessing and use it for preprocessing of the next show on the same channel.  I found the pre-processing more accurate this way (If the logo detection was good).

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
jdebuhr

II currently have Emby installed in a Jail on my TrueNAS server. I have read through some of the posts and looking for info on how to install this plug in on that. If I go to settings and look in the plugins catalog I don't see it, so I am not quite sure on the correct way to install it

any ideas? 

 

Link to comment
Share on other sites

Spaceboy
6 hours ago, mike3821 said:

How does live recording commercial skip work?

are you asking about the creation of the edl files or the actual skipping?

Link to comment
Share on other sites

mike3821
2 hours ago, Spaceboy said:

are you asking about the creation of the edl files or the actual skipping?

I’m referring to being able to skip commercials while watching an active recording.

I have a working setup now, but the script that calls comskip is after the recording is complete.

Link to comment
Share on other sites

BillOatman
4 hours ago, mike3821 said:

I’m referring to being able to skip commercials while watching an active recording.

I have a working setup now, but the script that calls comskip is after the recording is complete.

There is a different setup if you want to do this.  It is described at the bottom of the supplied PDF document, which I also attached here. 

Commercial Skipper Plugin.pdf

Link to comment
Share on other sites

BillOatman
Posted (edited)
13 hours ago, jdebuhr said:

II currently have Emby installed in a Jail on my TrueNAS server. I have read through some of the posts and looking for info on how to install this plug in on that. If I go to settings and look in the plugins catalog I don't see it, so I am not quite sure on the correct way to install it

any ideas? 

 

It is not, and will likely not ever be, in the plugins catalog.  You need to install the DLL manually on your server wherever the other plugin DLLs are. There is other setup work required as well so I suggest looking at the PDF, which I attached to the previous post.

Edited by BillOatman
Link to comment
Share on other sites

jdebuhr
2 hours ago, BillOatman said:

It is not, and will likely not ever be, in the plugins catalog.  You need to install the DLL manually on your server wherever the other plugin DLLs are. There is other setup work required as well so I suggest looking at the PDF, which I attached to the previous post.

Is the rest of the setup dealing with ComSkip itself? I am hoping to use the EDL files generated by Channels DVR as I use Channels DVR to do my recording

Link to comment
Share on other sites

BillOatman
On 4/7/2022 at 12:53 PM, jdebuhr said:

Is the rest of the setup dealing with ComSkip itself? I am hoping to use the EDL files generated by Channels DVR as I use Channels DVR to do my recording

Largely but have a look, it will likely save questions later.  It will work with any valid EDL file regardless of the creator so long as the naming convention is followed (again, in the PDF :) ).

Link to comment
Share on other sites

jdebuhr

Ok, so I have read the PDF. What I did not see is what video file extensions it supports. Is it only .ts? I know that channels uses a differ extension. I do know the video file and .EDL files match in naming. 
 

I will check the file extension when I can. But if ConSkipper only uses .TS any chance of using others?

Link to comment
Share on other sites

BillOatman
Posted (edited)
2 hours ago, jdebuhr said:

Ok, so I have read the PDF. What I did not see is what video file extensions it supports. Is it only .ts? I know that channels uses a differ extension. I do know the video file and .EDL files match in naming. 
 

I will check the file extension when I can. But if ConSkipper only uses .TS any chance of using others?

Comskipper is extension agnostic. I hate asking stupid questions, but you did you enable the plugin in its settings?

Also if you are running Emby beta it may or may not work,  Emby beta's are a moving target and are unpredictable for plugins.

If you enable debug logging and start playback and let it go past where the EDL says there is a commercial and send me the log, I'll have a look.

Edited by BillOatman
Link to comment
Share on other sites

jdebuhr

OK. 

Yes Enabled, actually on my Apple TV with it enabled and the on screen message is enabled it goes back to the screen for the show where you select resume ,play etc and I cannot get back to the video. 

I disabled the OSD for Skipping and restarted the same show and it skips at the commercials. not sure why it was not working before, I originally had it set for skip and no OSD, but switched it for testing purposes. 

I will say it is very nice to have Comskip in Emby. Thanks for the plugin

 

  • Like 1
Link to comment
Share on other sites

BillOatman
15 hours ago, jdebuhr said:

OK. 

Yes Enabled, actually on my Apple TV with it enabled and the on screen message is enabled it goes back to the screen for the show where you select resume ,play etc and I cannot get back to the video. 

I disabled the OSD for Skipping and restarted the same show and it skips at the commercials. not sure why it was not working before, I originally had it set for skip and no OSD, but switched it for testing purposes. 

I will say it is very nice to have Comskip in Emby. Thanks for the plugin

 

Glad you got it sorted out, enjoy!

Link to comment
Share on other sites

  • 4 weeks later...
jachin99

I don't think this is working the way it should.  when I run the bat file on its own I get a message that comskip cannot open .ts files.  I have the donators version of comskip, and I altered the example bat for my actual comskip location.  Do I need to alter it for my media drives as well?  They're stored on my E drive.  Here is my bat and error message


C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>set drive=

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>set folder=

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>set filename=

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>c:

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>cd C:\Users\Family\AppData\Roaming\Emby-Server\Comskip

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>comskip --ini=comskip.ini "   .ts"
 Comskip 0.82.010, made using ffmpeg
Donator build
The commandline used was:
comskip --ini=comskip.ini "   .ts"

Setting ini file to comskip.ini as per commandline
Using comskip.ini for initiation values.
Mpeg:      .ts
Exe     comskip.exe
Logo:      .logo.txt
Ini:    comskip.ini

Detection Methods to be used:
        1) Black Frame
        2) Logo - Give up after 2000 seconds
        3) Resolution Change
        4) Aspect Ratio


ComSkip throttles back from -0001 to -0001.
The time is now 2047 so it's full speed ahead!

Settings
--------
[Main Settings]
;the sum of the values for which kind of frames comskip will consider as possible cutpoints: 1=uniform (black or any other color) frame, 2=logo, 4=scene change, 8=resolution change, 16=closed captions, 32=aspect ration, 64=silence, 255=all.
detect_method=43
;Set to 10 to show a lot of extra info, level 5 is also OK, set to 0 to disable
verbose=10
;Frame not black if any of the pixels of the frame has a brightness greater than this (scale 0 to 255)
max_brightness=60
maxbright=1
;Frame not pure black if a small number of the pixels of the frame has a brightness greater than this. To decide if the frame is truly black, comskip will also check average brightness (scale 0 to 255)
test_brightness=40
;
max_avg_brightness=25
;
max_commercialbreak=600
;
min_commercialbreak=25
;
max_commercial_size=125
;
min_commercial_size=4
;
min_show_segment_length=250
;
max_volume=500
;
max_silence=100
;
non_uniformity=500
[Detailed Settings]
min_silence=12
remove_silent_segments=0
noise_level=5
brightness_jump=200
fps=1
validate_silence=1
validate_uniform=1
validate_scenechange=1
global_threshold=1.05
disable_heuristics=4
cut_on_ac_change=1
[CPU Load Reduction]
thread_count=2
hardware_decode=0
play_nice_start=-1
play_nice_end=-1
play_nice_sleep=2
[Input Correction]
max_repair_size=200
ms_audio_delay=5
volume_slip=40
lowres=0
skip_b_frames=0
[Aspect Ratio]
ar_delta=0.08
cut_on_ar_change=1
[Global Removes]
padding=0
remove_before=0
remove_after=0
added_recording=14
delete_show_after_last_commercial=0
delete_show_before_first_commercial=0
delete_show_before_or_after_current=0
delete_block_after_commercial=0
min_commercial_break_at_start_or_end=39
always_keep_first_seconds=0
always_keep_last_seconds=0
[USA Specific]
intelligent_brightness=0
black_percentile=0.0076
uniform_percentile=0.003
score_percentile=0.71
[Main Scoring]
length_strict_modifier=3
length_nonstrict_modifier=1.5
combined_length_strict_modifier=2
combined_length_nonstrict_modifier=1.25
ar_wrong_modifier=2
ac_wrong_modifier=1
excessive_length_modifier=0.01
dark_block_modifier=0.3
min_schange_modifier=0.5
max_schange_modifier=2
logo_present_modifier=0.01
punish_no_logo=1
[Detailed Scoring]
punish=0
reward=0
punish_threshold=1.3
punish_modifier=2
reward_modifier=0.5
[Logo Finding]
border=10
give_up_logo_search=2000
delay_logo_search=0
logo_max_percentage_of_screen=0.12
ticker_tape=0
ticker_tape_percentage=0
top_ticker_tape=0
top_ticker_tape_percentage=0
ignore_side=0
ignore_left_side=0
ignore_right_side=0
subtitles=0
logo_at_bottom=0
logo_threshold=0.75
logo_percentage_threshold=0.25
logo_filter=0
aggressive_logo_rejection=0
edge_level_threshold=5
edge_radius=2
edge_weight=10
edge_step=1
num_logo_buffers=50
use_existing_logo_file=1
two_pass_logo=1
[Logo Interpretation]
connect_blocks_with_logo=1
logo_percentile=0.92
logo_fraction=0.4
shrink_logo=5
shrink_logo_tail=0
before_logo=0
after_logo=0
where_logo=0
min_black_frames_for_break=1
[Closed Captioning]
ccCheck=0
cc_commercial_type_modifier=4
cc_wrong_type_modifier=2
cc_correct_type_modifier=0.75
[Live TV]
live_tv=0
live_tv_retries=4
require_div5=0
div5_tolerance=-1
incommercial_frames=1000
[Output Control]
output_default=1
output_chapters=0
output_plist_cutlist=0
output_zoomplayer_cutlist=0
output_zoomplayer_chapter=0
output_scf=0
output_vcf=0
output_vdr=0
output_projectx=0
output_avisynth=0
output_videoredo=0
output_videoredo3=0
videoredo_offset=2
output_btv=0
output_edl=1
output_live=0
edl_offset=0
timeline_repair=1
edl_skip_field=0
output_edlp=0
output_bsplayer=0
output_edlx=0
output_cuttermaran=0
output_mpeg2schnitt=0
output_womble=0
output_mls=0
output_mpgtx=0
output_dvrmstb=0
output_dvrcut=0
output_ipodchap=0
output_framearray=0
output_debugwindow=0
output_tuning=0
output_training=0
output_false=0
output_aspect=0
output_demux=0
output_data=0
output_srt=0
output_smi=0
output_timing=0
output_incommercial=0
output_ffmeta=0
output_ffsplit=0
delete_logo_file=0
output_mkvtoolnix=0
cutscene_frame=0
cutscene_threshold=10
windowtitle="Comskip - %s"
cuttermaran_options="cut=\"true\" unattended=\"true\" muxResult=\"false\" snapToCutPoints=\"true\" closeApp=\"true\""
mpeg2schnitt_options="mpeg2schnitt.exe /S /E /R25  /Z %2 %1"
avisynth_options="LoadPlugin(\"MPEG2Dec3.dll\") \nMPEG2Source(\"%s\")\n"
dvrcut_options="dvrcut \"%s.dvr-ms\" \"%s_clean.dvr-ms\" "
[Sage Workarounds]
sage_framenumber_bug=0
sage_minute_bug=0
enable_mencoder_pts=0

   .ts: Can not open file
   .ts: Can not open file
   .ts: Can not open file
   .ts: Can not open file
   .ts: Can not open file

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>del "  .log"
Could Not Find C:\Users\Family\AppData\Roaming\Emby-Server\Comskip\  .log

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>del "  .logo.txt"
Could Not Find C:\Users\Family\AppData\Roaming\Emby-Server\Comskip\  .logo.txt

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>del "  .txt"
Could Not Find C:\Users\Family\AppData\Roaming\Emby-Server\Comskip\  .txt

C:\Users\Family\AppData\Roaming\Emby-Server\Comskip>pause
Press any key to continue . . .

 

Link to comment
Share on other sites

BillOatman

@jachin99You do have the donators version.  Check for permissions and make sure you don't have any extra spaces in your bat or ini files. Otherwise I don't know what is causing that.

Link to comment
Share on other sites

vdrover

@jachin99 One of my early INI files had a missing semi-colon. I found it by deleting like 90% of the lines from the bottom-up, and rerunning comskip. There was no error. 

 

Then I added 25% of the ini content back and tested again. I found the problematic line by repeating this process. 

Note that none of this was done with the match file, all with comskip directly. Once I had that working, I moved on to the match fille. 

Link to comment
Share on other sites

richt

I found an additional setting for the comskip.ini file that allows comskip to skip processing the last x seconds of a video file.  This is a helpful with some programs that have a short segment after the last commercial break.  I found that without this setting I was missing that short segment on some programs.

always_keep_last_seconds=60	; Sets comskip to not process last x seconds of file

Likewise there is a similar setting for the first x seconds of a recording.

always_keep_first_seconds=60

I didn't find either of these in the comskip.ini sample file that comes with comskip.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

BillOatman
1 hour ago, richt said:

I found an additional setting for the comskip.ini file that allows comskip to skip processing the last x seconds of a video file.  This is a helpful with some programs that have a short segment after the last commercial break.  I found that without this setting I was missing that short segment on some programs.

always_keep_last_seconds=60	; Sets comskip to not process last x seconds of file

Likewise there is a similar setting for the first x seconds of a recording.

always_keep_first_seconds=60

I didn't find either of these in the comskip.ini sample file that comes with comskip.

Great find!!

Link to comment
Share on other sites

jachin99
Posted (edited)

I have the donators version, and I even updated to the latest comskip.  I checked my INI, and bat file.  The only thing I have changed from your example script is is the directory for comskip.  Do I have to set my media drives or any folders in this script?  TO be clear, I'm testing this out outside of emby by just running the bat by itself.  Does It need the {Path} argument to work?

Edited by jachin99
Link to comment
Share on other sites

Are you sure that the referenced error doesn't just mean that it can't find the ts file and not that it can' process a ts file?

   .ts: Can not open file
Link to comment
Share on other sites

BillOatman
Posted (edited)
14 hours ago, jachin99 said:

I have the donators version, and I even updated to the latest comskip.  I checked my INI, and bat file.  The only thing I have changed from your example script is is the directory for comskip.  Do I have to set my media drives or any folders in this script?  TO be clear, I'm testing this out outside of emby by just running the bat by itself.  Does It need the {Path} argument to work?

Oh yes of course.  That's what tells it what file to work on.

Edited by BillOatman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...