Msdk-4.9 has supported the function of live broadcast, just provide the RTMP address to achieve uav live broadcast.
The client pushes the stream
LiveStreamManager msDK-4.9 provides LiveStreamManager to manage a livestreamstream:
LiveStreamManager.java
DJISDKManager.getInstance().getLiveStreamManager()
Copy the code
LiveStreamManager is very simple to implement in three steps:
- Set the RTMP capture address
- Start pushing flow
- Closing push flow
1. Set the URL address of the RTMP Server.
DJISDKManager.getInstance().getLiveStreamManager().setLiveUrl(liveShowUrl);
Copy the code
2, Starts the live streaming.The encoder will start to encoding the video frame if it is needed streamed to the RTMP server if the server is available
int result = DJISDKManager.getInstance().getLiveStreamManager().startStream();
Copy the code
The result returned is an error code.
3, Stop the live streaming. The operation is asynchronous
DJISDKManager.getInstance().getLiveStreamManager().stopStream();
Copy the code
LiveStreamManager also provides other LiveStreamManager Settings, which can be found in msDK-LivestreamManager Doc
The server captures traffic
In fact, as long as the server supports the RTMP protocol can be directly resolved to play, if you want to see the effect intuitively, you can use the station B direct broadcast:
String liveShowUrl = + RTMP address broadcast code DJISDKManager. GetInstance () getLiveStreamManager () setLiveUrl (liveShowUrl); DJISDKManager.getInstance().getLiveStreamManager().startStream();Copy the code
Wait a short while before you can watch live video from the drone in the studio.
We can also build our own stream capture server based on some third-party open source frameworks.
Red5-Server
Red5 is an open source Flash server written in Java.
- Streaming Video (FLV, F4V, MP4, 3GP)
- Streaming Audio (MP3, F4A, M4A, AAC)
- Recording Client Streams (FLV and AVC+AAC in FLV container)
- Shared Objects
- Live Stream Publishing
- Remoting
- Protocols: RTMP, RTMPT, RTMPS, and RTMPE
download
The latest version is release-1.1.1, download the latest red5-server-1.1.1.zip
The installation
- MacOS installation
- Linux installation
If the above installation is too tedious, here is a simple installation recommended:
- The JDK environment must be installed
- Run in red5-server-1.1.1 folder
./red5.sh start
Command to start the Red5 service
run
- Enter the local red5 service address in your browser: http://localhost:5080/
- Select launch a demo
- Choose the Publisher demo
- Monitor: View /Publish toggle
- Log: Log of the current execution
- Name: live code, which is similar to the live code of station B
- Stop: Stops live streaming
- Play/Pause: Play or Pause live broadcast
- Enable Aundio/Video: currently available
- Servers: Live address
- Close /connect: Closes/connects the live broadcast service
- Location: RTMP push address
2. Click the Connect button on servers to start the service. If the service is successfully started, the button will change to Close
Procedure for setting the client: 1. Splicing the RTMP address of Location and the live broadcast code Name into the live broadcast address RTMP ://Red5 IP address /oflaDemo/codelang 2, setLiveUrl 3, and startStream