1.使用docker拉取srs镜像。

[root@k8sWorker2 ~]# docker pull registry.cn-hangzhou.aliyuncs.com/ossrs/srs:2

2.运行镜像

  首先确保宿主机的1935,1985,8080端口没有被占用

[root@k8sWorker2 ~]# docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 registry.cn-hangzhou.aliyuncs.com/ossrs/srs:2

3.进入镜像

[root@k8sWorker2 ~]# docker exec -it -u root 83e /bin/bash

4.查看日志

[root@83ee3de7f169 srs]# tail -f ./objs/srs.log 
[2021-01-19 11:32:08.336][trace][1][155] -> HLS time=35465749, stream dts=7139970(79333ms), sno=23, ts=test-22.ts, dur=7.67, dva=0p
[2021-01-19 11:32:09.669][trace][1][132] -> PLA time=35466749, msgs=14, okbps=1,225,105, ikbps=0,0,0, mw=350
[2021-01-19 11:32:13.974][trace][1][155] <- CPB time=80026, okbps=0,0,0, ikbps=230,230,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:32:23.976][trace][1][155] <- CPB time=90030, okbps=0,0,0, ikbps=230,228,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:32:28.338][trace][1][155] -> HLS time=35485754, stream dts=8939970(99333ms), sno=25, ts=test-24.ts, dur=3.67, dva=0p
[2021-01-19 11:32:33.780][trace][1][155] unpublish drop ts segment, sequence_no=24, uri=test-24.ts, duration=2147387.48, start=8610030
[2021-01-19 11:32:33.781][trace][1][155] cleanup when unpublish
[2021-01-19 11:32:33.781][trace][1][155] control message(unpublish) accept, retry stream service.
[2021-01-19 11:32:33.781][warn][1][155][32] client disconnect peer. ret=1004
[2021-01-19 11:32:35.498][trace][1][132] -> PLA time=35492757, msgs=128, okbps=1,226,105, ikbps=0,0,0, mw=350

5.使用ffmpeg推送rtmp视频流

ffmpeg要使用share版本。

D:\Tools\FFMpeg\ffmpeg-shared\ffmpeg-20160116-git-d7c75a5-win64-shared\ffmpeg-20160116-git-d7c75a5-win64-shared\bin>ffmpeg -re -i D:\123.flv -c copy -f flv rtmp://192.168.0.95:1935/live/test

产生以下输出内容:

ffmpeg version N-77883-gd7c75a5 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 13.100 / 55. 13.100
  libavcodec     57. 22.100 / 57. 22.100
  libavformat    57. 21.101 / 57. 21.101
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 25.100 /  6. 25.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, flv, from 'D:\123.flv':
  Metadata:
    metadatacreator : modify by youku.com in 20090909
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : false
    datasize        : 2999014
    videosize       : 2527560
    audiosize       : 456158
    lasttimestamp   : 104
    lastkeyframetimestamp: 102
    lastkeyframelocation: 2923201
  Duration: 00:01:44.27, start: 0.000000, bitrate: 230 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p, 352x264 [SAR 11:12 DAR 11:9], 192 kb/s, 15.17 fps, 15 tbr, 1k tbn, 30 tbc
    Stream #0:1: Audio: aac (HE-AAC), 44100 Hz, stereo, fltp, 33 kb/s
[flv @ 000002307238e2e0] Codec for stream 0 does not use global headers but container format requires global headers
[flv @ 000002307238e2e0] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, flv, to 'rtmp://192.168.0.95:1935/live/test':
  Metadata:
    metadatacreator : modify by youku.com in 20090909
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : false
    datasize        : 2999014
    videosize       : 2527560
    audiosize       : 456158
    lasttimestamp   : 104
    lastkeyframetimestamp: 102
    lastkeyframelocation: 2923201
    encoder         : Lavf57.21.101
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 352x264 [SAR 11:12 DAR 11:9], q=2-31, 192 kb/s, 15.17 fps, 15 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: aac (HE-AAC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, 33 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[flv @ 000002307238e2e0] Failed to update header with correct duration.9.1kbits/s speed=   1x
[flv @ 000002307238e2e0] Failed to update header with correct filesize.
frame= 1565 fps= 15 q=-1.0 Lsize=    2929kB time=00:01:44.81 bitrate= 228.9kbits/s speed=   1x
video:2444kB audio:417kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.399039%

6.在docker镜像容器里可以看到有日志在一直输出,日志如下:

[root@83ee3de7f169 srs]# tailf ./objs/srs.log
[2021-01-19 03:22:39.950][trace][1][139] HTTP API GET http://192.168.0.95:1985/api/v1/streams?callback=angular.callbacks._18q, content-length=-1, chunked=0/0
[2021-01-19 03:22:39.951][trace][1][141] HTTP API GET http://192.168.0.95:1985/api/v1/streams/?callback=angular.callbacks._18q, content-length=-1, chunked=0/0
[2021-01-19 03:22:43.948][trace][1][141] HTTP API GET http://192.168.0.95:1985/api/v1/streams?callback=angular.callbacks._18r, content-length=-1, chunked=0/0
[2021-01-19 03:22:43.951][trace][1][139] HTTP API GET http://192.168.0.95:1985/api/v1/streams/?callback=angular.callbacks._18r, content-length=-1, chunked=0/0
[2021-01-19 03:22:47.951][trace][1][139] HTTP API GET http://192.168.0.95:1985/api/v1/streams?callback=angular.callbacks._18s, content-length=-1, chunked=0/0
[2021-01-19 03:22:47.952][trace][1][141] HTTP API GET http://192.168.0.95:1985/api/v1/streams/?callback=angular.callbacks._18s, content-length=-1, chunked=0/0
[2021-01-19 03:22:51.675][trace][1][141] HTTP API GET http://192.168.0.95:1985/api/v1/streams?callback=angular.callbacks._18t, content-length=-1, chunked=0/0
[2021-01-19 03:22:51.677][trace][1][139] HTTP API GET http://192.168.0.95:1985/api/v1/streams/?callback=angular.callbacks._18t, content-length=-1, chunked=0/0
[2021-01-19 03:23:51.675][warn][1][141][62] client disconnect peer. ret=1004
[2021-01-19 03:23:51.677][warn][1][139][62] client disconnect peer. ret=1004
[2021-01-19 11:22:21.900][trace][1][143] RTMP client ip=192.168.0.165
[2021-01-19 11:22:21.900][trace][1][143] simple handshake success.
[2021-01-19 11:22:21.901][trace][1][143] connect app, tcUrl=rtmp://192.168.0.95:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.0.95, port=1935, app=live, args=null
[2021-01-19 11:22:21.943][trace][1][143] client identified, type=fmle-publish, stream_name=test, duration=-1.00, param=
[2021-01-19 11:22:21.943][trace][1][143] connected stream, tcUrl=rtmp://192.168.0.95:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=test, param=, args=null
[2021-01-19 11:22:21.943][trace][1][143] source url=/live/test, ip=192.168.0.165, cache=1, is_edge=0, source_id=-1[-1]
[2021-01-19 11:22:21.985][trace][1][143] hls: win=60.00, frag=10.00, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=0
[2021-01-19 11:22:21.995][trace][1][143] http: mount flv stream for vhost=/live/test, mount=/live/test.flv
[2021-01-19 11:22:22.006][trace][1][143] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0, rtcid=145
[2021-01-19 11:22:22.043][trace][1][143] got metadata, width=352, height=264, vcodec=7, acodec=10
[2021-01-19 11:22:22.043][trace][1][143] protocol in.buffer=0, in.ack=0, out.ack=2500000, in.chunk=128, out.chunk=60000
[2021-01-19 11:22:22.043][trace][1][143] 50B video sh,  codec(7, profile=Main, level=3.1, 352x272, 0kbps, 0fps, 0s)
[2021-01-19 11:22:22.043][trace][1][143] 9B audio sh, codec(10, profile=LC, 2channels, 0kbps, 22050HZ), flv(16bits, 2channels, 22050HZ)
[2021-01-19 11:22:22.055][trace][1][143] -> HLS time=34878566, stream dts=0(0ms), sno=1, ts=test-0.ts, dur=0.00, dva=0p
[2021-01-19 11:22:22.423][trace][1][132] update source_id=143[143]
[2021-01-19 11:22:22.423][trace][1][132] protocol in.buffer=3000, in.ack=2500000, out.ack=2500000, in.chunk=128, out.chunk=60000
[2021-01-19 11:22:22.784][trace][1][132] -> PLA time=34879567, msgs=13, okbps=0,0,0, ikbps=0,0,0, mw=350
[2021-01-19 11:22:25.653][trace][1][132] stream consumer change pause state 0=>1
[2021-01-19 11:22:32.658][trace][1][132] -> PLA time=34889570, msgs=0, okbps=0,0,0, ikbps=0,0,0, mw=350
[2021-01-19 11:22:41.177][trace][1][143] -> HLS time=34898574, stream dts=1721970(19133ms), sno=2, ts=test-1.ts, dur=4.33, dva=0p
[2021-01-19 11:22:42.666][trace][1][132] -> PLA time=34899575, msgs=0, okbps=0,30,0, ikbps=0,0,0, mw=350
[2021-01-19 11:22:47.006][trace][1][143] <- CPB time=20008, okbps=1,0,0, ikbps=235,0,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:22:48.674][trace][1][132] stream consumer change pause state 1=>0
[2021-01-19 11:22:48.674][warn][1][132][11] resize iovs 256 => 512, max_msgs=128
[2021-01-19 11:22:52.746][trace][1][132] -> PLA time=34909576, msgs=14, okbps=0,30,0, ikbps=0,0,0, mw=350
[2021-01-19 11:22:57.007][trace][1][143] <- CPB time=30010, okbps=0,1,0, ikbps=236,225,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:23:01.179][trace][1][143] -> HLS time=34918578, stream dts=3521970(39133ms), sno=4, ts=test-3.ts, dur=1.80, dva=0p
[2021-01-19 11:23:02.775][trace][1][132] -> PLA time=34919579, msgs=14, okbps=0,30,0, ikbps=0,0,0, mw=350
[2021-01-19 11:23:07.007][trace][1][143] <- CPB time=40012, okbps=0,1,0, ikbps=230,225,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:23:12.808][trace][1][132] -> PLA time=34929581, msgs=14, okbps=0,341,0, ikbps=0,0,0, mw=350
[2021-01-19 11:23:17.008][trace][1][143] <- CPB time=50015, okbps=0,1,0, ikbps=231,225,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:23:21.175][trace][1][143] -> HLS time=34938584, stream dts=5321970(59133ms), sno=5, ts=test-4.ts, dur=11.40, dva=0p
[2021-01-19 11:23:22.835][trace][1][132] -> PLA time=34939584, msgs=14, okbps=0,341,0, ikbps=0,0,0, mw=350
[2021-01-19 11:23:27.008][trace][1][143] <- CPB time=60018, okbps=0,0,0, ikbps=230,232,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:23:32.576][trace][1][132] -> PLA time=34949588, msgs=13, okbps=0,341,0, ikbps=0,0,0, mw=350
[2021-01-19 11:23:37.010][trace][1][143] <- CPB time=70020, okbps=0,0,0, ikbps=229,232,0, mr=0/350, p1stpt=20000, pnt=5000
[2021-01-19 11:23:41.181][trace][1][143] -> HLS time=34958591, stream dts=7121970(79133ms), sno=7, ts=test-6.ts, dur=7.47, dva=0p
[2021-01-19 11:23:42.615][trace][1][132] -> PLA time=34959591, msgs=14, okbps=0,228,0, ikbps=0,0,0, mw=350

7.使用VLC播放器拉取rtmp视频流

点击播放后,就能看到从ffmpeg推送的实时视频流了。

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐