Simple-rtmp-server Server Setup

Source: Internet
Author: User

simple-rtmp-server Server Setup 1. Server Image Acquisition
    • GitHub Source Address
git clone https://github.com/winlinvip/simple-rtmp-server.git
    • CSDN Mirror Address
git clone https://code.csdn.net/winlinvip/srs-csdn.git
    • Oschina Mirroring
git clone https://git.oschina.net/winlinvip/srs.oschina.git
2. Turn off firewalls and selinux or open ports
    • Shutting down the firewall
# disable the firewallsudo /etc/init.d/iptables stopsudo /sbin/chkconfig iptables off
    • Make SELinux fail
    • Edit configuration file: sudo vi/etc/sysconfig/selinux
    • Change the SELINUX value to disabled:selinux=disabled
    • Reboot system: sudo init 6
3. Compiling the system
./configure --disable-all --with-ssl --with-hls --with-nginx --with-ffmpeg --with-transcode
&& sudo make install

The install command installs the SRS by default /usr/local/srs and can specify a configure different directory at the time, such as ./configure --prefix= pwd /_release can be installed in the current _release directory (can be installed without sudo, directly with make install)

4. Setting up a startup service

4.1 Establishing a soft connection

sudo ln -sf   /usr/local/srs/etc/init.d/srs  /etc/init.d/srs
    • Note: If the SRS is installed in a different directory, replace the/USR/LOCAL/SRS with a different directory.

    • Note: You can also use other names, such as/etc/init.d/srs, which can be any name, and also use this name when starting up.

4.2 Adding services

#centos 6sudo /sbin/chkconfig --add srs

Or

#ubuntu12sudo update-rc.d srs defaults

4.3 Using the Init.d script to manage SRS

To view the SRS status:

/etc/init.d/srs status

To start the SRS:

/etc/init.d/srs start

To stop the SRS:

/etc/init.d/srs stop

Restart SRS:

/etc/init.d/srs restart

Reload SRS:

/etc/init.d/srs reload
5. Start the Nginx distribution HLs (m3u8/ts)
sudo ./objs/nginx/sbin/nginx
6. Writing the SRS configuration file

Save the following as a file, such as conf/transcode2hls.audio.only.conf, when the server starts by specifying the profile (the Conf folder for the SRS has the file).

# Conf/transcode2hls.audio.only.conflisten 1935;max_connections 1000;http_stream{# Whether HTTP streaming service is enabled.# Default:off enabled on;# the HTTP streaming port # @remark, if use lower port, for instance, user must start S RS by Root. # default:8080 listen 8080; # the default dir for HTTP root. # default:./objs/nginx/html dir./objs/nginx/html; }vhost __defaultvhost__ {hls {enabled on; Hls_path./objs/nginx/html ; Hls_fragment 10; Hls_window 60;  transcode {enabled on; ffmpeg./objs/ffmpeg/bin/ffmpeg; engine ff { Enabled on; VCODEC copy; Acodec Libaacplus; Abitrate 45; Asample_rate 44100; Achannels 2; Aparams {} output Rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[ Stream]_[engine]; } }          /span>       

Note: This configuration uses only transcoding audio, because the video is H.

7. Start the SRS
./objs/srs -c conf/transcode2hls.audio.only.conf

Or start with a service

8. Start the push-Flow encoder

To push a stream with the FFmpeg command:

for((;;)); do ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv -vcodec copy -acodec copy -f flv -y rtmp://192.168.1.170/live/livestream; sleep 1; done

Or use FMLE to push the flow:

FMS URL: rtmp://192.168.1.170/liveStream: livestream

The generated stream addresses are:

    • Rtmp stream Address is (FMLE push stream without HLS address): Rtmp://192.168.1.170/live/livestream
    • After transcoding the rtmp stream address is: RTMP://192.168.1.170/LIVE/LIVESTREAM_FF
    • The HLS stream after transcoding address is: http://192.168.1.170/live/livestream_ff.m3u8

Note : Because FMLE pushed up the audio has a problem, not AAC, so SRS will error (of course, otherwise you do not have to transcode). This error can be ignored, SRS is that the rtmp stream is not a problem, but cannot be sliced into HLS, because the audio encoding is incorrect. No matter, FFmpeg will be transcoded and then re-pushed all the way to the SRS.

Note : How do I cut HLS only for compliant streams? You can use Vhost. The default vhost does not cut HLS, which pushes the transcoded stream to another vhost, the Vhost-cut HLS.

9. Watch the rtmp stream
    • Rtmp stream address is: RTMP://192.168.1.170/LIVE/LIVESTREAM_FF
    • Player: VLC
    • Or:
    • Http://winlinvip.github.io/srs.release/trunk/research/players/srs_player.html?vhost=defaultVhost&autostart =true&server=192.168.1.170&app=live&stream=livestream_ff

    • HLS Stream address is: http://192.168.1.170/live/livestream_ff.m3u8
    • Player VLC
    • Or
    • Http://winlinvip.github.io/srs.release/trunk/research/players/jwplayer6.html?vhost=defaultVhost&hls_ Autostart=true&server=192.168.1.170&app=live&stream=livestream_ff
10. Mobile-side view

10.1 Android

<video width="640" height="360"autoplay controls autobuffer src="http://127.0.0.1/live/livestream.m3u8"type="application/vnd.apple.mpegurl"></video>

10.2 IOS

http://127.0.0.1/live/livestream.m3u8
Latest First Hottest
    • Comments

Simple-rtmp-server Server Setup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.