How to Use RTMP for Live Broadcast, Real-Time Messaging Protocol (RTMP) was initially a proprietary protocol for streaming audio, video and data over the Internet, between a Flash player and a server. RTMP is a TCP-based protocol which maintains persistent connections and allows low-latency communication.
1. What is Milesight RTMP?
Real-Time Messaging Protocol (RTMP) was initially a proprietary protocol for streaming audio, video and data over the Internet, between a Flash player and a server. RTMP is a TCP-based protocol which maintains persistent connections and allows low-latency communication.It can realize the function of live broadcast so that customers can login to the camera wherever there is a network.
2. How to Use RTMP for Live Broadcast?
In this test case, we use YouTube to play the role of the testing platform for live view.
2.1 Preconditions
1) IP Camera that can be networked to YouTube.
You can just prepare a computer that can be networked to YouTube, and then directly connect it to the IP Camera which is in the same network segment.
2) An activated account of YouTube with which you can do live broadcast in this platform.
3) Ensure that your devices are with the correct firmware versions (Camera firmware: V4X.8.0.1 or above, V3X.8.0.1 or above, V51.7.0.77-r1 or above, V61.8.0.2 or above).
4) IP Camera needs to support audio function if you want to play audio in YouTube.
2.2 Configuration procedures
2.2.1 Open YouTube website to get the Server URL and Stream key
Step 1: Open YouTube website.
Step 2: Login the YouTube account.
Step 3: Get access to the YouTube Studio (If it is the first time to use, you should create studio firstly.).
Step 4: Get access to Live broadcast and get the server address.
① Click the “CREATE” red box marked, and choose “Start live”.
② Fill in the red box and click “CREATE LIVE”.
The following useful message with the live URL and Stream key will pop up, you can just click “copy” for the live URL(rtmp://a.rtmp.youtube.com/live2) and the live code(7emj-7vrb-scck-a9fx) to form a whole RTMP server address, which is as below in this example: rtmp://a.rtmp.youtube.com/live2/7emj-7vrb-scck-a9fx
You can also see it here:
Note:
1. If you use a newly created account to live broadcast, you need to wait for 24hrs to activate the account for using live function.
2. For RTMP, since G.711 is not available for YouTube, so you can only play video from Milesight IP camera with H.264 video coding and AAC audio coding on YouTube.
3. If you use Facebook to live broadcast, you need to enable “Use a Persistent Stream Key”.
2.2.2 Make configuration for Milesight IP Camera
Step 1: Set the video code as H.264, and audio encoding as AAC, considering the limitation of RTMP.
Step 2: Access to Network->RTMP, and make configuration.
① Enable RTMP.
② Choose the Stream Type.
③ Fill in the server address confirmed before.
④ rtmp://a.rtmp.youtube.com/live2/7emj-7vrb-scck-a9fx.
⑤ Save the configuration, and you will see the live view in YouTube.
Note:
Server Address in IP Camera RTMP interface needs to be filled with the format: rtmp://< Server URL >/< Stream key >, remember it needs ’/’to connect between < Server URL > and < Stream key >.
2.2.3 Watch the Live Broadcast of Milesight IP camera
2.2.4 How to use a fixed url to see the Live Broadcast on YouTube?
You can always use the url:
“https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID” on browser to see the Live Broadcast. Even if the live streaming is interrupted temporarily, you can still use this url to see the live broadcast after the streaming recover.
.
Note:
1. You can check the CHANNEL_ID in the advanced settings of your Youtube.
2. Please edit the visibility to “Public“, and disable the “Unlist live replay once stream ends”.
2.3 How to use RTMP on Wowza Streaming Cloud?
Wowza is a live video streaming platform with industry-leading technology delivering broadcast-quality live streaming to any sized audience on any device.
Step 1: Log in your Wowza account and Add Live Stream.
Step 2:Set stream name and your location.
Step 3: Choose RTMP as video source, and disable authentication.
Step 4: Finish the settings of Playback, Hosted Page and Review. (You can just keep default settings.)
Step 5:Then the Live Stream is created. You can get server address and stream name(key).
Step 6:Fill in server address on camera’s RTMP settings.
For example, the Primary Server is
“rtmp://45baad.entrypoint.cloud.wowza.com/app-9w7Wm5d3”, Stream Name(key) is
“b78db5cd”, then you should fill in the Server Address like
“rtmp://45baad.entrypoint.cloud.wowza.com/app-9w7Wm5d3/b78db5cd” on camera.
.
Step 7:Modify camera’s codec to H.264.
Step 8:Then you can start the Live Stream on Wowza.
RTMP
Description
RTMP stream cannot be played normally on third-party platforms such as Youtube, Facebook and so on.
Cause
Resolution
1. Camera Settings
1.1 Server Address
Ensure that the server address is correct on the camera side.
For example, the Stream key is “rruf-21z6-c5w7-22mk-19yd”,
the Stream URL is: “rtmp://a.rtmp.youtube.com/live2”,
so the total server address would be: “rtmp://a.rtmp.youtube.com/live2/rruf-21z6-c5w7-22mk-19yd”
Please pay attention to “/”between the Stream key and URL.
1.2 Video Codec
Most platforms only support playing RTMP streams with H.264 video codec.
1.3 TCP/IP Settings
Ensure that the camera can access the Internet.
We recommend using 8.8.8.8 as the Preferred DNS Server.
2. Platform Requirements
2.1 Audio Coding Limitation on Youtube
Since G.711, G.722, G.726 are not available for YouTube, you can only play video of Milesight IP camera with AAC audio coding on YouTube.
Note:
For camera models without Audio interface, we recommend using OBS as RTMP client to convert RTSP stream to RTMP stream for Live Broadcast. Moreover, there are no restrictions on Camera Settings, which means that RTMP function does not need to be enabled on the camera. The video codec can be H.265 or MJPEG. All you need is to ensure that the RTSP stream can be played on VLC.
How to play RTMP stream on platforms over OBS
Step1: Install the OBS Studio, which can be downloaded from:
Download | OBS (obsproject.com)
Step2: Install the VLC, which can be downloaded from (If you cannot find the VLC Video Source on OBS, please try again from Step1.):
Download official VLC media player for Windows – VideoLAN
Step3: Add RTSP stream of IP Camera on OBS.
RTSP URL (Contains Authentication Information):
rtsp://admin:password@camera IP: rtsp port/main
rtsp://admin:password@camera IP:rtsp port/sub
For example, we input the URL: “rtsp://admin:test8403@192.168.4.205:554/main” as follows.
Click OK to add the RTSP stream successfully.
Then you will see the RTSP stream you just entered.
Step4: Add RTMP Server Information on OBS.
Take the Youtube platform as an example:
Step5: Click “Start Streaming” and then the RTMP stream will be pushed to Youtube.
2.2 Resolution Limitation on Youtube
Youtube Studio prompts “Error You need to change the video resolution. The current resolution is (2592×1944), which is not supported for this configuration. The expected video resolution is (1920×1080).” as shown below.
If you encounter such problems, you need to modify the Resolution and Bit Rate of the IP Camera to the recommended parameters.
For more details, please refer to Choose live encoder settings, bitrates and resolutions – YouTube Help (google.com) .
2.3 Authentication Requirement on Wowza
Check the “Other RTMP” Settings and make sure the “Disable authentication” is ticked.
Others
1. RTMP stream is disconnected unexpectedly after live broadcast on Youtube for 4-5 hours.
Cause: Older versions of RTMP re-connection timeout problem.
Resolution: Upgrade IP camera version to 4X.7.0.78 (2021/6) or above
2. Failed to access the previous Youtube live broadcast URL address.
Cause: The Youtube live broadcast URL address is different every time. If the live broadcast is disconnected for a long time, it will cause the address of the live broadcast room on Youtube to change.
Resolution: Fixed URL: https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID
How to use a fixed url to see the Live Broadcast on YouTube
Step1: Resolution: You can check the CHANNEL_ID in the advanced settings of your Youtube.
Step2: Please edit the visibility to “Public“, and disable the “Unlist live replay once stream ends”.
.