ffmpeg+ffserver實現網路攝影機直播

來源:互聯網
上載者:User

標籤:參數   mon   nbsp   綁定   glob   修改環境變數   res   tsp   日誌   

1. 首先, 下載ffmpeg的源碼, 編譯

先./configure --disable yasm --prefix=/usr/local/ffmpeg

然後make 跟make install

 

2. 修改環境變數

修改/etc/profile檔案, 在最後加入

export PATH="/usr/local/ffmpeg/bin:$PATH"

3. 做一個conf檔案, 啟動ffserver

Port 8090                       #綁定連接埠號碼BindAddress 0.0.0.0             #綁定ipMaxHTTPConnections 2000         #最大HTTP串連數MaxClients 1000                 #最大用戶端串連數MaxBandwidth 1000               #最大頻寬CustomLog -                     #記錄檔,“-”為直接列印NoDaemon                        #預設全域參數<Feed feed1.ffm>                #Feed:每一個輸入(網路攝影機)建立一個Feed    File /tmp/feed1.ffm             #Feed快取檔案    FileMaxSize 20M                #快取檔案最大值    ACL allow 127.0.0.1             #允許寫入Feed的ip</Feed><Stream test.flv>               #Stream:每一個廣播(轉換後的視頻流)的轉碼設定項目    Format flv                      #視頻流格式    Feed feed1.ffm                  #視頻流的種子來源    VideoFrameRate 40               #視訊框架頻    VideoBitRate 128                #視頻位元速率    VideoSize 160x80                #視訊框架大小    AVOptionVideo flags +global_header    NoAudio</Stream>

 

注意, 這裡是NoAudio, 就是沒有音訊, 因為是網路攝影機, 沒有帶音頻.

 

4. 插入網路攝影機, 並把它連到虛擬機器裡面, 用dmesg命令可以看到:

......

Linux video capture interface: v2.00
uvcvideo: Found UVC 1.00 device USB2.0 Camera (1e4e:0110)
input: USB2.0 Camera as /devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/input/input5
usbcore: registered new interface driver uvcvideo
USB Video Class driver (v1.0.0)

 

5. 使用ffmpeg命令, 給ffserver喂一個流:

 ffmpeg  -f v4l2 -i /dev/video0 http://127.0.0.1:8090/feed1.ffm

 

6. 最後用vlc或者media player就可以播放http://虛擬機器ip:8090/test.flv了.

 

對了, 記得關iptables.

現在的問題是延時非常大.

考慮下一步用rtsp協議.

ffmpeg+ffserver實現網路攝影機直播

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.