目的:
在工作項(xiàng)目中會(huì)經(jīng)常遇到IPTV播放RTSP的調(diào)試問(wèn)題馁启,公司內(nèi)沒(méi)有RTSP服務(wù)器前端蛮拔,為了方便調(diào)試和提高工作效率淋样,基于VLC搭建了符合IPTV規(guī)范的RTSP服務(wù)器前端肛度。
VLC RTSP TS準(zhǔn)備環(huán)境:
Ubuntu編譯環(huán)境準(zhǔn)備:
Ubuntu16.04鏡像下載地址:http://mirror.pnl.gov/releases/xenial/
Linux版本編譯在了14.04即可,Window版本編譯最好在16.04上(14.04上某些依賴版本庫(kù)編譯問(wèn)題)
Ubuntu選擇橋接模式,這樣配置后才能在局域網(wǎng)終端才能收到VLC發(fā)出的rtsp流(可在PC端使用VLC測(cè)試播放)
Ubuntu_14.04/16.04基本安裝完成后音羞,進(jìn)入U(xiǎn)buntu啟動(dòng)界面后:
1.配置root用戶(ctrl+alt+T啟動(dòng)shell窗口)
# sudo passwd root
按照說(shuō)明設(shè)置root用戶密碼
2.ssh配置(可選)
# sudo apt-get install openssh-server
將 /etc/ssh/sshd_confg中PermitRootLogin no 改為yes,重新啟動(dòng)ssh服務(wù)
啟動(dòng)SSH服務(wù):
# sudo /etc/init.d/ssh start
# sudo service ssh restart
啟動(dòng)之后可以檢查是否安裝成功并啟動(dòng)
關(guān)閉防火墻:
# ufw disable
3.samba配置(可選)
# apt-get install samba
# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
# gedit /etc/samba/smb.conf
在smb.conf最后添加:
[share]
path = /home/username/share
available = yes
browsealbe = yes
public = yes
writable = yes
重啟生效:
# touch /etc/samba/smbpasswd
# smbpasswd -a root
# sudo service smbd restart
VLC配置及編譯:
Linux版本:
1.VLC代碼及編譯:
https://wiki.videolan.org/UnixCompile/ (頁(yè)面上有最新穩(wěn)定版本):
# wget ftp://ftp.videolan.org/pub/videolan/vlc/2.2.4/vlc-2.2.4.tar.xz
# tar xvJf vlc-2.2.4.tar.xz
# cd vlc-2.2.4
(git clone git://git.videolan.org/vlc.git 這個(gè)是獲取當(dāng)前最新的版本,遇到的編譯問(wèn)題會(huì)很少有人遇到并解決,推薦使用穩(wěn)定版)
# tar xvf vlc-2.2.4.tar.xz
# sudo apt-get install git libtool build-essential pkg-config autoconf
2.編譯
# sudo apt-get build-dep vlc
# ./bootstrap
# ./configure ...(編譯前必須執(zhí)行)
或者選擇開(kāi)關(guān)宏:
# ./configure --enable-static --enable-shared --with-pic --enable-dbus --enable-debug --enable-gprof --enable-cprof --enable-run-as-root --enable-libproxy --enable-live555 --enable-lirc --enable-dc1394 --enable-screen --enable-realrtsp --enable-dvbpsi --enable-ogg --enable-mad --enable-avcodec --enable-libva --enable-switcher --enable-avformat --enable-swscale --enable-postproc --enable-a52 --enable-libmpeg2 --enable-vorbis --enable-flac --enable-speex --enable-tremor --enable-theora --enable-png --enable-libass --with-x --enable-glx --enable-sdl-image --enable-freetype --enable-fontconfig --enable-android-surface -enable-directfb --enable-pulse --enable-alsa --enable-opensles --enable-fribidi --enable-visual --enable-gnutls --enable-media-library --enable-sqlite --enable-loader --enable-vlc
比較重要的宏:
--enable-realrtsp(rtsp播放一定要打開(kāi)的宏)
--enable-debug(調(diào)試可打開(kāi))
--enable-run-as-root(在linux環(huán)境下執(zhí)行權(quán)限)
詳細(xì)參考configure.ac文件中--enable-*模塊
這是我為項(xiàng)目配置的編譯項(xiàng):
# ./configure --enable-run-as-root --enable-live555 --enable-realrtsp --enable-avcodec --enable-avformat --enable-libmpeg2 --enable-dvbpsi --disable-qt
首先可以使用./configure 后直接編譯,確碧盘矗可編譯通過(guò)后在使用enable配置選項(xiàng),某些配置選項(xiàng)打開(kāi)時(shí)需要依賴其他編譯庫(kù)文件,導(dǎo)致編譯失敗,需要選擇性打開(kāi)開(kāi)關(guān)
關(guān)于Qt5可能遇到的問(wèn)題馅扣,在configure.ac中把以下屏蔽后在重新./configure
編譯:
# make 或者.compile
# make install (安裝可選擇執(zhí)行)
3.RTSP輸出調(diào)試
# ./vlc -vvv demo.mpg --sout "#rtp{mux=ts,sdp=rtsp://:554/1}" --sout-keep --loop
Windows版本的編譯:
安裝交叉編譯工具:
For the 32-bit version, run this:
# apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools
For the 64-bit version, this becomes:
# apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools
安裝編譯工具包:
# apt-get install lua5.2 libtool automake autoconf autopoint make gettext pkg-config
# apt-get install qt4-dev-tools qt5-default git subversion cmake cvs
# apt-get install wine64-development-tools zip p7zip nsis bzip2
# apt-get install yasm ragel ant default-jdk protobuf-compiler dos2unix
Prebuilt (fast)
# $ mkdir -p contrib/win32
# $ cd contrib/win32 $ ../bootstrap --host=x86_64-w64-mingw32
# $ make prebuilt
Linux 64-bit
If you are on Linux 64-bit, you SHOULD remove some files, or install the lib32 packages (ia32-libs, multilibs, etc...)
# $ rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc
Fix your contrib path
If your host triplet is not i686-w64-mingw32 (you are not compiling for Debian or Ubuntu), create a symlink to contribs:
# $ ln -sf insert_your_host_triplet_here ../i686-w64-mingw32
So, for example x86:
# $ ln -sf x86_64-w64-mingw32 ../i686-w64-mingw32
# $ cd -./bootstrap
# export PKG_CONFIG_LIBDIR=/home/yang/share/vlc-2.2.4/contrib/i686-w64-mingw32/lib/pkgconfig
# cd -
# mkdir win32 && cd win32
# $ ../extras/package/win32/configure.sh --host=x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu --enable-run-as-root --enable-live555 --enable-realrtsp --enable-avcodec --enable-avformat --enable-libmpeg2 --enable-dvbpsi --disable-qt --disable-skins2
# $ make package-win32-zip
配置期間可能遇到的問(wèn)題:
1.configure: error: You need 32-bits luac when using using lua from contrib.
# mv /vlc-2.2.4/contrib/i686-w64-mingw32/bin/luac /vlc-2.2.4/contrib/i686-w64-mingw32/bin/luac.bak
# cp /usr/bin/luac5.2 /vlc-2.2.4/contrib/i686-w64-mingw32/bin/luac
2.fatal error: dpapi.h: No such file or directory
# cp /usr/share/mingw-w64/include/* /home/yang/share/vlc-2.2.4/contrib/i686-w64-mingw32/include/ -rf
3.stdole2.idl錯(cuò)誤
# sudo apt-get install wine-dev 或者是sudo apt-get install wine1.4-dev
4.打開(kāi)VLC圖形化工具時(shí)有類(lèi)似libVLC.so.5找不到的問(wèn)題
# sudo /sbin/ldconfig
RTSP輸出調(diào)試
# vlc.exe -vvv D:\demo.mpg --sout "#rtp{mux=ts,sdp=rtsp://:554/1}"
不公開(kāi)部分
基于RFC2326(RTP/AVP斟赚、RTP/AVP/TCP),擴(kuò)展了電信IPTV(MP2T/RTP/UDP岂嗓、MP2T/RTP/TCP汁展、MP2T/UDP、MP2T/TCP)的支持厌殉,由于該部分涉及到行業(yè)知識(shí)食绿,因此不公開(kāi),感謝公罕!