问题
从 HDHomerun Prime 录制电视节目会导致 30 秒的清晰视频,然后发出响亮的哔哔声并丢失大约半秒的视频,或者导致视频流看起来像是从信号非常差的 OTA 电视录制的(即:我每秒可能收到两三个好的视频帧,但完全无法观看)。请帮助我解决这个问题,因为这些时候我从来不在家看我最喜欢的节目。
网络设置
我有一台 TP-Link TL-SG1016D(千兆),带有一条 Cat5E 电缆,连接到我的 HDHomerun Prime(具有 DHCP 保留 IP)。
同时连接到我的 TP-Link 交换机的还有:
Netgear WNDR-4500(通过 Cat5E)用于互联网访问和 DHCP 服务器
Poweredge 1950(通过两根 Cat5E 电缆),运行 ESXi 5.1u1,带有一个用于录制的 arch linux VM。
较旧的定制英特尔台式机(通过 Cat5E 插入 Netgear WNDR-4500),配备高端 Core 2 Duo、千兆以太网,运行 arch linux 用于录制
软件设置
两个 Arch Linux 系统都启用了 cronie 服务并安装了 curl
这是我的 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
这是它调用的 bash 文件:
#!/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"
答案1
问题出在缓存和使用 http 下载程序和 stdout 写入文件上。如果有人知道为什么我的解决方案有效而我原来的努力无效,请发表评论!
这是我所做的:
- 我的 Crontab 看起来一样
- 我的录制脚本使用 mplayer 并在写入文件时将媒体缓存到内存中
- 我检查了正在使用的硬盘的写入速度,并且始终获得持续的连续写入速度在 74-76MB/s 之间
这是我的脚本:#!/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