天天看點

使用樹莓派專用攝像頭實作rtsp流的方法

1.raspivid擷取+vlc實作rtsp伺服器      測試效果: 差     實作難度:低

2.rapivid擷取+gstream轉發+gst-rtsp實作rtsp服務   測試效果: 差,會出現圖像模糊     實作難度:中   gstreamer安裝與gst-rtsp安裝可能出現庫缺失問題

3.調用v4l2接口捕獲視訊+live555實作rtsp服務 測試效果:好,延遲與畫面都尚可     實作難度: 可能遇到各種包缺失,且難以檢查出錯位置

針對3詳細介紹:

樹莓派端:

step1. 安裝live555

  • 擷取live555最新源碼  
  • wget http://live555.com/liveMedia/public/live555-latest.tar.gz  
  • 解壓編譯安裝  
  • tar -zxvf live555-latest.tar.gz  
  • cd live  
  • sudo ./genMakefiles linux  
  • sudo make  
  • sudo make install  
step2. 安裝庫檔案
  • sudo apt-get update  
  • sudo apt-get install libavcodec54   
  • sudo apt-get install libswscale2  
  • sudo apt-get install libx264-142  

step3. 編譯執行工具

下載下傳源碼 copy到/opt/vc/src/hello_pi/

根據/hello_pi/下的README編譯安裝iclient庫

  • cd live_camera_linux  
  • sudo make  
  • sudo make install  
  • sudo ./zk_v4l2_x264_source  
若出現
  • [2464] WebcamOndemandMediaSubsession .... calling  
  • using url "rtsp://192.168.1.102:9554/webcam"  

則成功實作

播放端:

使用vlc等工具播放rtsp流: rtsp://IP_of_Raspi:9554/webcam

注:我在step3 的時候出現了錯誤

zk_v4l2_x264_source.cpp:17:24: fatal error: liveMedia.hh: 沒有那個檔案或目錄

#include <liveMedia.hh>

                        ^

compilation terminated.

<builtin>: recipe for target 'zk_v4l2_x264_source.o' failed

make: *** [zk_v4l2_x264_source.o] Error 1

我打開makefile檔案發現第一行是:LIVE555= /home/pi/live我的live在Downloads檔案夾下,所有找不到檔案,然後與把live複制到pi下,此錯誤消失,但是又出現下面的錯誤:

/usr/bin/ld: cannot find -lilclient

collect2: error: ld returned 1 exit status

Makefile:29: recipe for target 'zk_v4l2_x264_source' failed

make: *** [zk_v4l2_x264_source] Error 1

這個錯誤的意思是:lilclient 這個動态連結庫沒有找到解決方法:

$ cd /opt/vc/src/hello_pi

$ make -C libs/ilclient

然後就可以把

live_camera_linux 編譯通過了!

使用樹莓派專用攝像頭實作rtsp流的方法