环境:
ubuntu-11.04-desktop-amd64.iso
一,前期准备:
1,下载live555
下载源码:http://www.live555.com/liveMedia/public
可以下载最新的,我下载的版本是:live.2012.12.24.tar.gz
2,安装live555
root@microcreat:/workdir/private# ls
live555-latest.tar.gz
root@microcreat:/workdir/private# tar -zxvf live555-latest.tar.gz
root@microcreat:/workdir/private# ls
live live555-latest.tar.gz
root@microcreat:/workdir/private/live# ls
BasicUsageEnvironment config.freebsd config.solaris-32bit Makefile
config.aix config.iphoneos config.solaris-64bit Makefile.head
config.alpha config.irix config.sunos Makefile.tail
config.armeb-uclibc config.linux config.uClinux mediaServer
config.armlinux config.linux-64bit configure proxyServer
config.avr32-linux config.linux-gdb COPYING README
config.bfin-linux-uclibc config.macosx fix-makefile testProgs
config.bfin-uclinux config.macosx-32bit genMakefiles UsageEnvironment
config.bsplinux config.macosx-before-version-10.4 genWindowsMakefiles win32config
config.cris-axis-linux-gnu config.mingw genWindowsMakefiles.cmd win32config.Borland
config.cygwin config.openbsd groupsock WindowsAudioInputDevice
config.cygwin-for-vlc config.qnx4 liveMedia
root@microcreat:/workdir/private/live# ./genMakefiles linux
root@microcreat:/workdir/private/live# make
这样就编译完成了。
3,安装SMplayer
sudo add-apt-repository ppa:rvm/smplayer
sudo apt-get update
sudo apt-get install smplayer smtube smplayer-themes
注:如果下面的错误:
root@microcreat:/workdir/private# sudo apt-get install smplayer smtube smplayer-themes
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/cn.archive.ubuntu.com_ubuntu_dists_natty_restricted_i18n_Translation-en
E: The package lists or status file could not be parsed or opened.
解决方法是:
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
这样SMplayer就安装OK了。
可以用"Applications -> Sound & Video -> MPlayer Movie Player"来运行mplayer。
二,用本机搭建RTSP服务器
2.1其实很简单,就是利用刚刚编译成功的live555的源码。
root@microcreat:/workdir/private/live/mediaServer# pwd
/workdir/private/live/mediaServer
root@microcreat:/workdir/private/live/mediaServer# ls
COPYING DynamicRTSPServer.hh in.264 live555MediaServer.cpp Makefile Makefile.tail
DynamicRTSPServer.cpp DynamicRTSPServer.o live555MediaServer live555MediaServer.o Makefile.head version.hh
在此项目中放入一个in.264的文件,然后启动服务器:
root@microcreat:/workdir/private/live/mediaServer# ./live555MediaServer
LIVE555 Media Server
version 0.75 (LIVE555 Streaming Media library version 2012.09.27).
Play streams from this server using the URL
rtsp://192.168.196.128:8554/<filename>
where <filename> is a file present in the current directory.
Each file's type is inferred from its name suffix:
".264" => a H.264 Video Elementary Stream file
".aac" => an AAC Audio (ADTS format) file
".ac3" => an AC-3 Audio file
".amr" => an AMR Audio file
".dv" => a DV Video file
".m4e" => a MPEG-4 Video Elementary Stream file
".mkv" => a Matroska audio+video+(optional)subtitles file
".mp3" => a MPEG-1 or 2 Audio file
".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file
".ts" => a MPEG Transport Stream file
(a ".tsx" index file - if present - provides server 'trick play' support)
".wav" => a WAV Audio file
".webm" => a WebM audio(Vorbis)+video(VP8) file
See http://www.live555.com/mediaServer/ for additional documentation.
(We use port 8000 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).)
2.2 另外开一个终端:来启动SMplayer
root@microcreat:~# mplayer rtsp://192.168.196.128:8554/in.264
mplayer: Symbol `ff_codec_bmp_tags' has different size in shared object, consider re-linking
MPlayer 1.0rc4-4.5.2 (C) 2000-2010 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing rtsp://192.168.196.128:8554/in.264.
Resolving 192.168.196.128 for AF_INET6...
Couldn't resolve name for AF_INET6: 192.168.196.128
Connecting to server 192.168.196.128[192.168.196.128]: 8554...
rtsp_session: unsupported RTSP server. Server type is 'unknown'.
STREAM_LIVE555, URL: rtsp://192.168.196.128:8554/in.264
Stream not seekable!
file format detected.
Initiated "video/H264" RTP subsession on port 48870
demux_rtp: Guessed the video frame rate as 30 frames-per-second.
(If this is wrong, use the "-fps <frame-rate>" option instead.)
VIDEO: [H264] 0x0 0bpp 30.000 fps 0.0 kbps ( 0.0 kbyte/s)
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
[VO_TDFXFB] This driver only supports the 3Dfx Banshee, Voodoo3 and Voodoo 5.
[VO_3DFX] Unable to open /dev/3dfx.
Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
[vdpau] Error when calling vdp_device_create_x11: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Audio: no sound
Starting playback...
Movie-Aspect is undefined - no prescaling applied.
VO: [xv] 160x128 => 160x128 Planar YV12
V: 17.4 592/592 1% 1% 0.0% 0 0
Exiting... (Quit)
这样rtsp服务器就搭建完成!