Can't get clean recording from HDHomerun Prime via curl

0

The Problem
Recording TV shows from HDHomerun Prime results in either 30 seconds of clean video, then a loud beep and loss of roughly 1/2 a second or results in a stream that looks like it was recorded from OTA TV with a really bad signal (ie: I get maybe two or three good frames per second of video and it's completely unwatchable). Please help me get this working, as I am never home at these times to watch my favorite shows.

Network Setup
I have a TP-Link TL-SG1016D (gigabit) with a Cat5E cable going to my HDHomerun Prime (which has a DHCP reserved IP)
Also hooked into my TP-link switch are:
Netgear WNDR-4500 (via Cat5E) for internet access and DHCP server
Poweredge 1950 (via two Cat5E cables) running ESXi 5.1u1 with an arch linux VM for recording
Older custom Intel desktop (via Cat5E plugged into the Netgear WNDR-4500) with a high-end Core 2 Duo, gigabit ethernet running arch linux for recording

Software Setup
Both of the arch linux systems have the cronie service enabled and have curl installed

Here is my crontab:

#Agents of SHIELD
0 20 * * 2 /home/user/cron/RECORD-ch-name-time.sh 707 "Marvel's Agents of SHIELD - 1x02.mpg" 3600
#House
0 21 * * 2 /home/user/cron/RECORD-ch-name-time.sh 704 "House - 4x12-13.mpg" 7200
#Person of Interest
0 22 * * 2 /home/user/cron/RECORD-ch-name-time.sh 705 "Person of Interest - 3x02.mpg" 3600
#Arrow
0 20 * * 3 /home/user/cron/RECORD-ch-name-time.sh 712 "Arrow - 2x01.mpg" 3600

Here is the bash file it is calling:

#!/bin/bash

CHANNEL=707
FILENAME="output"
TIMEOUTSECS=3720

# Set channel
if [ "$1" ]
    then
        CHANNEL="$1"
fi

# Set filename
if [ "$2" ]
    then
        FILENAME="$2"
fi

# Set timeout time in minutes
if [ "$3" ]
    then
        TIMEOUTSECS="$3"
fi

# Start recording
cd /home/user/recordings
echo curl http://192.168.1.200:5004/auto/v$CHANNEL -m $TIMEOUTSECS>> "v$CHANNEL"
curl http://192.168.1.200:5004/auto/v$CHANNEL -m $TIMEOUTSECS>> "v$CHANNEL"
echo "Renaming output_file in RECORD-ch-name-time.sh"
mv "v$CHANNEL" "$FILENAME"
cd /home/user/cron
echo "End of RECORD-ch-name-time.sh"

KG6ZVP

Posted 2013-09-26T18:06:22.183

Reputation: 111

Have you tired eliminating the rest of the network (just the client, the server and a (crossover) cable) to ensure another device isn't bottlenecking or interfering? – Ƭᴇcʜιᴇ007 – 2013-09-26T18:12:01.127

I have not. The effort required to do that would be too great as the HDHomerun Prime is located in a different room from the baremetal recorder and ESXi doesn't have the hardware passthrough capabilities on the Poweredge 1950 like it does on the T510's and so on. I should mention: I have tried both machines as recorders separately so as to keep network traffic from the tuner to a minimum. Since all of this should theoretically work on a 100megabit ethernet system, I am baffled as to what the problem is on an entirely gigabit network. – KG6ZVP – 2013-09-26T18:17:40.513

"Since all of this should theoretically work on a 100megabit ethernet system, I am baffled as to what the problem is on an entirely gigabit network." Why be baffled unless you KNOW it works on a 100Mb network? My guess is that it has nothing to do with network capability. Since you can't reduce the network physically to troubleshoot, then have you done any network sniffing to see if there's excessive network traffic that may be affecting the stream? – Ƭᴇcʜιᴇ007 – 2013-09-26T18:18:35.280

No, I have not. I have only tested network latency with ping and tested download and upload speeds over the network between systems. How would you recommend I troubleshoot it? – KG6ZVP – 2013-09-26T18:22:18.117

Monitor all and any internet traffic from my home PC - what should I use? - mainly Wireshark. :) – Ƭᴇcʜιᴇ007 – 2013-09-26T18:25:10.623

I have used wireshark in the past to figure out some latency and routing issues. However, I am enough of a n00b with it that I don't see how it would help me here. The weird part of all this is that when I have manually started recording jobs by just calling curl directly, I don't see any stuttering or other problems recording (then again, I have never done a test recording using curl with a duration of more than 10 minutes) – KG6ZVP – 2013-09-26T18:27:50.267

let us continue this discussion in chat

– KG6ZVP – 2013-09-26T18:28:03.767

Please describe the hardware of "both of the arch linux systems". – sawdust – 2013-09-26T18:46:41.393

Virtual Machine <br>RAM: 1GB (reserved) <br>Swap partition: 4GB <br>CPU: 1 virtual socket, 8 cores (physical machine has two quad-core Xeons at 2.66Ghz each) <br>HD: 200GB virtual disk (virtual ISCSI) <br>Network Adapter: E1000 <br><br> Physical <br>motherboard: Intel D975XBX2 <br>CPU: Core 2 @ 2.4Ghz <br>Ram: 4GB DDR2-533mhz <br>HD: 500GB Western Digital IDE and 1TB WD Black have both been tried as recording drives <br><br> both <br>Both systems have the latest package updates – KG6ZVP – 2013-09-26T19:16:29.983

Answers

0

The problem was with caching and with using an http download program and stdout to write to a file. If anyone has any ideas as to why my solution works and my original effort did not, please comment!

This is what I did:
-My Crontab looks the same
-My recording script uses mplayer and caches the media to memory as it writes to a file
-I checked the write speed of the hard disk I was using and I consistently get sustained contiguous writes of betwen 74-76MB/s

Here's my script: #!/bin/bash

CHANNEL=707
FILENAME="output"
TIMEOUTSECS=3601

# Set channel
if [ "$1" ]
    then
        CHANNEL="$1"
fi

# Set filename
if [ "$2" ]
    then
        FILENAME="$2"
fi

# Set timeout time in minutes
if [ "$3" ]
    then
        TIMEOUTSECS="$3"
fi

echo $0 $CHANNEL $FILENAME $TIMEOUTSECS> "/home/user/cron/log/log-RECORD.sh $CHANNEL $FILENAME $TIMEOUTSECS.txt"

# Start recording
cd /home/user/recordings
echo RECORDING>> "/home/user/recordings/$FILENAME.LOCK.mkv"
echo mplayer -cache 131072 -dumpfile "/home/user/recordings/$FILENAME.mpg" -dumpstream "http://192.168.1.200:5004/auto/v$CHANNEL"

/usr/bin/mplayer -cache 196608 -dumpfile "/home/user/recordings/$FILENAME.mpg" -dumpstream "http://192.168.1.200:5004/auto/v$CHANNEL"&
sleep $TIMEOUTSECS
sleep 1
for s in HUP INT KILL; do
    kill -$s $! &>/dev/null || break
    sleep 5
done

rm "/home/user/recordings/$FILENAME.LOCK.mkv"

/usr/bin/ccextractor "/home/user/recordings/$FILENAME.mpg" -out=srt -o "/home/user/recordings/$FILENAME.srt"
/usr/bin/ffmpeg -i "/home/user/recordings/$FILENAME.mpg" -i "/home/user/recordings/$FILENAME.srt" -scodec copy -vcodec copy -threads 8 -acodec copy "/home/user/recordings/$FILENAME-Editable.mpg"

/usr/bin/ffmpeg -i "/home/user/recordings/$FILENAME.srt" -i "/home/user/recordings/$FILENAME-Editable.mkv" -scodec copy -vcodec libx264 -threads 8 -crf 26 -coder 1 -acodec aac -vbr 4 -strict -2 "/home/user/recordings/$FILENAME-Quick.mkv"

chown -R user "/home/user/recordings/*"

cd /home/user/cron

KG6ZVP

Posted 2013-09-26T18:06:22.183

Reputation: 111