hdhomerun_config save question

Want to write your own code to work with a HDHomeRun or work with the HDHomeRun DVR? We are happy to help with concepts, APIs, best practices.
Post Reply
Nounours
Posts: 6
Joined: Thu Sep 12, 2019 3:22 pm

hdhomerun_config save question

Post by Nounours » Mon Sep 16, 2019 3:12 pm

I would like a quick way to automate a capture of a channel for 20 seconds every hour.

I got hdhomerun_config save operation to work manually, but there doesn't seem to be any way to provide a duration. I've tried to push the equivalent of a <Ctrl-C> through the stdin (via C# Process.Close()), but the process doesn't seem to respond to it.

Would you have any recommendations on how I should proceed?

Thank you in advance.

jasonl
Silicondust
Posts: 14712
Joined: Sun Oct 28, 2007 9:23 pm

Re: hdhomerun_config save question

Post by jasonl » Mon Sep 16, 2019 3:37 pm

Use wget/curl/fetch/etc. to retrieve via HTTP instead of using hdhomerun_config.

URL format:
http://hdhomerun.ip.address:5004/auto/vx?duration=20

Where x is the channel number you want to record (e.g. 2.1, 104), and hdhomerun.ip.address is the actual IP address of the HDHomeRun.
ex:
http://192.168.0.105:5004/auto/v2.1?duration=20

Nounours
Posts: 6
Joined: Thu Sep 12, 2019 3:22 pm

Re: hdhomerun_config save question

Post by Nounours » Mon Sep 16, 2019 5:03 pm

Thanks Jason.

I'm not too familiar with web interfaces in general, but I'll give it a shot, since it would solve my problem quite nicely.

A few follow up questions:

1. Is there a way to record the whole channel (with all the programs) via HTTP? Aka, the equivalent of running config save without setting the program?
2. Is there a way via HTTP of recording with the frequency instead of a virtual channel? Or in other words: is there a way to record a stream that is not currently detected in the channel list?
3. Is there a way to get the detailed output that the hdhomerun_config save operation gives us (the packet count and the "....ts....")?
4. Finally, I see that the HTTP call fails with a 503 if the channel is not locked on HDHR5. Is this the proper way to detect a not locked channel? Are there any other error codes that would be useful to know?

Thank you in advance.

PhilipD
Posts: 6
Joined: Sun Sep 15, 2019 3:21 am

Re: hdhomerun_config save question

Post by PhilipD » Mon Sep 16, 2019 11:39 pm

Hi

There is a document here detailing the various http commands: https://www.silicondust.com/hdhomerun/h ... opment.pdf

In answer to your questions, as far as I know:

1) No, it only works by program number, not by frequency or PIDS, see post viewtopic.php?f=125&t=72371 which is asking for a change to allow specific PIDs, it would also be good if they would accept a frequency.

2) No, however you could achieve this if they implemented the option of specifying a list of PIDs on the Http get.

3) This would be more tricky as the HTTP get will only support a stream, whereas hdhomerun_config can write to a file whilst also writing debug information to the screen.

4) The HTTP call should succeed if the channel is not locked, then lock it until you close the stream. If you try to open another stream and no tuners are available you then get the 503 error.

As a point of interest, personally I think it would be great if the HTTP API was extended to include all the functions of the hdhomerun_config. In fact I was surprised to find that wasn't the case already, and even tried things like http://192.168.1.100/get/tuner0/streaminfo which is the same command used with hdhomerun_config that already looks like part of a URL. My initial impression was that the hdhomerun_config was simply wrapping calls to the tuners HTTP server, alas it doesn't appear to be.

Regards

Phil

Nounours
Posts: 6
Joined: Thu Sep 12, 2019 3:22 pm

Re: hdhomerun_config save question

Post by Nounours » Tue Sep 17, 2019 12:36 am

Many thanks Philip!

That answers many of my questions and I can't believe that I missed that HTTP documentation.

FWIW, you would also get my vote for extending more of the hdhomerun_config functionality into the HTTP API, especially if this is the blessed way to interact with the HDHR devices.

And if it wouldn't be too much to ask from the SiliconDust software team, I think the hdhomerun_config save command would also benefit from having an optional duration parameter.

Thank you again to both of you for all the help!

jasonl
Silicondust
Posts: 14712
Joined: Sun Oct 28, 2007 9:23 pm

Re: hdhomerun_config save question

Post by jasonl » Tue Sep 17, 2019 3:09 pm

It does work with the full channel, just use "ch" instead of "v", and the RF channel number or frequency in Hz instead of the virtual channel number. PID filtering is not currently available, but there's a good case for it so I can see that happening at some point.

There isn't an output of the t/s but you could track it yourself by monitoring the actual packets. t indicates the TEI bit is set on the packet, and s means a sequence number was missed.

You can get the signal status via http://hdhomerun.ip.address/status.json .

The device will return 404 if you try to tune a vchannel that isn't known and 503 for most others. There's an X-HDHomeRun-Error header that will be returned with more specific reasons. Here's the list. The parts in parentheses are not included in the error, just an explanation of what the error is.
801 Unknown Channel
802 Unknown Transcode Profile (EXTEND only)
803 System Busy (normally means the device is in the middle of a channel scan)
804 Tuner In Use (when a specific tuner is used instead of auto)
805 All Tuners In Use
806 Tune Failed (TA reported an error (PRIME only), or hardware error)
807 No Video Data (bad reception/station off air/particular service is not being transmitted at that time)
808 DVR Failure (DVR can't write to the recording location)
809 Playback Connection Limit (DVR has hit the limit of playback streams)
810 DVR Full
811 Content Protection Required (PRIME only, channel is copy protected)

PhilipD
Posts: 6
Joined: Sun Sep 15, 2019 3:21 am

Re: hdhomerun_config save question

Post by PhilipD » Tue Sep 17, 2019 11:30 pm

Hi Jason

Many thanks for the info. Didn't know about channel request option on HTTP, is there an updated technical document for the HTTP API available by any chance? The one I have from a Google is from 2014.

Looking forward to PID filtering, I don't suppose you know what sort of time span just so I can decide if I need to use an alternative method in the meantime or could wait? Just roughly weeks, months, many months...

Thanks again.

Phil

jasonl
Silicondust
Posts: 14712
Joined: Sun Oct 28, 2007 9:23 pm

Re: hdhomerun_config save question

Post by jasonl » Wed Sep 18, 2019 1:31 pm

No updated document.

No idea on the timeframe on when it might happen, it's all dependent on engineering time coming open to do it.

Post Reply