Total Pageviews

Monday, 16 July 2012

使用简单的办法让linux变成一个流媒体服务器

以FreeBSD的inetd为例:
在/etc/inetd.conf增加一行:
mgplay stream tcp    nowait root   /bin/cat  cat/usr/home/pm/mp3/dvb.mpg
注意没有折行。
在/etc/services增加一行:
mgplay           1234/tcp #media transfer
重新启动inetd服务
然后就可以在别的机器上访问/mp3/dvb.mpg了,比如:
nc <youfreebsdip> 1234|mplayer -
就可以看电影啦,呵呵。
把/usr/home/pm/mp3/dvb.mpg换成你想要播放的设备也可以,比如要想适用1020卡收看卫星电视,可以换成:
/dev/dvb/adapter0/dvr0
就可以在其他的机器上收看了。
windows机器上可以下载windows版本的nc,地址如下:
当然不用inetd,直接适用nc作为服务端也可以,比如:
nc -k -l 1234 < /dev/dvb/adapter0/dvr0
不过不如inetd方便.
-------------------------
终于让1020卡工作起来了,也了解了其大概工作流程。

需要安装的驱动:
参考内核文档
/usr/src/linux-2.6.20.1/Documentation/dvb/bt8xx.txt
1) Running TwinHan and Clones

       $ modprobe bttv card=113
       $ modprobe dvb-bt8xx
       $ modprobe dst


/usr/src/linux-2.6.20.1/Documentation/dvb/faq.txt
2. How can I watch TV?
       The driver distribution includes some simple utilities which aremainly intended for testing and to demonstrate how the DVB APIworks.
       Depending on whether you have a DVB-S, DVB-C or DVB-T card, useapps/szap/szap, czap or tzap. You must supply a channel list in~/.[sct]zap/channels.conf. If you are lucky you can just copy oneof the supplied channel lists, or you can create a new one byrunning apps/scan/scan. If you run scan on an unknown network youmight have to supply some start data inapps/scan/initial.h.
       If you have a card with a built-in hardware MPEG-decoder thedrivers create a video4linux device (/dev/v4l/video0) which you canuse to watch TV with any v4l application. xawtv is known to work.Note that you cannot change channels with xawtv, you have to zapusing [sct]zap. If you want a nice application for TV watching andrecord/playback, have a look at VDR.
       If your card does not have a hardware MPEG decoder you need asoftware MPEG decoder. Mplayer or xine are known to work.Newsflash: MythTV also has DVB support now. Note: Only very recentversions of Mplayer and xine can decode. MPEG2 transport streams(TS) directly. Then, run '[sct]zap channelname -r' in one xterm,and keep it running, and start 'mplayer - </dev/dvb/adapter0/dvr0' or 'xine stdin://mpeg2 </dev/dvb/adapter0/dvr0' in a second xterm. That's all far fromperfect, but it seems no one has written a nice DVB applicationwhich includes a builtin software MPEG decoderyet.
还需要这个:
linuxtv-dvb-apps-1.1.1
linuxtv-dvb-apps-1.1.1/util/scan/scan -x 0 -l 11300 dvb-s/138.0E>channels.conf

上面的命令可以升成一个channels.conf 下面的szap需要
cp channels.conf ~/.szap/
调整高频头:
linuxtv-dvb-apps-1.1.1/util/szap/szap -l 11300 -r -n 32
下面的操作应该可以在faq.txt看到了.