View Single Post
Old 12-Sep-2019, 8:32 PM   #10
TheFu
Junior Member
 
Join Date: Aug 2012
Posts: 10
more ssh and scripts for HDHR

I have a few HDHR network tuners connected to the network. In the USA, ATSC is mpeg2 TS. Not the most efficient video codec available today. Either h.264 or h.265 are dramatically better. h.264 uses about 50% less bandwidth than mpeg2. h.265 uses about 50% less than h.264 - those are rough estimates. YMMV.

It is possible to have the HDHR "record" and pipe that output into ffmpeg to transcode it into either h.264 or h.265 video before streaming over ssh or a VPN.

I haven't used this in about a year, but it worked previously:
Code:
#!/bin/bash

CH=69.1
in=test-$CH
/usr/bin/timeout 1.25h \
wget -q -O - http://hdhr4:5004/auto/v$CH | \
 ffmpeg      -i -       -c:v libx264       -crf 19.5 \
         -vf scale=-1:720 \
         -preset veryfast \
         -c:a libvorbis -q:a 6 "$in.mkv"
The ability for live transcoding is determined by the system running the ffmpeg task. I for only 720p resolutions and use vorbis for audio.
On the remote system, we just need to playback the created mkv file. h.264 can work well on dual core pentium/celeron systems. h.265 can't keep up without a more powerful CPU than I have for this.

timeout will end the wget pulling the stream from the HDHR in 1.25 hours.
The veryfast option sacrifices file size for speed.

Don't forget that the ~/.ssh/config file can hold any options for a specific connection, just use a different alias for the stanza
Code:
host tv-record
  user thefu
  hostname 123.4.5.6 
  port 62428


host tv-root
   user root
  hostname 123.4.5.6 
  port 62428
No need to ever use the userid, IP or non-standard port again. Every ssh tool honors this file. sftp, scp, rsync, ssh, x2go, sshfs, and the 50 backup tools as well. The ssh_config manpage spells out all the options for this client-side config file. The hostname can be a DNS name too, if you like. Only the first "host" part needs to be unique. Different ssh-keys can be specified, as can ssh port forwarding.

Instead of using this transcode script, I just let the plex server transcode the mpeg2 into h.264 and control the bandwidth needed by the plex web server settings. I'm using the plex web-app and don't have a plex userid or plex account. To access the plex web-app on the home LAN, I use:
Code:
#!/bin/bash

PORT=62001
# Only start SOCKS proxy if necessary
if  [ $(ps -eaf |grep ssh |grep -c $PORT ) = 0 ] ; then
   # Setup SOCKS proxy through home server
   echo "Starting ssh SOCKS Proxy"
   ssh -f -C -D $PORT  123.4.5.6  -NT &
fi 

# Star private firejail with chromium, going through 
# just setup SOCKS proxy
sleep 3;
echo "Starting Firejail chromium with private & proxy "
export http_proxy="socks5://localhost:$PORT "; 
firejail --private chromium-browser \
         --proxy-server="socks5://localhost:$PORT " &
I didn't intend to put so much here. Sorry. Hopefully, someone will find it useful.

I have no idea how to accomplish the same using Windows. We are a Unix household.
TheFu is offline   Reply With Quote