Getting video stream from DJI
已完成HEre is code:
var sr = MediaDataCenter.getInstance().getLiveStreamManager()
Log.d("Monsoon: RTMP Video stream", "stream status: " + sr.isStreaming.toString());
if(sr.isStreaming) {
//Log.d("Monsoon: RTMP Video stream", "stream status: " + sr.isStreaming.toString());
return;
}
var vs = VideoStreamManager.getInstance().availableStreamSources
Log.d("Monsoon: RTMP Video stream", "stream source: " + vs.toString()+ " " )
if (vs == null ) {
Log.e("Monsoon: RTMP Video stream", "No stream sources");
return;
}
if(vs!!.size == 0) {
Log.e("Monsoon: RTMP Video stream", "No stream sources");
return;
}
var vc = VideoStreamManager.getInstance().availableVideoChannels
Log.d("Monsoon: RTMP Video stream", "video channel: " +vc.toString()+ " " )
if (vc == null ) {
Log.e("Monsoon: RTMP Video stream", "No stream channels");
return;
}
if(vc!!.size == 0) {
Log.e("Monsoon: RTMP Video stream", "No stream channels");
return;
}
var vch = VideoStreamManager.getInstance().getAvailableVideoChannel(VideoChannelType.PRIMARY_STREAM_CHANNEL)
var ssrc = vs[0]
var channelCallback = object: CommonCallbacks.CompletionCallback {
override fun onSuccess() {
Log.i("Monsoon: RTMP Video stream", String.format(Locale.US, "Stream %s successfully opened", ssrc.toString()));
}
override fun onFailure(error: IDJIError) {
Log.e("Monsoon: RTMP Video stream", String.format(Locale.US, "Stream %s could not be opened, error %s", ssrc.toString(), error.toString()));
}
}
/*
if (vch != null) {
vch.startChannel(ssrc!!,channelCallback)
} else {
return
}
*/
var rtmpb : RtmpSettings.Builder = RtmpSettings.Builder()
rtmpb.setUrl("rtmp://monsoon.open-sky.org/LiveApp/MSDK123")
var rtmps = rtmpb.build()
var lsbuilder : LiveStreamSettings.Builder = LiveStreamSettings.Builder()
lsbuilder.setRtmpSettings(rtmps)
lsbuilder.setLiveStreamType(LiveStreamType.RTMP)
var lss = lsbuilder.build()
sr.liveStreamSettings = lss
sr.videoChannelType = VideoChannelType.PRIMARY_STREAM_CHANNEL
sr.liveStreamQuality = StreamQuality.SD
sr.liveVideoBitrateMode = LiveVideoBitrateMode.AUTO
val retrievedRtmpSettings: LiveStreamType = lss.getLiveStreamType()
val callback: CommonCallbacks.CompletionCallback = object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
Log.d("Monsoon: RTMP Video stream", "Live stream started successfully. Stream Settings: $retrievedRtmpSettings " + vs.toString())
}
override fun onFailure(error: IDJIError) {
Log.d("Monsoon: RTMP Video stream", "Failed to start live stream: " + error.description())
}
}
sr.startStream(callback);
//
val ss = sr.isStreaming
Log.i("Monsoon: RTMP Video stream manager", ss.toString())
}
We get:
2024-04-03 14:26:17.094 10702-10702 Monsoon: R...deo stream org.opensky.monsoon.flightopsrdi D stream status: false
2024-04-03 14:26:17.095 10702-10702 Monsoon: R...deo stream org.opensky.monsoon.flightopsrdi D stream source: [StreamSource{physicalDeviceCategory = CAMERA, physicalDeviceType = FPV, physicalDevicePosition = NOSE, streamId = 2556672}, StreamSource{physicalDeviceCategory = CAMERA, physicalDeviceType = M30T, physicalDevicePosition = PORTSIDE, streamId = 3473408}]
2024-04-03 14:26:17.095 10702-10702 Monsoon: R...deo stream org.opensky.monsoon.flightopsrdi D video channel: [PRIMARY_STREAM_CHANNEL, SECONDARY_STREAM_CHANNEL, EXTENDED_STREAM_CHANNEL]
2024-04-03 14:26:17.300 10702-10702 LOG_JNI org.opensky.monsoon.flightopsrdi I [MRTC-I addChannel: 120]: [kztv]AgentBase: [uav:name= uuid=][channel:name= id=][video:enabled=1 sensor_name= uuid=][stream_id=14 codec_type=0 codec_name=H264][url=rtmp://monsoon.open-sky.org/LiveApp/MSDK123]add_channel
2024-04-03 14:26:17.305 10702-10702 Monsoon: R...deo stream org.opensky.monsoon.flightopsrdi D Live stream started successfully. Stream Settings: RTMP [StreamSource{physicalDeviceCategory = CAMERA, physicalDeviceType = FPV, physicalDevicePosition = NOSE, streamId = 2556672}, StreamSource{physicalDeviceCategory = CAMERA, physicalDeviceType = M30T, physicalDevicePosition = PORTSIDE, streamId = 3473408}]
2024-04-03 14:26:17.305 10702-10702 Monsoon: R...am manager org.opensky.monsoon.flightopsrdi I true
2024-04-03 14:26:17.398 10702-10702 Monsoon: R...deo stream org.opensky.monsoon.flightopsrdi D stream status: true
Problem: Stream not visible.
If i play a video with ffmpeg on my linux machine and broadcast to same target, it works without issue. So my rtmp server is fine.
I also can't see any issue in the code, as it is reporting all good.
Question: I need the code corrected, please.
is the sample app working? Yes, but I dont care about the sampel app. I want to know what is wrong with this code. DJI's customer care is abysmal, but Please, I request the engineers to READ my question.
Is the stream server ok? READ ABOVE
-
If the sample code can stream normally, it means the SDK can work properly at least. There doesn't seem to be any issue with your code, but successful live streaming requires some other prerequisites. I would like to confirm the status of the primary video channel when you start the live stream. Does the current page for live streaming display the video channel feed that needs to be pushed out? -
> Does the current page for live streaming display the video channel feed that needs to be pushed out?
I do not understand what page you are referring to.
> I would like to confirm the status of the primary video channel when you start the live stream.
using this code:
Log.i("Monsoon: RTMP Video stream : primary channel", vch.toString());
if (vch != null) {
vch.startChannel(ssrc!!,channelCallback)
} else {
return
}
Log.i("Monsoon: RTMP Video stream : primary channel", vch.toString());
Log.i("Monsoon: RTMP Video stream : primary channel", vch.streamSource.toString());we get:
2024-04-07 18:50:23.516 16660-16660 Monsoon: R...ry channel org.opensky.monsoon.flightopsrdi I PRIMARY_STREAM_CHANNEL
2024-04-07 18:50:23.519 16660-16660 Monsoon: R...ry channel org.opensky.monsoon.flightopsrdi I PRIMARY_STREAM_CHANNEL
2024-04-07 18:50:23.519 16660-16660 Monsoon: R...ry channel org.opensky.monsoon.flightopsrdi I StreamSource{physicalDeviceCategory = CAMERA, physicalDeviceType = M30T, physicalDevicePosition = PORTSIDE, streamId = 3473408}This is just before the startstream call.
Please keep in mind: I do not not need to see the video stream on my app. There is NO PROVISION for that. I want the stream to be fully transmitted to the RTMP Server without showing up on the app.
-
Could you please inform us of the Mobile SDK version you are using? Prior to version 5.8, the live streaming feature of the Mobile SDK required displaying the camera feed being pushed on the app. If you are not using version 5.8, I recommend updating to version 5.8 before attempting again. Are you referring to the format of the live video stream? The format of the live video stream cannot be adjusted to H265 and defaults to using H264.
请先登录再写评论。
评论
3 条评论