Send HTTP Recording Stream to NUL?

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
Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

I know this is going to sound bizarre, but I am wondering if the "Recording using HTTP download" functionality can send the output stream to NUL instead of storing it on a local drive? Sometimes I just need to monitor the signal strength/quality of a channel, but don't have a need to actually watch the captured video.

Example: http://192.168.1.41:5004/tuner3/v20.1?duration=600 captures the output stream to a file in my Downloads folder.

Billi23
Posts: 163
Joined: Mon Mar 20, 2017 8:08 pm
Device ID: 1323AADB

Re: Send HTTP Recording Stream to NUL?

Post by Billi23 »

On Windows, try this from a Windows command prompt (Windows command line)

Code: Select all

curl.exe http://192.168.1.41:5004/tuner3/v20.1?duration=600 -o NUL:
Works on Windows 10 Pro, not sure about Windows 11

Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Re: Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

Billi23, your idea is heading in the right direction. I am actually using PowerShell, here is a stripped-down example of my current code:

Code: Select all

$WebRequestParameters = [ordered]@{ Uri = "http://192.168.1.41:5004/tuner3/v20.1?duration=300"
					OutFile = "C:\Users\Keith\Downloads\v20.mpeg" }

# Create and initialize the $BackgroundJobs array
$BackgroundJobs = @()

# Invoke streaming for each channel requested (maximum 6 channels)
foreach ($WebRequestParameter in $WebRequestParameters) {
	$BackgroundJobs += Start-ThreadJob -Name $WebRequestParameter.OutFile -ScriptBlock {
		$params = $Using:WebRequestParameter
		Invoke-WebRequest @params
	} -ThrottleLimit 6
}

# Wait until streaming for all requested channels is complete
Write-Host "Streaming initiated at" (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
Wait-Job -Job $BackgroundJobs
Write-Host "All streaming successfully completed at" (Get-Date -Format "yyyy-MM-dd HH:mm:ss")

# Display the results of the PowerShell background jobs in the current session
foreach ($BackgroundJob in $BackgroundJobs) {
	Receive-Job -Job $BackgroundJob
}

Pause

exit
This code initiates streaming and captures the output in a file in the Windows Downloads directory, it works well. However, when I change the OutFile parameter to OutFile = "NUL", it returns "Stream does not support seeking." When I change the OutFile parameter to OutFile = "NUL:", it returns "Cannot find drive. A drive with the name 'NUL' does not exist."

If there is a better choice than Start-ThreadJob, I'd be good with that. I am using Start-ThreadJob to allow me to submit multiple streaming requests simultaneously. Currently, I have six set as the maximum, which leaves me two tuners for actual recording/playback purposes. Hopefully, there is at least one PowerShell guru out there that can help me out.

signcarver
Expert
Posts: 11423
Joined: Wed Jan 24, 2007 1:04 am
Device ID: 10A05954 10802091 131B34B7 13231F92 1070A18E 1073ED6F 15300C36
x 40

Re: Send HTTP Recording Stream to NUL?

Post by signcarver »

I didn't have time to really look at your script or try to run it (on phone on a bus at the moment) but typically in windows i believe such would be $null (such as >$null ) and i think in the case of invoke web request there is also an out-null available.

Billi23
Posts: 163
Joined: Mon Mar 20, 2017 8:08 pm
Device ID: 1323AADB

Re: Send HTTP Recording Stream to NUL?

Post by Billi23 »

What signcarver said is covered here https://geekeefy.wordpress.com/2017/10/ ... owershell/
I don't mess with PowerShell

Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Re: Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

Thanks for the info, Billi23 and signcarver.

I finally found the correct syntax, here's the updated code (in case anyone else has a need for this):

Code: Select all

$WebRequestParameters = [ordered]@{ Uri = "http://192.168.1.41:5004/tuner3/v20.1?duration=300" }

# Create and initialize the $BackgroundJobs array
$BackgroundJobs = @()

# Invoke streaming for each channel requested (maximum 6 channels)
foreach ($WebRequestParameter in $WebRequestParameters) {
	$BackgroundJobs += Start-ThreadJob -Name $WebRequestParameter.Uri -ScriptBlock {
		$params = $Using:WebRequestParameter
		Invoke-WebRequest @params | Out-Null
	} -ThrottleLimit 6
}

# Wait until streaming for all requested channels is complete
Write-Host "Streaming initiated at" (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
Wait-Job -Job $BackgroundJobs
Write-Host "All streaming successfully completed at" (Get-Date -Format "yyyy-MM-dd HH:mm:ss")

# Display the results of the PowerShell background jobs in the current session
foreach ($BackgroundJob in $BackgroundJobs) {
	Receive-Job -Job $BackgroundJob
}

Pause

exit

Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Re: Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

Well, I spoke a little too soon. Turns out, using either the Out-Null sub command or using > nul maxes out at 2 GB. Once it hits 2 GB, it stops and returns a "Stream was too long" message. Unless anyone has other suggestions, I'll need to switch back to streaming to a file, or restricting the length of time for the streaming requests. I'm as surprised as the next guy that nul has a limit.

I'm using PowerShell version 7.5.1.

Billi23
Posts: 163
Joined: Mon Mar 20, 2017 8:08 pm
Device ID: 1323AADB

Re: Send HTTP Recording Stream to NUL?

Post by Billi23 »

If you just want signal stats, why stream?
Why not use hdhomerun_config
https://info.hdhomerun.com/info/hdhomer ... al_channel
https://info.hdhomerun.com/info/hdhomer ... l_strength

Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Re: Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

I'm not sure I understand your suggestion. I am using the SiliconDust http api for tuning channels, and for collecting stats for signal strength/quality etc. The hdhomerun_config application accesses pretty much the same information, so I don't see how that would be a better solution. Unless I'm missing something...

The statistics I am collecting end up with auto-updating charts in excel, which update every minute. So I can see tuner behavior real-time, and/or historically. Here's an example of one of my excel charts:

https://drive.google.com/file/d/1SHSHIF ... sp=sharing

With that chart, it's easy to see that there was a serious signal issue on June 3rd. Per jasonl on this forum, it was likely due to tropospheric ducting.

Billi23
Posts: 163
Joined: Mon Mar 20, 2017 8:08 pm
Device ID: 1323AADB

Re: Send HTTP Recording Stream to NUL?

Post by Billi23 »

KeithAbbott wrote: Wed Jun 11, 2025 6:13 pm I'm not sure I understand your suggestion.
The hdhomerun_config application accesses pretty much the same information, so I don't see how that would be a better solution. Unless I'm missing something...
If you use the hdhomerun_config application to tune a frequency or channel and to get the status, it doesn't have to stream output to do it.
It just tunes. No need to use the network and capture a stream from it.

Although you could do that
https://info.hdhomerun.com/info/hdhomer ... g_a_stream
https://info.hdhomerun.com/info/hdhomer ... et_machine

Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Re: Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

As far as I know, the hdhomerun_config application shows a continuously refreshed snapshot of a moment in time, and does not have a way to export the signal information that is being displayed to another tool. So I would probably have to resort to screen-scraping the app to collect a history of tuner performance. Also, it doesn't display dBmV values for signal strength or dB values for signal quality. So I would lose more than I would gain by utilizing the hdhomerun_config application.

The http api has a similar provision to capture stats for channels that are tuned but not currently streaming. Since I do not want to capture data for 14 tuners 24 hours/day, I have my php data capture program set to exclude signal information for tuners that do not have a valid TargetIP. That way, I am only capturing data for channels that are actively being recorded.
Last edited by KeithAbbott on Wed Jun 11, 2025 7:07 pm, edited 1 time in total.

Billi23
Posts: 163
Joined: Mon Mar 20, 2017 8:08 pm
Device ID: 1323AADB

Re: Send HTTP Recording Stream to NUL?

Post by Billi23 »

This is what I meant by using the "command line utility"

Code: Select all

C:\>"C:\Program Files\Silicondust\HDHomeRun\hdhomerun_config" 1323AADB set /tuner2/vchannel 706

C:\>"C:\Program Files\Silicondust\HDHomeRun\hdhomerun_config" 1323AADB get /tuner2/status
ch=qam:129000000 lock=qam256 ss=96 snq=100 seq=100 bps=3478752 pps=0

C:\>"C:\Program Files\Silicondust\HDHomeRun\hdhomerun_config" 1323AADB get /tuner2/status
ch=qam:129000000 lock=qam256 ss=96 snq=100 seq=100 bps=4132992 pps=0

C:\>"C:\Program Files\Silicondust\HDHomeRun\hdhomerun_config" 1323AADB get /tuner2/status
ch=qam:129000000 lock=qam256 ss=96 snq=100 seq=100 bps=4129984 pps=0

C:\>"C:\Program Files\Silicondust\HDHomeRun\hdhomerun_config" 1323AADB set /tuner2/vchannel none

C:\>"C:\Program Files\Silicondust\HDHomeRun\hdhomerun_config" 1323AADB get /tuner2/status
ch=none lock=none ss=0 snq=0 seq=0 bps=0 pps=0
KeithAbbott wrote: Wed Jun 11, 2025 6:50 pm Also, it doesn't display dBmV values for signal strength or dB values for signal quality.
True

Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Re: Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

Yes, I have used that before. The http api gives me the exact same functionality (including signal status from a non-streaming tuner) as the hdhomerun_config app, but includes additional information that the hdhomerun_config app cannot provide. Plus using the hdhomerun_config app will use more system resources by constantly initiating a new instance of the app. Frankly, if I can't get the Out-Null option to work, I'll just revert back to streaming to a disk file. No harm, no foul. After all, disk is cheap.

jasonl
Silicondust
Posts: 17404
Joined: Sun Oct 28, 2007 9:23 pm
x 71

Re: Send HTTP Recording Stream to NUL?

Post by jasonl »

You can tune via hdhomerun_config and still use the status.json for stats. Worrying about the performance of a compiled C program while running a PowerShell script is kind of funny though.

Online
KeithAbbott
Posts: 79
Joined: Fri Mar 11, 2011 7:10 pm

Re: Send HTTP Recording Stream to NUL?

Post by KeithAbbott »

I'm filing this under the "I'm sorry I even asked" category. I already reverted the code back to capture the stream(s) to a local drive.

I have a data collection PHP script that runs 24/7, that queries all 14 tuners once per minute. If any of the tuners are actively streaming (i.e. TargetIP contains a valid IP address), it captures all of the signal stats (strength, quality, etc.) and saves them on my server for later analysis. The majority of the 24 hours, none of the tuners are actively streaming. If I were to change the data collection program so that it ignores the TargetIP field (thereby collecting data for whatever channels the tuners happen to have been set at, even if they are duplicate channels), the amount of data being collected would increase substantially, for no practical benefit. So I would chew up far more disk space than I am using by streaming to a local disk file and then immediately/programmatically deleting that file once the tuner has finished streaming.

The PowerShell script is strictly used to initiate streaming on channels that are not recorded often. It's completely separate from the PHP script, and I only manually initiate the script when needed. I created the PowerShell script because it is hard to optimize something when it is rarely used. My script forces those channels to be used from a background process that is almost invisible to me.

Please, let's stop beating this dead horse. I appreciate the initial suggestions, and if it wasn't for that fairly obscure 2GB limitation, Out-Null would have worked perfectly.

Post Reply