Detecting start of recordings

MymsMan

Ad detector
Is there a mechanism, similar to recmon, that plugins can be called when a recording starts rather than just when it ends?

Redring can obviously detect when a recording starts but it is not obvious to me how it achieves this feat or if jim scripts can be called from redring

The reason for asking is I have succeeded in running ad detection whilst a recording is in progress and would like to be able to automate the start up. I could use a chrontab scheduled task but I think a notification would be neater.
 
While I have something that meets my immediate needs it will take more work before it is fit for prime time:
  • I am not the author of the detectads package and I would not wish to cause any friction by distributing an unapproved modification of someone else's code. I have sent some of my simpler modifications to njm for comment but haven't had a response yet
  • I am still a relative novice to jim tcl coding so not as productive as the older hands.
  • I have created a new function that I call chaseget which uses the dlnahelper technique to retrieve the recording by multiple invocatons of curl until the entire file is retrieved, curl is throttled to spread retrieval over the remaining recording time.
  • There is inadequate support for restarting the process should the system shut down in mid process
  • Handling multiple simultaneous recordings is not yet supported, it uses the system dlnahelper function which would require some, fairly simple, changes to allow for multiple helper entries
  • The ffmpeg program is a CPU hog, even when throttled to close to recording rate it still takes up to 55% cpu so running two instances could deny the humaxtv process adequate resources so more thought and experimentation is needed for handling simultaneous recordings.
  • Ideally I would like to include nicesplice into the pipeline so that it can crop the ads out whilst the recording is in progress allowing ad free chase play, currently if you attempt chase play you can see the bookmarks for any ad breaks already detected but don't see those for ad breaks detected later since the hmt file is marked in use. So effectively chase play is not yet viable.
  • Not including nicesplice in the pipleline also means the cropping does not start until after recording is complete - significantly better than today but not as good as I know should be possible
  • I have sent a message to drutt to discuss the changes needed but haven't heard back yet.
  • There are other potential uses for the technique. ffmpeg can produce several outputs so mp3 and mp4 extraction could also occur simultaneously with recording and ad detection.
 
The idea of just being able to skip to bookmark seems enough to me, it's not a hardship.

I had ideas about finding a way to detect silences without the overhead of ffmpeg, but the flesh is weak.
 
Is there a mechanism, similar to recmon, that plugins can be called when a recording starts rather than just when it ends?

The latest version of recmon (2.0.3-4) calls the scripts in /mod/etc/recmon.d with a first argument of either -start or -stop and the recording filename (minus extension) as the second argument.

For example:
Code:
/mod/etc/recmon.d/auto-unprotect -start "/media/My Video/The Resident_20150520_0007"
/mod/etc/recmon.d/auto-unprotect -stop "/media/My Video/The Resident_20150520_0007"
The existing scripts have been updated (in their various packages) to require -stop. Auto-unprotect should handle chase play now too.
 
The ffmpeg program is a CPU hog, even when throttled to close to recording rate it still takes up to 55% cpu so running two instances could deny the humaxtv process adequate resources so more thought and experimentation is needed for handling simultaneous recordings.
There were some later versions of ffmpeg that af123 compiled but did not end up in the main repository (e.g. version 2.1.4). How does this compare to the version currently in use (0.10) with respect to CPU usage?
 
Does this mean that I can stream a recording which has only started a minute ago?
Not yet, but MymsMan has, in essence, shown that it can be done: see post #4. As far as I am aware the aim of his work is to get near real time decryption, ad detection and removal working, but streaming on another device is a small step from there.
 
Last edited:
Thanks for the recmon update.

Due to a botched ISP move I have been offline since Wednesday morning so have a huge backlog to plough through before I can start playing again.
 
The latest version of recmon (2.0.3-4) calls the scripts in /mod/etc/recmon.d with a first argument of either -start or -stop and the recording filename (minus extension) as the second argument.
Unfortunately I seem to be missing some start events :(
Code:
782 /media/My Video/Come Dine with Me_20150525_1101-dec.hmt: No such file or directory
781 detectads: -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1101}
780 25/05/2015 11:01:16 : -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1101}
779 /media/My Video/Come Dine with Me_20150525_1030-dec.hmt: No such file or directory
778 /media/My Video/Come Dine with Me_20150525_1030-dec.hmt: No such file or directory
777 /media/My Video/Come Dine with Me_20150525_1030-dec.hmt: No such file or directory
776 25/05/2015 11:01:08 : -stop {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1030}
775 detectads: -stop {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1030}
774 25/05/2015 10:44:36 : -stop {/media/My Video/Columbo_ Last Salute to Commodore_20150525_1028}
773 detectads: -stop {/media/My Video/Columbo_ Last Salute to Commodore_20150525_1028}
772 /media/My Video/Come Dine with Me_20150525_1030-dec.hmt: No such file or directory
771 detectads: -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1030}
770 25/05/2015 10:30:08 : -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1030}
769 25/05/2015 10:30:07 : -stop {/media/My Video/Homes Under the Hammer_20150525_1025}
768 detectads: -stop {/media/My Video/Homes Under the Hammer_20150525_1025}
767 detectads: -start {/media/My Video/Homes Under the Hammer_20150525_1025}
766 25/05/2015 10:25:48 : -start {/media/My Video/Homes Under the Hammer_20150525_1025}
765 /media/My Video/[Deleted Items]/Beat the Brain_20150521_1829.hmt: No such file or directory
764 /media/My Video/[Deleted Items]/Pointless_20150521_1714.hmt: No such file or directory
763 /media/My Video/[Deleted Items]/Countdown_20150521_1411.hmt: No such file or directory
762 /media/My Video/[Deleted Items]/BBC News at Ten_20150520_2159.hmt: No such file or directory
761 /media/My Video/[Deleted Items]/South Today_20150520_2228.hmt: No such file or directory
You will see at 772/3 stop events for Colombo with no corresponding start events.
There was an on screen recording conflict message at the time but I have also seen missing -starts where there was no conflict

There also a number of spurious 'No such file' messages for .hmt files. Some occurred for recordings in the dustbin (765...) whilst the four 1030-dec.hmt (772,7,8,9) files are for the decrypted recording detectacts is creating and do exist at the time.

It is a pity the recmon log is not time stamped bydefault, I created a dummy recmon file which does nothing but writes a timestamped copy of the parameters to provide some context, but you could add it for all log entries using:
Code:
...recmon | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }'>>/mod/tmp/recmon.log 2>&1
 
Some more examples of missing recording start notifications;
Code:
852 25/05/2015 23:28:15 : -stop {/media/My Video/Have I Got a Bit More News for You/Have I Got a Bit More News for You_20150525_2244}
850 25/05/2015 22:44:26 : -stop {/media/My Video/BBC News at Ten/South Today_20150525_2235}
848 25/05/2015 22:35:22 : -stop {/media/My Video/BBC News at Ten/BBC News_20150525_2214}
846 25/05/2015 22:35:22 : -start {/media/My Video/BBC News at Ten/South Today_20150525_2235}
844 25/05/2015 22:14:51 : -start {/media/My Video/BBC News at Ten/BBC News_20150525_2214}
839 25/05/2015 22:03:43 : -stop {/media/My Video/Britain's Got Talent Live/Britain's Got Talent Results_20150525_2133}
836 25/05/2015 21:33:17 : -start {/media/My Video/Britain's Got Talent Live/Britain's Got Talent Results_20150525_2133}
828 25/05/2015 21:00:03 : -stop {/media/My Video/Britain's Got Talent Live_20150525_1935}
821 25/05/2015 18:59:41 : -stop {/media/My Video/Beat the Brain/Beat the Brain_20150525_1829}
819 25/05/2015 18:30:05 : -stop {/media/My Video/Pointless/Pointless_20150525_1744}
816 25/05/2015 17:44:10 : -stop {/media/My Video/Eggheads/Eggheads_20150525_1713}
810 25/05/2015 15:00:57 : -stop {/media/My Video/Countdown/Countdown_20150525_1410}
809 25/05/2015 14:59:54 : -stop {/media/My Video/Perfection/Perfection_20150525_1414}
806 25/05/2015 14:14:29 : -start {/media/My Video/Perfection/Perfection_20150525_1414}
804 25/05/2015 13:08:22 : -stop {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1236}
800 25/05/2015 12:36:10 : -stop {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1202}
796 25/05/2015 12:02:45 : -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1202}
794 25/05/2015 12:02:40 : -stop {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1133}
785 25/05/2015 11:33:21 : -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1133}
784 25/05/2015 11:33:19 : -stop {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1101}
780 25/05/2015 11:01:16 : -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1101}
776 25/05/2015 11:01:08 : -stop {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1030}
774 25/05/2015 10:44:36 : -stop {/media/My Video/Columbo_ Last Salute to Commodore_20150525_1028}
770 25/05/2015 10:30:08 : -start {/media/My Video/Come Dine with Me/Come Dine with Me_20150525_1030}
769 25/05/2015 10:30:07 : -stop {/media/My Video/Homes Under the Hammer_20150525_1025}
766 25/05/2015 10:25:48 : -start {/media/My Video/Homes Under the Hammer_20150525_1025
Of todays 17 recording there were only 9 start notifications

I can see no obvious rhyme or reason to explain when the notifications are missing
 
The latest version of recmon (2.0.3-4) calls the scripts in /mod/etc/recmon.d with a first argument of either -start or -stop and the recording filename (minus extension) as the second argument.

The existing scripts have been updated (in their various packages) to require -stop. Auto-unprotect should handle chase play now too.
Auto-unprotect has been a bit unreliable on my boxes recently because of the 'in-use' problem, but since this change it has been completely broken.
The recmon.log shows lines like these:
Code:
/mod/etc/recmon.d/auto-unprotect:11: Error: invalid command name "0"
at file "/mod/etc/recmon.d/auto-unprotect", line 11
Everything is apparently up to date, but a force reinstall of auto-unprotect reveals this:
Code:
humax ~ # opkg files auto-unprotect
Package auto-unprotect (2.0.0) is installed on root and has the following files:
/mod/sbin/unprotect
/mod/etc/recmon.d/auto-unprotect
/mod/etc/init.d/S99auto-unprotect
humax ~ # ls -l /mod/etc/recmon.d/auto-unprotect
-rwxr-xr-x  1 root  root  258 Jan 27 20:50 /mod/etc/recmon.d/auto-unprotect
humax ~ # opkg update && opkg --force-reinstall install auto-unprotect
Downloading http://hpkg.tv/hdrfoxt2/base/Packages.gz.
Inflating http://hpkg.tv/hdrfoxt2/base/Packages.gz.
Updated list of available packages in /mod/var/opkg/base.
Removing package auto-unprotect from root...
Installing auto-unprotect (2.0.0) to root...
Downloading http://hpkg.tv/hdrfoxt2/base/auto-unprotect_2.0.0-0_mipsel.opk.
Configuring auto-unprotect.
<snip>
humax ~ # ls -l /mod/etc/recmon.d/auto-unprotect
-rwxr-xr-x  1 root  root  331 May 19 23:32 /mod/etc/recmon.d/auto-unprotect
which looks to me like the package was updated but the version number wasn't changed and thus it didn't update.
I wonder how many other people are suffering from this? It's done it on more than one box, so not an isolated incident.

Also, I wondered about those "0" errors and it turns out that "ts fetch" returns either this or an object, but there is no test for the former, so I added one:
Code:
humax /mnt/hd2/mod/etc/recmon.d # diff -u auto-unprotect~ auto-unprotect
--- auto-unprotect~
+++ auto-unprotect
@@ -7,6 +7,7 @@

 set file [lindex $argv 1]
 set ts [ts fetch "$file.ts"]
+if {$ts eq "0"} exit

 while {[$ts inuse]} { sleep 30 }
 
which looks to me like the package was updated but the version number wasn't changed and thus it didn't update.
The current auto-unprotect does appear to have a unique version number (2.0.0-0), however I am wondering if 2.0.0 and 2.0.0-0 are seen as the same version and that maybe 2.0.0-0 should have been 2.0.0-1 in order for it to appear as a new version
 
I would tend to agree with you (just to annoy BH!).
I hate 4 part version numbers anyway. It always seems like overkill. Some people go to even more insane lengths with letters and "rc" and stuff like that. Barking mad IMHO.
 
It was the "I would tend to agree" bit that I was going on about. You're slipping... ;)
 
He would agree if you were right. But under the present circumstances, he only tends to agree with you.
 
Back
Top