Mailing List Archive

Recording from STB that requests channel access pins
Hi,

Running MythTV 0.27; I'm recording some channels via sat box (with subscription card, so I can't use dvb-s card like for FTA channels) controlled via IR transmitter. Depending on time of day and rating of a program, the box sometimes requires a 4-digit access code (meant to protect kids from inappropriate content).

* The protection system can not be turned off/disabled
* The request for the pin is linked to the program, not the channel.
* Start/end times are not too reliable, so starting a recording a couple of minutes before the official start time is often required to ensure complete recordings.
* I've put the pin into the channel change script, so if a pin is requested when changing channels, all is fine.

There is however a nasty problem:
when a recording starts, the current content can be unrestricted, so no access pin is requested. There is also no way to "preemptively" enter the PIN at this time. A couple of minutes later the actual program to be recorded starts and the box pops up the "please enter your pin" screen ==> recording of pin screen instead of program.

So, what would be required to make this work would be to regularly (say, every 15 seconds or so) grab the latest frame and compare it to the "please enter pin" image [.there's also a running clock/date on that screen, so it won't be a 100% match]. The actual comparsing could be don using imagemagick for example. If a match is found, send the pin via lirc/irsend.

Is there any infrastructure within myth I could harness to implement something like this, or does this already exist?
There's a slight similarity to commercial flagging as that can also run concurrently to the recoding and analyze the video is at becomes available, so a new "commercial detection method" might be a way to implement this.

Any ideas on how to best hook such a function into MythTV would be appreciated!

Thanks, Martin
No Disclaimer.icomedias





_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Recording from STB that requests channel access pins [ In reply to ]
On Tue, Jan 12, 2016 at 7:14 AM, Martin Bene <Martin.Bene@icomedias.com> wrote:
> when a recording starts, the current content can be unrestricted,
> so no access pin is requested. There is also no way to "preemptively"
> enter the PIN at this time. A couple of minutes later the actual program
> to be recorded starts and the box pops up the "please enter your pin"
> screen ==> recording of pin screen instead of program.

Yes, I agree, that's a nasty problem.

> There's a slight similarity to commercial flagging as that can also run concurrently
> to the recoding and analyze the video is at becomes available, so a new "commercial
> detection method" might be a way to implement this.

I'd think you'd want something different. The commercial detection,
even when configured to run in real time with the recording, is still
just a job and is subject to throttling up to the limit of the number
of jobs which can be running at any given time. MythTV doesn't
guarantee that these jobs will run in real time, so it may be too late
for your needs.

> Any ideas on how to best hook such a function into MythTV would be appreciated!

I would first look for any way around the problem. Does your STB
offer any means of control/query other than IR? No
serial/ethernet/firewire port that might be used for some alternate
means of two-way communication? Have you contacted your provider to
verify that there really is no way to disable the pin requirement?

Eric
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Recording from STB that requests channel access pins [ In reply to ]
On Wed, Jan 13, 2016 at 12:38 AM, Martin Bene <Martin.Bene@icomedias.com>
wrote:

> So far, I'm stuck at the point that I really need to look fort he pop-up
> image to determine if a pin is required.
>

I used to use a channel changer script that tried to analyze the screen to
know if the STB was in screen-saver mode. It used ffmpeg to capture a few
frames of video as jpeg files, converted those jpegs to colored text with
jp2a, and then looked at those files with a Perl script to come up with a
confidence score.

It ended up not working very well... maybe the resolution of the files jp2a
created was too low, or maybe because the screensaver was constantly
shifting. Looking at the video or jpegs directly may have worked better.

-- Tony
Re: Recording from STB that requests channel access pins [ In reply to ]
On Wed, Jan 13, 2016 at 6:38 AM, Martin Bene <Martin.Bene@icomedias.com> wrote:
> .... many users asked how to permanently disable these
> since there are no kids in their household - answer by the
> provider is allways the same: not possible, a visitor might
> bring a kid so pin is allways required.

On at least some of the Humax models there was
a configuration regarding the maturity level that
set the PIN requirement (with a "View All"? meaning
no PIN). Some providers may have disabled the
ability for their customers to set the parental
control maturity rating (which means, I guess,
it is only "not possible" due to their decisions
to make it "not possible").
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Recording from STB that requests channel access pins [ In reply to ]
On 01/13/2016 10:41 AM, Eric Sharkey wrote:
> On Wed, Jan 13, 2016 at 3:37 AM, Mark Perkins wrote:
>> Sorry to be vague, but at the time they were not relevant to me. But haven't there
>> been channel change scripts discussed that do something similar to overcome the
>> power toggle issue where the STB has an on/off toggle remote code?
> I don't think you could do this in the channel change script. The
> problem is the delay.
>
> For powering on the STB, it's simple. If your recording starts 30
> seconds before the program, it's no problem for the script to power on
> the STB *now* and return successfully, allowing MythTV to start the
> recording. For the case of the pin entry, 30 seconds before the
> program there's no pin entry screen to detect. The channel change
> script would need to wait for it before returning, but not all
> programs have a pin requirement, so it might end up waiting for
> something that never comes.

The channel change script simply needs to spawn a child process to do
the monitoring (and pin entry), then return an exit code for MythTV
indicating the status of the channel change. So, technically, you can't
do it in the channel change script, but you could (probably should) do
it with a script called by the channel change script (using System
Events--really the only other hook indicating start of recording--would
add much more complexity than just using channel change scripts, and
probably more latency and such, and may not be much help for Live TV,
and ...).

Or, really, if I were doing it, I'd use a normal channel change script
for sending button presses to the STB, but and create a
script/program/... to monitor for whether a PIN is required and--if
so--send the PIN using the normal channel change script, and have a 3rd
script that simply orchestrates the calling of the scripts and set this
3rd script as the MythTV channel change script.

Though the whole PIN entry at whenever the STB decides is completely
broken--to the point that the provider really /should/ allow a way to
disable it. (And I'd search high and low--even wade through cable
company customer support to try to get a different STB--for a way to
disable it, even if doing so requires going into some
service/maintenance interface that my cable company may not want to tell
me about).

Mike
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Recording from STB that requests channel access pins [ In reply to ]
On 13/01/16 20:13, Michael T. Dean wrote:
> On 01/13/2016 10:41 AM, Eric Sharkey wrote:
>> On Wed, Jan 13, 2016 at 3:37 AM, Mark Perkins wrote:
>>> Sorry to be vague, but at the time they were not relevant to me. But haven't there
>>> been channel change scripts discussed that do something similar to overcome the
>>> power toggle issue where the STB has an on/off toggle remote code?
>> I don't think you could do this in the channel change script. The
>> problem is the delay.
>>
>> For powering on the STB, it's simple. If your recording starts 30
>> seconds before the program, it's no problem for the script to power on
>> the STB *now* and return successfully, allowing MythTV to start the
>> recording. For the case of the pin entry, 30 seconds before the
>> program there's no pin entry screen to detect. The channel change
>> script would need to wait for it before returning, but not all
>> programs have a pin requirement, so it might end up waiting for
>> something that never comes.
>
> The channel change script simply needs to spawn a child process to do the monitoring (and pin
> entry), then return an exit code for MythTV indicating the status of the channel change. So,
> technically, you can't do it in the channel change script, but you could (probably should) do it
> with a script called by the channel change script (using System Events--really the only other hook
> indicating start of recording--would add much more complexity than just using channel change
> scripts, and probably more latency and such, and may not be much help for Live TV, and ...).
>
> Or, really, if I were doing it, I'd use a normal channel change script for sending button presses to
> the STB, but and create a script/program/... to monitor for whether a PIN is required and--if
> so--send the PIN using the normal channel change script, and have a 3rd script that simply
> orchestrates the calling of the scripts and set this 3rd script as the MythTV channel change script.
>
> Though the whole PIN entry at whenever the STB decides is completely broken--to the point that the
> provider really /should/ allow a way to disable it. (And I'd search high and low--even wade through
> cable company customer support to try to get a different STB--for a way to disable it, even if doing
> so requires going into some service/maintenance interface that my cable company may not want to tell
> me about).
>
The suggested procedure might fail, if you have two programs scheduled on the same channel and the
second one requires a PIN. In that case, there might be no channel change script invoked at all,
since myth knows the tuner is already on the correct channel.

--

Mike Perkins

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Recording from STB that requests channel access pins [ In reply to ]
>But haven't there been channel change scripts discussed that do something similar to overcome the power toggle issue where the STB has an on/off toggle remote code?

I found a link to this on the Mythtv Wiki
http://evuraan.blogspot.com/2008/01/how-to-ensure-set-top-box-stb-is.html

I will be investigating/testing something like this for myself soon.  I would be interested in any other code that does something similar.  I need to detect of the Set Top Box in on or not.

Craig
Re: Recording from STB that requests channel access pins [ In reply to ]
On 01/13/2016 06:07 PM, Mike Perkins wrote:
> On 13/01/16 20:13, Michael T. Dean wrote:
>> On 01/13/2016 10:41 AM, Eric Sharkey wrote:
>>> On Wed, Jan 13, 2016 at 3:37 AM, Mark Perkins wrote:
>>>> Sorry to be vague, but at the time they were not relevant to me.
>>>> But haven't there
>>>> been channel change scripts discussed that do something similar to
>>>> overcome the
>>>> power toggle issue where the STB has an on/off toggle remote code?
>>> I don't think you could do this in the channel change script. The
>>> problem is the delay.
>>>
>>> For powering on the STB, it's simple. If your recording starts 30
>>> seconds before the program, it's no problem for the script to power on
>>> the STB *now* and return successfully, allowing MythTV to start the
>>> recording. For the case of the pin entry, 30 seconds before the
>>> program there's no pin entry screen to detect. The channel change
>>> script would need to wait for it before returning, but not all
>>> programs have a pin requirement, so it might end up waiting for
>>> something that never comes.
>>
>> The channel change script simply needs to spawn a child process to do
>> the monitoring (and pin
>> entry), then return an exit code for MythTV indicating the status of
>> the channel change. So,
>> technically, you can't do it in the channel change script, but you
>> could (probably should) do it
>> with a script called by the channel change script (using System
>> Events--really the only other hook
>> indicating start of recording--would add much more complexity than
>> just using channel change
>> scripts, and probably more latency and such, and may not be much help
>> for Live TV, and ...).
>>
>> Or, really, if I were doing it, I'd use a normal channel change
>> script for sending button presses to
>> the STB, but and create a script/program/... to monitor for whether a
>> PIN is required and--if
>> so--send the PIN using the normal channel change script, and have a
>> 3rd script that simply
>> orchestrates the calling of the scripts and set this 3rd script as
>> the MythTV channel change script.
>>
>> Though the whole PIN entry at whenever the STB decides is completely
>> broken--to the point that the
>> provider really /should/ allow a way to disable it. (And I'd search
>> high and low--even wade through
>> cable company customer support to try to get a different STB--for a
>> way to disable it, even if doing
>> so requires going into some service/maintenance interface that my
>> cable company may not want to tell
>> me about).
>>
> The suggested procedure might fail, if you have two programs scheduled
> on the same channel and the second one requires a PIN. In that case,
> there might be no channel change script invoked at all, since myth
> knows the tuner is already on the correct channel.

Every recording involves a channel change--we never assume that things
are as we left them (because lots of people like to mess with things).
TTBOMK, only Live TV will sit on the same channel through a program change.

Mike
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Recording from STB that requests channel access pins [ In reply to ]
Hi,

Lots of good feedback on this thread - I really appreciate the help.

> The channel change script simply needs to spawn a child process to do
> the monitoring (and pin entry), then return an exit code for MythTV
> indicating the status of the channel change.

Currently, I think the channel change script isn't the best place to attach this; an event script for the "Recording started" or " Recording started writing" looks like a better fit: I can get information on the recording file and card as parameters so I don't have to look around for the right recording file and can also avoid monitoring recordings from sane sources that don't require this voodoo.

Currently envisioned logic looks like this:
* spawn a monitoring process from "Recording Started" event script
* end the monitor if the recording file doesn't change for 30" (recording finished)
* grab last 5mb off the recording file, feed to ffmpeg, extract first keyframe as a jpg
* cut out a region from the image that's constant for the popup (no date/time/channel name/program info)
* compare grabbed image to corresponding part of the popup using imagemagick compare function
* send pin if compare returns reasonable similarity.

I'll share my results if I get this running in an acceptable way.

> Though the whole PIN entry at whenever the STB decides is completely
> broken--to the point that the provider really /should/ allow a way to
> disable it. (And I'd search high and low--even wade through cable company
> customer support to try to get a different STB--for a way to disable it,
> even if doing so requires going into some service/maintenance interface that
> my cable company may not want to tell me about).

I wholeheartedly agree, it's definitely ridiculous. The provider only supports one model of STB (they went so far as to send a new box to customers owning previously supported different models).

Bye, Martin
No Disclaimer.icomedias
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Recording from STB that requests channel access pins [ In reply to ]
Hi,

> Lots of good feedback on this thread - I really appreciate the help.
> I'll share my results if I get this running in an acceptable way.

Turns out that this requires just a few lines of code with the right tools.
The script is called from a Start recording event script I need anyway ( to fix hd-pvr recording parameters)

Monitoring script is called like this in the event script:
/usr/bin/nohup /usr/local/bin/monitor-hdpvr.sh $1 &

Settins for the start recording event:
+--------------------+---------------------------------------------------------+----------+
| value | data | hostname |
+--------------------+---------------------------------------------------------+----------+
| EventCmdRecStarted | /usr/local/bin/fix-hdpvr.sh %FILE% %STARTTIME% %CARDID% | pvr-sw |
+--------------------+---------------------------------------------------------+----------+

The script monitors the given filename, grabs a screenshot every 10 seconds and compares it to a reference image. Imagemagick compare returns a result ~500 for the popup screen and ~ 12000 for normal content from movie recordings so accuracy of detection is quite good.

Again, thanks a lot for the Input I received here!

Bye, Martin
No Disclaimer.icomedias
Re: Recording from STB that requests channel access pins [ In reply to ]
On Sat, Jan 16, 2016 at 5:39 AM, Martin Bene <Martin.Bene@icomedias.com> wrote:
> Hi,
>
>> Lots of good feedback on this thread - I really appreciate the help.
>> I'll share my results if I get this running in an acceptable way.
>
> Turns out that this requires just a few lines of code with the right tools.

Very nicely done! I never would have expected that to have such a
relatively simple solution.

I took a look at your script. The one piece which seemed somewhat
brittle to me was the reliance on the mtime of the recording file
being updated at least every 30 seconds. When an application has a
file descriptor open and is appending data to the file, I'm not sure
how often the metadata like mtime is updated. Functions like
fdatasync specifically avoid updating the mtime when syncing data to
disk. Depending on a number of factors, this could cause your script
to end early. If you want to be more paranoid, you could check both
the mtime and the size of the recording file and keep going when
either has changed.

Eric
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org