DIY DSM DS3612xs /NAS212j +dvb3221实现iPhone随时随地收看和录制NBA。
本帖最后由 sangood 于 2014-9-28 12:07 编辑经过一段时间的研究,终于实现了在路由器、NAS212j上添加电视盒,实现手机、iPad收看、录制电视节目。更新:目前在DIY DSM4.3 ds3612xs x64上面实现同样功能。
2014-9-28号,更新tvheadendtesting,最新版本tvheadend-testing_bromolow_3.9.1562-21.spk,支持内置转码。
相关软件下载:**** Hidden Message *****
硬件条件:1、DIY NAS、NAS212j(也可以路由器如4530R,树莓派)。
2、dvb-c 3221 USB 电视盒(也可以有相关驱动的电视卡、电视盒等)。
3、有线电视接入,且有线电视机卡不绑定,可以使用读卡器oscam读卡。
4、USB读卡器
5、手机、电脑、openwrt路由器。
软件:
1、dvb-c 3221驱动
2、tvheadend
3、tvhclient 和vlc for iPhone 客户端。
4、oscam for openwrt 或者 oscam for nas。
5、xbmc or vlc for windows or mac.
暂时只是提供简单思路,给有折腾精神的人士参考。
编译参考:
https://github.com/SynoCommunity/spksrc
更多资料,请自行搜寻。其他机型参考楼下编译笔记。
spksrc + Synology NAS 212j 88f281 编译 tvheandend +libdvbcsa + oscam centos 7.1 32bit i686
1. centos insatll
debian-7.0.0-i386-CD-1 install
sangood@debian:~$ uname -a
Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1+deb7u1 i686 GNU/Linux
2.
https://github.com/SynoCommunity/spksrc
spksrc
spksrc is a cross compilation framework intended to compile and package softwares for Synology NAS
Requirements
To use spksrc, it is recommended to use a virtual machine with an x86 version of Debian stable OS installed. You'll also need some stuff:
sudo aptitude install build-essential debootstrap python-pip automake libgmp3-dev libltdl-dev libunistring-dev libffi-dev ncurses-dev imagemagick libssl-dev pkg-config zlib1g-dev gettext git curl subversion check bjam intltool gperf flex bison xmlto php5 expect libgc-dev mercurial cython
sudo pip install -U pip
You may need to install some packages from testing like autoconf. Read about Apt-Pinning to know how to do that.
You are now ready to use spksrc and make almost all SPKs. If you have any problem, try installing the missing packages on your virtual machine.
Usage
Lets start with an example:
git clone https://github.com/SynoCommunity/spksrc.git
cd spksrc/
make setup
cd spk/transmission
make arch-88f6281
What have I done?
You cloned the repository
Went into the directory of the SPK for transmission
Started building the SPK for the architecture 88f6281
To list all available architectures use ls toolchains from within the spkrc directory. Remove the prefix syno- to have the actual architecture.
An overview of which architecture is used per Synology model can be found on the wiki pageArchitecture per Synology model
At the end of the process, the SPK will be available in spksrc/packages/
What is spksrc doing?
First spksrc will read spksrc/spk/transmission/Makefile
Download the adequate toolchain for the chosen architecture
Recursively:
Process dependencies if any
Download the source in spksrc/distrib/
Extract the source
configure
make
make install
Package all the requirements into a SPK under spksrc/packages/:
Binaries
Installer script
Start/Stop/Status script
Package icon
Wizards (optional)
Help files (optional)
Contribute
The only thing you should be editing in spksrc is Makefiles. To make a SPK, start by cross-compiling the underlying package. To do so:
Copy a standard cross package like spksrc/cross/transmission/Makefile in your new package directory spksrc/cross/newpackage/
Edit the Makefile variables so it fits your new package
Empty variables DEPENDS and CONFIGURE_ARGS in the Makefile
Try to cross-compile and fix issues as they come (missing dependencies, configure arguments, patches)
cd spksrc/cross/newpackage/
make arch-88f6281
Use make clean to clean up the whole working directory after a failed attempt
On a successful cross-compilation create a PLIST file with the same syntax asspksrc/cross/transmission/PLIST but based on the auto-generated PLIST for your new package atspksrc/cross/newpackage/work-88f6281/newpackage.plist
Once you have successfully cross compiled the new package, to create the SPK:
Copy a standard SPK directory like spksrc/spk/transmission in your new SPK directoryspksrc/spk/newspk
Edit the stuff to fit your needs
After all that hard work, submit a pull request to have your work merged with the main repository on GitHub and published in SynoCommunity's repository.
If you are not familiar with git or GitHub, please refer to the excellent GitHub help pages.
3。
cd /home/sangood/nas/spksrc/cross/libdvbcsa
vi Makefile
PKG_NAME = libdvbcsa
PKG_VERS = 1.1.0
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = http://download.videolan.org/pub/videolan/libdvbcsa/1.1.0
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)
DEPENDS =
HOMEPAGE = http://download.videolan.org/pub/videolan/libdvbcsa/1.1.0/
COMMENT= libdvbcsa 1.1.0
LICENSE=
CONFIGURE_ARGS = cross_compiling=yes--prefix=$(INSTALL_PREFIX)
include ../../mk/spksrc.cross-cc.mk
make arch-88f6281
如果成功将得到如下包
lnk:lib/libdvbcsa.so
lnk:lib/libdvbcsa.so.1
lib:lib/libdvbcsa.a
lib:lib/libdvbcsa.la
lib:lib/libdvbcsa.so.1.0.1
dvbcsa/dvbcsa.h
这些包安装后需要拷贝到NAS的 /volume1/@appstore/tvheadend/ 目录执行--(已经打包进spk文件,不需要这步)。
4.tvheadend
sangood@debian:~/nas/spksrc/cross/tvheadend/$ vi Makefile
修改:CONFIGURE_ARGS = --enable-dvbconv --enable-dvbcsa --disable-avahi libdvbcsa --release
--enable-dvbconv 增加中文支持https://github.com/tvheadend/tvheadend/pull/90
修改为github源:
sangood@debian:~/nas/spksrc/cross/tvheadend$ cat Makefile
PKG_NAME = tvheadend
PKG_VERS = 3.5.2
PKG_EXT = tar.gz
PKG_DOWNLOAD_METHOD = git
PKG_GIT_HASH = f5c5ffd
PKG_DIST_NAME = tvheadend.git
PKG_DIST_SITE = git://github.com/tvheadend
PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT)
PKG_DIR = $(PKG_NAME)-git*
DEPENDS = cross/openssl cross/libdvbcsa
HOMEPAGE = https://www.lonelycoder.com/tvheadend/
COMMENT= Tvheadend is a TV streaming server for Linux supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, IPTV, and Analog video (V4L) as input sources
LICENSE=
GNU_CONFIGURE = 1
CONFIGURE_ARGS =--enable-dvbcsa --disable-avahi --release
INSTALL_TARGET = myInstall
include ../../mk/spksrc.cross-cc.mk
.PHONY: myInstall
myInstall:
$(RUN) make install DESTDIR=$(INSTALL_DIR)
sangood@debian:~/nas/spksrc/cross/tvheadend/patches$ ls
atomic32.patchcapmt.c-svn.patchiov-max.patchpsi.c-svn.patchWerror.patch dvb_support.c-svn.patchmain.c-svn.patch dvr_rec.c-svn.patch
tvheadend的补丁包,其中psi.c-svn.path capmt.c-svn.patch 见sangood github https://github.com/sangood/tvheadend
编译过程输入补丁路径 :src/capmt.c 和 src/psi.c
CONFIGURE_ARGS = --enable-dvbcsa --disable-avahi --release
make arch-88f6821
在目录得到sangood@debian:~/nas/spksrc/packages$ ls
tvheadend_88f6281_3.4.27-6.spk 在nas源里面手动安装,安装之后默认是tvheadend用户启动的。
/usr/local/tvheadend/bin/tvheadend -f -u tvheadend -c /usr/local/tvheadend/var -p /usr/local/tvheadend/var/tvheadend.pid
plus:在NAS上面`/volume1/soft/nas/synosource/libiconv-1.11/ ,编译 libiconv 解决中文乱码问题:dvb_support.c-svn.patchmain.c-svn.patch
https://www.gnu.org/software/libiconv/
$ ./configure --prefix=/usr/local
$ make
$ make install
5.oscam :
改成最新的源码 8968
~/nas/spksrc/cross/oscam$ vi Makefile
PKG_SVN_REV = 8968
.PHONY: myConfigure
myConfigure:
$(RUN) ./config.sh --enable WITH_SSL --enable HAVE_DVBAPI
sangood@debian:~/nas/spksrc/spk/oscam$ vi Makefile
SPK_VERS = 1.20~r8968
如果编译nx111版本(8175--版本 hash=4183129,支持数码视讯5.2.3):
~/nas/spksrc/cross/oscam$ vi Makefile
PKG_NAME = oscam-nx111
PKG_VERS = 1.20
PKG_EXT = tar.gz
PKG_DOWNLOAD_METHOD = git
PKG_GIT_HASH = 4183129
PKG_DIST_NAME = oscam-nx111.git
PKG_DIST_SITE = git://github.com/nx111
PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT)
PKG_DIR = $(PKG_NAME)-git*
sangood@debian:~/nas/spksrc/spk/oscam$ vi Makefile
SPK_VERS = 1.20~r8175
运行脚本
/bin/sh /var/packages/oscam/scripts/start-stop-status status
6.tvheandend 错误
/var/log/syslog:16255:Jan 30 19:28:44tvheadend: TS: TurboSight TBS 6921 DVBS/S2 frontend/Channel: 11,393,000 kHz Vertical (Default (Port 0, Universal LNB))/Channel Style: CA @ #1617: Continuity counter error, 1213 duplicate log lines suppressed
Solution for that is:
go to tvheadend->Configuration->TV Adapter-> and disable “Idle scanning” in tvheadend. The problems will go away.
Did you try it with the "Full mux reception" option set to "off" at your adapter settings? Had the same issue before, until I found this tip. From then on it worked all just fine.
7。dvb3221 驱动加载,加载顺序 i2c dvb-core usb pll tda 3221
dvb-core.kodvb-pll.kodvb-usb.kodvb3221.koi2c-core.koincludetda10023.ko
insmod /lib/modules/2.6.32.12/dvb3221/i2c-core.ko
insmod /lib/modules/2.6.32.12/dvb3221/dvb-core.ko
insmod /lib/modules/2.6.32.12/dvb3221/dvb-usb.ko
insmod /lib/modules/2.6.32.12/dvb3221/dvb-pll.ko
insmod /lib/modules/2.6.32.12/dvb3221/tda10023.ko
insmod /lib/modules/2.6.32.12/dvb3221/dvb3221.ko
8.解决gb2312乱码问题:
dvb_support.c
13.0 KB
补丁生成:
macmini:tvheadend sangood$ diff -uN ./src/dvb/dvb_support.c.orig ./src/dvb/dvb_support.c > ./patches/dvb_support.c-svn.patch
9.解决libiconv 加载问题,处理gb2312转换.
参考:http://www.linuxidc.com/Linux/2012-01/51165.htm
libc的插入/重载模式(libc plug/override mode)。仅工作在GNU/Linux、Solaris和OSF/1系统上。是一种在没有glibc时来获取较好的iconv支持的途径。
这种模式安装库文件preloadable_libiconv.so,通过选项LD_PRELOAD,来重载所有C语言库中的iconv*函数。
GNU/Linux和Solaris系统:
$ export LD_PRELOAD=/usr/local/lib/preloadable_libiconv.so
程序的代码不需要修改,甚至不需要重新编译,仅仅设置环境变量LD_PRELOAD即可。
具体方法:
http://www.linuxidc.com/Linux/2012-01/51165.htm
https://www.gnu.org/software/libiconv/
sangood@debian:~/nas/spksrc/cross/libiconv$ vi Makefile
PKG_NAME = libiconv
PKG_VERS = 1.11
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = http://ftp.gnu.org/pub/gnu/libiconv
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)
HOMEPAGE = https://www.gnu.org/savannah-checkouts/gnu/libiconv/
COMMENT= libiconv 1.14
LICENSE=
CONFIGURE_ARGS = cross_compiling=yes --prefix=$(INSTALL_PREFIX)
include ../../mk/spksrc.cross-cc.mk
sangood@debian:~/nas/spksrc/cross/libiconv/work-88f6281/install/usr/local/lib$ ls
libcharset.alibcharset.lalibcharset.solibcharset.so.1libcharset.so.1.0.0libiconv.lalibiconv.solibiconv.so.2libiconv.so.2.4.0preloadable_libiconv.so
拷贝preloadable_libiconv.so到NAS /lib/preloadable_libiconv.so,启动脚本增加export LD_PRELOAD=/lib/preloadable_libiconv.so
SangoodNAS> vi startvh.sh
insmod /root/dvb3221-modules-2.6/i2c-core.ko
insmod /root/dvb3221-modules-2.6/dvb-core.ko
insmod /root/dvb3221-modules-2.6/dvb-usb.ko
insmod /root/dvb3221-modules-2.6/dvb-pll.ko
insmod /root/dvb3221-modules-2.6/tda10023.ko
insmod /root/dvb3221-modules-2.6/dvb3221.ko
export LD_PRELOAD=/lib/preloadable_libiconv.so
/usr/local/tvheadend/bin/tvheadend -f -u root-c /root/.hts/tvheadend-p /usr/local/tvheadend/var/tvheadend.pid
首次启动tvh:
Code:
tvheadend -C -u root -g root -f
And add the following line to /etc/rc.local (using nano for example):
Code:
/usr/local/tvheadend/bin/tvheadend -f -u root -g root
# comment below when your happy its working
$TVHBIN start -C -u hts -g video -c /opt/tvh_dvrconfig_xbmc
# use this to fork it into the background
#$TVHBIN start -C -f -u hts -g video -c /opt/tvh_dvrconfig_xbmc
总之:
将以下代码加入/etc/rc.local,将控制套件中心的tvheadend启动改为停止:
insmod /root/dvb3221-modules-2.6/i2c-core.ko
insmod /root/dvb3221-modules-2.6/dvb-core.ko
insmod /root/dvb3221-modules-2.6/dvb-usb.ko
insmod /root/dvb3221-modules-2.6/dvb-pll.ko
insmod /root/dvb3221-modules-2.6/tda10023.ko
insmod /root/dvb3221-modules-2.6/dvb3221.ko
export LD_PRELOAD=/lib/preloadable_libiconv.so
/usr/local/tvheadend/bin/tvheadend -f -u root-c /root/.hts/tvheadend-p /usr/local/tvheadend/var/tvheadend.pid
更新:
以上手动拷贝方法已经不需要了,我已经编译进tvheandend spk包里面直接加载了dvb3221 驱动和preloadable_libiconv.so.以及修改了启动脚本,改为root用户启动,自动加载dvb3221驱动,自动加载preloadable_libiconv.so。
代码见 sangood github
安装好spk之后,/bin/sh /usr/local/tvheadend/dvb3221.sh 。控制台重启tvheadend。
将驱动自动加载:
SangoodNAS> vi /etc/rc.local
/bin/sh /usr/local/tvheadend/dvb3221.sh
如果无法登陆,需要修改启动代码
cd /root/.hts/tvheadend/var/accesscontrol/
修改用户名密码
vi 1
{
"enabled": 1,
"username": "tvh",
"password": "tvh",
"comment": "Administrator",
"prefix": "0.0.0.0/0",
"streaming": 1,
"dvr": 1,
"dvrallcfg": 1,
"webui": 1,
"admin": 1,
"id": "1"
}
进来学习了。!~ 楼主神人也! 好复杂哦 看上去好复杂,了解下先! 楼主厉害 谢谢分享!!!!!!!!!! 学习了,哈哈 谢谢分享。。。。 谢谢分享。。。。 谢谢分享。。。。 太赞了,太强大了 我在编openwrt上的,基本出来了,稍后放出。 mike22437120 发表于 2013-11-22 22:54
我在编openwrt上的,基本出来了,稍后放出。
感谢分享! 谢谢分享 有教程详细点吗?新手来看代码头都晕 再次看来,还是高深莫测 好强大,好复杂。 暂时用不着,挣点积分