• The forum software that supports hummy.tv has been upgraded to XenForo 2.1!

    This upgrade brings a number of improvements including the ability to bookmark posts to come back to later. Please bear with us as we continue to tweak things and open a new thread for any questions, issues or suggestions in Site/Forum Issues.

Detect Ads

Matthew

Member
If you do a 'manual' crop of a file the original is placed in a '_original' folder which seems the best way to me, but if you do a 'auto crop' with detect ads following detection the original stays in place and the cropped file named *.-crop.

Would it not be better if the detect ads auto process kept to the manual process method? If the renaming is prefered would it not be better to rename the original *-orig instead of the cropped as its most likely the cropped is the one that will be kept?
 

Matthew

Member
The following is an update to the previous mod on adjusting cropping bookmarks and only affects the detectads.jim file, it adds the automatic post crop bookmarks detailed here https://hummy.tv/forum/threads/automatic-edit-point-bookmarks-following-crop.9057/#post-127986 excepting the save is automatic too for this process.

This code will always create at least 2 bookmarks for the file (one at the beginning the other near the end) regardless of any calculated.

Code:
--- /mod/webif/plugin/detectads/detectads_orig.jim
+++ /mod/webif/plugin/detectads/detectads.jim
@@ -152,7 +152,8 @@
       admaxsec  65
       padsec     0
       makethm    0
-      thmoffset  0}
+      thmoffset  0
+      padout     0}
 
     # Override default from settings DB
     foreach {key defvalue} [array get optarray] {
@@ -467,6 +468,7 @@
     $queue_db close
 }
 
+# Manual
 proc ::detectads::run {ts} {
     set file [$ts get file]
 
@@ -479,7 +481,11 @@
            log "Cannot acquire exclusive lock $file, terminating." 0
            return {"DEFER" "Cannot acquire exclusive lock"}
     }
-
+    set stime [$ts get start]
+    set etime [$ts get end]
+    set durn $($etime-$stime)
+    set theend 0
+    set padding 0
     set size [$ts size]
     set numAdBreaks 0
     set bname [file rootname [file tail $file]]
@@ -495,7 +501,14 @@
     foreach {key value} [array get ::opts] {
         set $key $value
     }
-
+       
+    if {$padsec} {
+    set padout 0
+    }
+    if {$padout} {
+    log "Padding out points by $padout secs and ignoring program end bookmark" 0
+    }
+   
     set tailPid 0; # unused (for killing head of pipe on timeout - useful with tail -f recording.ts | ffmpeg ... | silence...)
 
     set silenceArgs "\
@@ -545,9 +558,22 @@
                     startSeconds \
                     endMinutes \
                     endSeconds]} {
-
+   
             set totalStartSeconds [expr {$startMinutes * 60 + $startSeconds}]
-            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds}]
+            if {$cropcmd eq " " && $totalStartSeconds < 10 && $padout} {
+            set padding 2
+            } elseif {$padout} {
+            set padding $padout
+            }
+            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds - $padding}]
+            set endMinutes [expr int($totalEndSeconds / 60)]
+            set endSeconds [expr ($totalEndSeconds % 60)]
+            if { [expr {$totalEndSeconds + 10}] > $durn} {
+               set totalEndSeconds [expr {$totalEndSeconds + $padding}]
+               if {$padout} {
+                  set theend 1
+               }
+            }
 
             log "  ad break found $startMinutes:$startSeconds-$endMinutes:$endSeconds ($totalStartSeconds - $totalEndSeconds)" 0
 
@@ -565,7 +591,11 @@
                         ladd bookmarks 0 $totalStartSeconds $totalEndSeconds
                     }
                 } else {
-                    ladd bookmarks $totalStartSeconds $totalEndSeconds
+            if {$theend == 0} {
+            ladd bookmarks $totalStartSeconds $totalEndSeconds
+                     } else {
+            ladd bookmarks $totalStartSeconds
+                     }
                 }
             }
             # Update bookmarks and build up crop cmd line as each break is detected.- mymsman  150408
@@ -660,7 +690,11 @@
         set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
         log "ad detection.processed in ${elapsedSeconds}s $elapsedTime - $numAdBreaks ad breaks bookmarked, crop starting" 0
 
-
+    # calculate post crop edit point bookmarks
+    set len [$ts duration 1]
+    set newbookmark [editpointbm $bookmarks $len]
+    set originalused 0
+         
         # copy & paste from crop/execute.jim  - mymsman 150407
         set rfile $file
         set dir [file dirname $rfile]
@@ -720,6 +754,7 @@
                 set cfile "$tgtpath/$shname-crop.ts"
                 if {![system inuse $cfile]} {  # Rename crop file to original if not in use
                       ts renamegroup "$cfile" "$shname"
+                      set originalused 1
                 }
            } else {
                 log "$file safe_delete failed" 0
@@ -734,6 +769,11 @@
         set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
         log "done...processed in ${elapsedSeconds}s $elapsedTime - $numAdBreaks ad breaks cropped out" 0
         set retcode [list "OK" "$numAdBreaks ad breaks cropped out" ]
+        # save post crop edit point bookmarks
+        if { !$originalused } {
+                set ts [ts fetch "$tgtpath/$shname-crop.ts"]
+            }
+            $ts setbookmarks $newbookmark
     } else  {
         set elapsedSeconds [elapsed $start]
         set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
@@ -746,6 +786,7 @@
     return $retcode
 }
 
+# Chaserun
 proc ::detectads::chaserun {ts {Qid 0} {retrynumb 0}} {
     # run ad detection against currently recording program using dlna helper - mymsman 150505
     # creates decrypted, cropped and shrunk copy of file in video root directory.
@@ -768,12 +809,23 @@
     }
     set statustok [system startop -multiple detectads $file]
     set size [$ts size]
+    set stime [$ts get start]
+    set etime [$ts get end]
+    set durn $($etime-$stime)
+    set theend 0
+    set padding 0
     set numAdBreaks 0
 
     # set each option from settings/overrides
     foreach {key value} [array get ::opts] {
         set $key $value
-    }
+    }       
+    if {$padsec} {
+    set padout 0
+    }
+    if {$padout} {
+    log "Padding out points by $padout secs and ignoring program end bookmark" 0
+    }   
     set tailPid 0; # unused (for killing head of pipe on timeout - useful with tail -f recording.ts | ffmpeg ... | silence...)
 
     set silenceArgs "\
@@ -788,6 +840,7 @@
     set stime [$ts get start]
     set etime [$ts get end]
     set ctime [clock seconds]
+    set len [$ts duration 1]
 
     # Check file sharing enabled
     if {[system param DMS_START_ON]} {
@@ -955,7 +1008,20 @@
                     endSeconds]}  {
 
             set totalStartSeconds [expr {$startMinutes * 60 + $startSeconds}]
-            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds}]
+            if {$cropcmd eq " " && $totalStartSeconds < 10 && $padout} {
+            set padding 2
+            } elseif {$padout} {
+            set padding $padout
+            }
+            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds - $padding}]
+            set endMinutes [expr int($totalEndSeconds / 60)]
+            set endSeconds [expr ($totalEndSeconds % 60)]
+            if { [expr {$totalEndSeconds + 10}] > $durn} {
+               set totalEndSeconds [expr {$totalEndSeconds + $padding}]
+               if {$padout} {
+                  set theend 1
+               }
+            }
 
             log "  ad break found $startMinutes:$startSeconds-$endMinutes:$endSeconds ($totalStartSeconds - $totalEndSeconds) Frames: $startFrame - $endFrame" 0
 
@@ -975,7 +1041,11 @@
                         ladd bookmarks 0 $totalStartSeconds $totalEndSeconds
                     }
                 } else {
-                    ladd bookmarks $totalStartSeconds $totalEndSeconds
+            if {$theend == 0} {
+            ladd bookmarks $totalStartSeconds $totalEndSeconds
+                     } else {
+            ladd bookmarks $totalStartSeconds
+                     }
                 }
             }
             # Update bookmarks and build up crop cmd line as each break is detected.- mymsman  150408
@@ -1139,7 +1209,7 @@
             set newtitle  "$title -Len err ([clock format $misdetect -format %T])"
         }
     }
-
+    set originalused 0
     if {$lengtherr == 0} {
         # All OK (as far as we can tell)
         set newtitle  "Done"
@@ -1154,6 +1224,7 @@
                     if {![system inuse $cfile]} {  # Rename crop file to original if not in use
                        exec hmt  "+settitle=$title" "$cpath/$cname.hmt"
                        ts renamegroup "$cfile" "$bname"
+                       set originalused 1
                     }
                     if {![system inuse $tfile]} {  # Delete decrypt file no longer needed
                        $tts delete
@@ -1195,7 +1266,18 @@
             }
             close $recording
     }
-
+   
+    if { $crop } {
+ 
+    set newbookmark [ editpointbm $bookmarks $len ]
+
+        # save post crop edit point bookmarks
+        if { !$originalused } {
+                set ts [ts fetch "$tgtpath/$cname.ts"]
+            }
+            $ts setbookmarks $newbookmark
+    }
+   
     if {$tempQid} {
         # remove temporary entryt from the queue
         log "Removing item $tempQid ($file) from the queue" 1
@@ -1217,7 +1299,8 @@
     log "=============================================================" 1
     set ::auto::loglevel ::autologlevel
     return [list $retcode $retmsg $qtime]
-}
+}   
+## proc detectads::chaserun end
 
 proc set_HMT_durn {hmtfn start durn} {
             # Update recording end & stored recording time in hmt file
@@ -1225,3 +1308,41 @@
             exec hmt "+patch32=0x288:$durn"  "$hmtfn.hmt"
 
 }
+
+# calculate post crop edit point bookmarks
+proc editpointbm {bookmarks len} {
+     set keeping 0
+    set start -1
+    set newbookmark "0 "
+    set i -1
+    foreach b $bookmarks {
+        if {$start < 0} {
+            set start $b
+            set removing $b
+            continue
+        }
+        if {$i == 0} {
+            set start $b
+            set endad $($b - $removing)
+            incr removing $($endad - $startad)
+            set i -1
+            continue
+        }
+        set end $b
+        incr keeping $($end - $start)
+        set startad $($b - $removing)
+        append newbookmark "$($startad +3) "   
+        set i 0
+    }       
+    if {$i < 0 && $start > 0} {
+        incr keeping $($len - $start)
+    }
+    set n $([llength $newbookmark] - 1)
+    if {[lindex $newbookmark end] > [expr $keeping - 8] && $n > 0} {
+        set newbookmark [lreplace $newbookmark $n $n]
+        append newbookmark " $($keeping - 8)"
+    } elseif {$n == 0 && $keeping > 0} {
+        append newbookmark " $($keeping - 8)"
+    }
+    return $newbookmark
+}
 

MymsMan

Ad detector
If you do a 'manual' crop of a file the original is placed in a '_original' folder which seems the best way to me, but if you do a 'auto crop' with detect ads following detection the original stays in place and the cropped file named *.-crop.
Only if the "Delete (move to bin) original recording after processing? " setting is Off or a problem is detected

Would it not be better if the detect ads auto process kept to the manual process method?
The problem with the _original folders is that they are not automatically cleaned up and tend to proliferate, the auto process packages, including detectads, normally put deleted original files in the dustbin where they will automatically be deleted after a period.

You have to seriously like watching paint dry to rum detectads in manual 'Run now' mode, most users use one of the auto processing option or add to queue for on-off detection.
That is why I don't see the need for a jump to Crop page button, after waiting half an hour for ad detection to complete do you really need to save a few seconds and mouse clicks - why not just let it do the the cropping whilst ad detecting.
 

Matthew

Member
You have to seriously like watching paint dry to rum detectads in manual 'Run now' mode, most users use one of the auto processing option or add to queue for on-off detection.
That is why I don't see the need for a jump to Crop page button, after waiting half an hour for ad detection to complete do you really need to save a few seconds and mouse clicks - why not just let it do the the cropping whilst ad detecting.
You don't have to watch the page whilst it detects, just leave the tab open and use others, check back later to see if its finished. The auto crop did not work for me before as the bookmarks always needed adjusting, but with the padOut option it works well now so I will continue with that. There are a few programs that Ad Detector doesn't work well with like The Big Bang Theory, but that's not often so getting them from the bin will be fine.
 

MymsMan

Ad detector
here are a few programs that Ad Detector doesn't work well with like The Big Bang Theory,
You can now specify different options for specific series by enabling the Auto Detectads flag for the folder and then Editing the Auto DetectAds options.

I have occasional problems with Countdown and 15to1 on Channel 4, they often include long (90sec) charity appeals in the ad breaks which is too much for the normal -adMaxSec 65 setting but increasing it to 95 sometimes leads to mis-cropping in the middle of the numbers games so I use -delOrig n to keep the original for just those recordings to give me the choice which copy to use
 

Matthew

Member
The two detectads processes return different messages after auto-cropping, one is: x ad breaks cropped out the other: x ad breaks detected,

I suggest the following change to maintain consistency.

Code:
--- /mod/webif/plugin/detectads/detectads_orig.jim
+++ /mod/webif/plugin/detectads/detectads.jim
@@ -1211,13 +1293,17 @@
     set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
     log "done...processed $file in ${elapsedSeconds}s $elapsedTime - $numAdBreaks ad breaks detected" 0
     set retmsg "$numAdBreaks ad breaks detected, $warning"
-
+    if { $crop && $numAdBreaks && $retcode != "FAILED" } {
+        set retmsg "$numAdBreaks ad breaks cropped out. $warning"
+    }
+  
     system endop $statustok
     release_lock $file
     log "=============================================================" 1
     set ::auto::loglevel ::autologlevel
     return [list $retcode $retmsg $qtime]
 
Last edited:

Matthew

Member
Having used Detectads with my padOut mod for a number of programs now I feel there is just one tweak needed, the 1st break adjustment needs to be 3secs not 2secs

ie both set padding 2 should be set padding 3
 

Matthew

Member
I found a minor issue with my mod, if the 1st ad break ends within the 1st few secs of the file the padding creates a negative value for the bookmark, the cropping then sees that as at the end of the file and the whole file is cropped!

Simple fix which is included in the full version of the mod in this diff against the latest DetectAds

Summery for anyone jumping straight here:

This mod creates a new option (padOut) which sets number of seconds to pad advert end bookmarks to allow for recording disruption at the 'edit point' following cropping, the start of file bookmark is always padded 3 secs (as that's all it needs there). Setting padOut means the last bookmark is ignored as that cleans the crop at the end.

padSec overrides padOut

Following the file crop the mod also calculates and applies new bookmarks set to appear just after any edit points, that allows edits to be quickly checked, a method to jump any disturbance and a chapter addition for recordings.

The edit point bookmarks is an implementation within DetectAds for my automatic post crop bookmarks detailed here https://hummy.tv/forum/threads/automatic-edit-point-bookmarks-following-crop.9057/#post-127986

Diff:
--- /mod/webif/plugin/detectads/detectads_orig.jim
+++ /mod/webif/plugin/detectads/detectads.jim
@@ -152,7 +152,8 @@
       admaxsec  65
       padsec     0
       makethm    0
-      thmoffset  0}
+      thmoffset  0
+      padout     0}

     # Override default from settings DB
     foreach {key defvalue} [array get optarray] {
@@ -467,6 +468,7 @@
     $queue_db close
}

+# Manual
proc ::detectads::run {ts} {
     set file [$ts get file]

@@ -479,7 +481,11 @@
            log "Cannot acquire exclusive lock $file, terminating." 0
            return {"DEFER" "Cannot acquire exclusive lock"}
     }
-
+    set stime [$ts get start]
+    set etime [$ts get end]
+    set durn $($etime-$stime)
+    set theend 0
+    set padding 0
     set size [$ts size]
     set numAdBreaks 0
     set bname [file rootname [file tail $file]]
@@ -495,7 +501,14 @@
     foreach {key value} [array get ::opts] {
         set $key $value
     }
-
+     
+    if {$padsec} {
+    set padout 0
+    }
+    if {$padout} {
+    log "Padding out points by $padout secs and ignoring program end bookmark" 0
+    }
+ 
     set tailPid 0; # unused (for killing head of pipe on timeout - useful with tail -f recording.ts | ffmpeg ... | silence...)

     set silenceArgs "\
@@ -547,7 +560,23 @@
                     endSeconds]} {

             set totalStartSeconds [expr {$startMinutes * 60 + $startSeconds}]
-            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds}]
+            if {$cropcmd eq " " && $totalStartSeconds < 10 && $padout} {
+            set padding 3
+            } elseif {$padout} {
+            set padding $padout
+            }
+            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds - $padding}]
+           if {$totalEndSeconds < 0} {
+               set totalEndSeconds 0
+            }
+            set endMinutes [expr int($totalEndSeconds / 60)]
+            set endSeconds [expr ($totalEndSeconds % 60)]
+            if { [expr {$totalEndSeconds + 10}] > $durn} {
+               set totalEndSeconds [expr {$totalEndSeconds + $padding}]
+               if {$padout} {
+                  set theend 1
+               }
+            }

             log "  ad break found $startMinutes:$startSeconds-$endMinutes:$endSeconds ($totalStartSeconds - $totalEndSeconds)" 0

@@ -565,7 +594,11 @@
                         ladd bookmarks 0 $totalStartSeconds $totalEndSeconds
                     }
                 } else {
-                    ladd bookmarks $totalStartSeconds $totalEndSeconds
+            if {$theend == 0} {
+            ladd bookmarks $totalStartSeconds $totalEndSeconds
+                     } else {
+            ladd bookmarks $totalStartSeconds
+                     }
                 }
             }
             # Update bookmarks and build up crop cmd line as each break is detected.- mymsman  150408
@@ -660,7 +693,11 @@
         set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
         log "ad detection.processed in ${elapsedSeconds}s $elapsedTime - $numAdBreaks ad breaks bookmarked, crop starting" 0

-
+    # calculate post crop edit point bookmarks
+    set len [$ts duration 1]
+    set newbookmark [editpointbm $bookmarks $len]
+    set originalused 0
+       
         # copy & paste from crop/execute.jim  - mymsman 150407
         set rfile $file
         set dir [file dirname $rfile]
@@ -720,6 +757,7 @@
                 set cfile "$tgtpath/$shname-crop.ts"
                 if {![system inuse $cfile]} {  # Rename crop file to original if not in use
                       ts renamegroup "$cfile" "$shname"
+                      set originalused 1
                 }
            } else {
                 log "$file safe_delete failed" 0
@@ -734,6 +772,11 @@
         set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
         log "done...processed in ${elapsedSeconds}s $elapsedTime - $numAdBreaks ad breaks cropped out" 0
         set retcode [list "OK" "$numAdBreaks ad breaks cropped out" ]
+        # save post crop edit point bookmarks
+        if { !$originalused } {
+                set ts [ts fetch "$tgtpath/$shname-crop.ts"]
+            }
+            $ts setbookmarks $newbookmark
     } else  {
         set elapsedSeconds [elapsed $start]
         set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
@@ -746,6 +789,7 @@
     return $retcode
}

+# Chaserun
proc ::detectads::chaserun {ts {Qid 0} {retrynumb 0}} {
     # run ad detection against currently recording program using dlna helper - mymsman 150505
     # creates decrypted, cropped and shrunk copy of file in video root directory.
@@ -768,12 +812,23 @@
     }
     set statustok [system startop -multiple detectads $file]
     set size [$ts size]
+    set stime [$ts get start]
+    set etime [$ts get end]
+    set durn $($etime-$stime)
+    set theend 0
+    set padding 0
     set numAdBreaks 0

     # set each option from settings/overrides
     foreach {key value} [array get ::opts] {
         set $key $value
-    }
+    }     
+    if {$padsec} {
+    set padout 0
+    }
+    if {$padout} {
+    log "Padding out points by $padout secs and ignoring program end bookmark" 0
+    } 
     set tailPid 0; # unused (for killing head of pipe on timeout - useful with tail -f recording.ts | ffmpeg ... | silence...)

     set silenceArgs "\
@@ -788,6 +843,7 @@
     set stime [$ts get start]
     set etime [$ts get end]
     set ctime [clock seconds]
+    set len [$ts duration 1]

     # Check file sharing enabled
     if {[system param DMS_START_ON]} {
@@ -954,9 +1010,24 @@
                     startSeconds  \
                     endMinutes \
                     endSeconds]}  {
-
             set totalStartSeconds [expr {$startMinutes * 60 + $startSeconds}]
-            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds}]
+            if {$cropcmd eq " " && $totalStartSeconds < 10 && $padout} {
+            set padding 3
+            } elseif {$padout} {
+            set padding $padout
+            }
+            set totalEndSeconds [expr {$endMinutes * 60 + $endSeconds - $padding}]
+            if {$totalEndSeconds < 0} {
+               set totalEndSeconds 0
+            }
+            set endMinutes [expr int($totalEndSeconds / 60)]
+            set endSeconds [expr ($totalEndSeconds % 60)]
+            if { [expr {$totalEndSeconds + 10}] > $durn} {
+               set totalEndSeconds [expr {$totalEndSeconds + $padding}]
+               if {$padout} {
+                  set theend 1
+               }
+            }

             log "  ad break found $startMinutes:$startSeconds-$endMinutes:$endSeconds ($totalStartSeconds - $totalEndSeconds) Frames: $startFrame - $endFrame" 0

@@ -976,7 +1047,11 @@
                         ladd bookmarks 0 $totalStartSeconds $totalEndSeconds
                     }
                 } else {
-                    ladd bookmarks $totalStartSeconds $totalEndSeconds
+            if {$theend == 0} {
+            ladd bookmarks $totalStartSeconds $totalEndSeconds
+                     } else {
+            ladd bookmarks $totalStartSeconds
+                     }
                 }
             }
             # Update bookmarks and build up crop cmd line as each break is detected.- mymsman  150408
@@ -1140,7 +1216,7 @@
             set newtitle  "$title -Len err ([clock format $misdetect -format %T])"
         }
     }
-
+    set originalused 0
     if {$lengtherr == 0} {
         # All OK (as far as we can tell)
         set newtitle  "Done"
@@ -1155,6 +1231,7 @@
                     if {![system inuse $cfile]} {  # Rename crop file to original if not in use
                        exec hmt  "+settitle=$title" "$cpath/$cname.hmt"
                        ts renamegroup "$cfile" "$bname"
+                       set originalused 1
                     }
                     if {![system inuse $tfile]} {  # Delete decrypt file no longer needed
                        $tts delete
@@ -1196,7 +1273,18 @@
             }
             close $recording
     }
-
+ 
+    if { $crop } {
+
+    set newbookmark [ editpointbm $bookmarks $len ]
+
+        # save post crop edit point bookmarks
+        if { !$originalused } {
+                set ts [ts fetch "$tgtpath/$cname.ts"]
+            }
+            $ts setbookmarks $newbookmark
+    }
+ 
     if {$tempQid} {
         # remove temporary entryt from the queue
         log "Removing item $tempQid ($file) from the queue" 1
@@ -1212,13 +1300,17 @@
     set elapsedTime [clock format $(round($elapsedSeconds)) -format "%H:%M:%S"]
     log "done...processed $file in ${elapsedSeconds}s $elapsedTime - $numAdBreaks ad breaks detected" 0
     set retmsg "$numAdBreaks ad breaks detected, $warning"
-
+    if { $crop && $numAdBreaks && $retcode != "FAILED" } {
+     set retmsg "$numAdBreaks ad breaks cropped out. $warning"
+    }
+ 
     system endop $statustok
     release_lock $file
     log "=============================================================" 1
     set ::auto::loglevel ::autologlevel
     return [list $retcode $retmsg $qtime]
-}
+} 
+## proc detectads::chaserun end

proc set_HMT_durn {hmtfn start durn} {
             # Update recording end & stored recording time in hmt file
@@ -1226,3 +1318,45 @@
             exec hmt "+patch32=0x288:$durn"  "$hmtfn.hmt"

}
+
+# calculate post crop edit point bookmarks
+proc editpointbm {bookmarks len} {
+     set keeping 0
+    set start -1
+    set newbookmark "0 "
+    set i -1
+    foreach b $bookmarks {
+        if {$start < 0} {
+            set start $b
+            set removing $b
+            continue
+        }
+        if {$i == 0} {
+            set start $b
+            set endad $($b - $removing)
+            incr removing $($endad - $startad)
+            set i -1
+            continue
+        }
+        set end $b
+        incr keeping $($end - $start)
+        set startad $($b - $removing)
+        append newbookmark "$($startad +3) " 
+        set i 0
+    }     
+    if {$i < 0 && $start > 0} {
+        incr keeping $($len - $start)
+    }
+    set n $([llength $newbookmark] - 1)
+    if {[lindex $newbookmark end] > [expr $keeping - 8] && $n > 0} {
+        set newbookmark [lreplace $newbookmark $n $n]
+        append newbookmark " $($keeping - 8)"
+    } elseif {$n == 0 && $keeping > 0} {
+        append newbookmark " $($keeping - 8)"
+    }
+    if {[lindex $newbookmark end] < [expr $keeping - 60]} {
+        append newbookmark " $($keeping - 8)"
+    }
+ 
+    return $newbookmark
+}
Code:
--- /mod/webif/plugin/detectads/detectads-orig
+++ mod/webif/plugin/detectads/detectads
@@ -133,6 +133,7 @@
                 puts "-brkMinSec  60   = Minimum length of an ad break in seconds"
                 puts "-adMaxSec   65   = Maximum length of a single ad in seconds"
                 puts "-padSec     0    = Adjust ends of ad breaks by n seconds"
+                puts "-padOut     0    = Adjust out points of ad breaks by n seconds"
                 puts "-makeThm    n    = Make thumbnail if it doesn't already exist"
                 puts "-thmOffset  0    = Thumbnail offset from programme start"
         }
Edit: added comments for clarity
 
Last edited:
Top