小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

手把手帶你實現(xiàn)srs流媒體推流和拉流操作

 新用戶0118F7lQ 2021-03-14

一、前言

大家晚上好,今天給大家來一個簡單的流媒體的推流和拉流的實際操作,廢話不多說,趕緊上車!

二、srs流媒體服務器

1、什么是srs流媒體服務器:

srs(Simple Realtime Server),簡單實時服務器,它支持是一個流媒體集成,支持RTMP / HLS / FLV,高效,穩(wěn)定,易用,簡單而快樂。SRS 是RTMP / HLS / FLV流式群集,高效,穩(wěn)定,簡單。它是一個國內(nèi)大佬寫的一個非常優(yōu)秀的一個流媒體服務器,它的開源地址在github和gitee上都有:

  • github地址:
https://github.com/ossrs/srs
  • gitee地址:
https:///winlinvip/srs.oschina

從這個github上大概我了解到,現(xiàn)在srs暫時支持3.0版本,4.0版本應該快發(fā)布了,在3.0版本的wiki教程中有一部分視頻教程在b站上,感興趣的小伙伴可以看看:

圖片

  • 3.0版本中文wiki教程:
https://github.com/ossrs/srs/wiki/v3_CN_Home

2安裝srs流媒體服務器:

  • 我們直接下載3.0版本:
git clone https:///winlinvip/srs.oschina.git cd srs.oschina
  • 下載來后:
root@ubuntu:/home/txp/share/srs# cd srs.oschina/
root@ubuntu:/home/txp/share/srs/srs.oschina# ls
AUTHORS.txt  LICENSE  README.md  trunk
  • 查看當前版本是否是3.0版本:
root@ubuntu:/home/txp/share/srs/srs.oschina# git branch -a
* develop
  remotes/origin/2.0release
  remotes/origin/3.0release
  remotes/origin/4.0release
  remotes/origin/HEAD -> origin/develop
  remotes/origin/develop
  remotes/origin/feature/h265
  remotes/origin/master
  remotes/origin/min
  • 切換到3.0版本:
root@ubuntu:/home/txp/share/srs/srs.oschina# git checkout -b 3.0 remotes/origin/3.0release
Branch 3.0 set up to track remote branch 3.0release from origin.
Switched to a new branch '3.0'
root@ubuntu:/home/txp/share/srs/srs.oschina# git branch -a
* 3.0
  develop
  remotes/origin/2.0release
  remotes/origin/3.0release
  remotes/origin/4.0release
  remotes/origin/HEAD -> origin/develop
  remotes/origin/develop
  remotes/origin/feature/h265
  remotes/origin/master
  remotes/origin/min
  • 開始編譯安裝:
root@ubuntu:/home/txp/share/srs/srs.oschina# cd trunk/

root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# ./configure 

root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# make

  • 配置啟動文件:
root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# ls
3rdparty  auto  conf  configure  doc  etc  ide  Makefile  modules  objs  research  scripts  src  usr
root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# vim conf/rtmp.conf 

#現(xiàn)在后期的版本不用配置,默認就是已經(jīng)配置好的
# the config for srs to delivery RTMP
# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleRTMP
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
vhost __defaultVhost__ {
}

  • 啟動srs:
root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# ./objs/srs -c conf/rtmp.conf 
[2021-03-13 23:14:46.387][Trace][1974][0] XCORE-SRS/3.0.156(OuXuli)
[2021-03-13 23:14:46.387][Trace][1974][0] config parse complete
[2021-03-13 23:14:46.387][Trace][1974][0] you can check log by: tail -f ./objs/srs.log (@see https://github.com/ossrs/srs/wiki/v1_CN_SrsLog)
[2021-03-13 23:14:46.387][Trace][1974][0] please check SRS by: ./etc/init.d/srs status

我們可以查看日志來看啟動過程中詳細的信息:

root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# tail -f ./objs/srs.log
[2021-03-13 23:14:46.389][Trace][1976][0] son(daemon) process running.
[2021-03-13 23:14:46.390][Trace][1974][0] grandpa process exit.
[2021-03-13 23:14:46.390][Trace][1976][0] st_init success, use epoll
[2021-03-13 23:14:46.390][Trace][1976][764] server main cid=764, pid=1976, ppid=1568, asprocess=0
[2021-03-13 23:14:46.390][Error][1976][764][11] srs is already running!(Resource temporarily unavailable)
[2021-03-13 23:14:46.390][Error][1976][764][11] Failed, code=1035 : run : daemon run master : acquire pid file : srs is already running
thread [1976][764]: do_main() [src/main/srs_main_server.cpp:186][errno=11]
thread [1976][764]: run() [src/main/srs_main_server.cpp:448][errno=11]
thread [1976][764]: run_master() [src/main/srs_main_server.cpp:467][errno=11]
thread [1976][764]: acquire_pid_file() [src/app/srs_app_server.cpp:824][errno=11](Resource temporarily unavailable)

注意上面的提示說我的服務器已經(jīng)在運行了,不能再運行了,我們把它給關閉了來:

root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# sudo lsof -i:1935
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
srs     1601 root    8u  IPv4  20067      0t0  TCP *:1935 (LISTEN)

通過查看srs的端口被一個進程給占用了,所以我們現(xiàn)在把這個進程給殺死掉來:

root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# sudo kill -9 1601

  • 重新啟動srs:
root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# ./objs/srs -c conf/rtmp.conf 
[2021-03-13 23:25:49.235][Trace][2037][0] XCORE-SRS/3.0.156(OuXuli)
[2021-03-13 23:25:49.235][Trace][2037][0] config parse complete
[2021-03-13 23:25:49.235][Trace][2037][0] you can check log by: tail -f ./objs/srs.log (@see https://github.com/ossrs/srs/wiki/v1_CN_SrsLog)
[2021-03-13 23:25:49.235][Trace][2037][0] please check SRS by: ./etc/init.d/srs status
root@ubuntu:/home/txp/share/srs/srs.oschina/trunk# tail -f ./objs/srs.log
[2021-03-13 23:25:49.238][Trace][2037][0] start daemon mode...
[2021-03-13 23:25:49.239][Trace][2038][0] father process exit
[2021-03-13 23:25:49.239][Trace][2039][0] son(daemon) process running.
[2021-03-13 23:25:49.239][Trace][2039][0] st_init success, use epoll
[2021-03-13 23:25:49.239][Trace][2039][236] server main cid=236, pid=2039, ppid=1568, asprocess=0
[2021-03-13 23:25:49.240][Trace][2039][236] write pid=2039 to ./objs/srs.pid success!
[2021-03-13 23:25:49.240][Trace][2037][0] grandpa process exit.
[2021-03-13 23:25:49.240][Trace][2039][236] RTMP listen at tcp://0.0.0.0:1935, fd=8
[2021-03-13 23:25:49.240][Trace][2039][236] signal installed, reload=1, reopen=10, fast_quit=15, grace_quit=3
[2021-03-13 23:25:49.241][Trace][2039][236] http: api mount /console to ./objs/nginx/html/console

三、實戰(zhàn)演示推流和拉流操作:

1、使用ffmpeg進行推流和ffplay進行拉流:

所謂的推流,簡單理解就是把流媒體文件上傳到流媒體服務器上去;所以拉流,也可以簡單理解就是從流媒體服務器上獲取流媒體文件。下面我演示把一個流媒體文件格式為flv的視頻流上傳到srs上去:

圖片

圖片

E:\ffmpeg\bin>ffmpeg -re -i test.flv -vcodec copy -acodec copy -f flv -y rtmp://192.168.0.104/live/livestream

上傳上去后,我們可以使用ffplay來進行拉流:

E:\ffmpeg\bin>ffplay rtmp://192.168.0.104/live/livestream

圖片

注意:這里拉流的時候,你的虛擬機最好搞成橋接模式,和本地的物理機windows在同一個網(wǎng)段;而且上面192.168.0.104代表的是我安裝srs流媒體服務器的那臺ubunut機器的ip地址。

圖片

2、使用vlc來進行拉流:

vlc下載地址:

<!--StartFragment--><https://get./vlc/3.0.12/win64/vlc-3.0.12-win64.exe><!--EndFragment-->

圖片

圖片

圖片

3、使用OBS進行推流

OBS下載地址:

https://pc.qq.com/detail/4/detail_23604.html

圖片

下面是OBS推流演示(兩種方式,另外一種是使用電腦攝像頭來獲取):

  • 本地文件推流:

圖片

圖片

圖片

圖片

圖片

圖片

  • 攝像頭捕獲推流

圖片

圖片

圖片

圖片

圖片

四、總結

好了,本次的分享就到這里結束了,下面我將開始更多音視頻方面的學習總結更新,敬請期待!

參考: 

https:///winlinvip/srs.oschina

https://ke.qq.com/webcourse/index.html#cid=468797&term_id=100561187&taid=4217056589719357&vid=5285890796286162335

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多