iOS RTMP live streaming
2418 8 2020-4-27
Uploading and Loding Picture ...(0/1)
o(^-^)o
baymax.gr
lvl.2
Flight distance : 9793 ft
Singapore
Offline

I am software developer engineer who uses DJISDK and its derivatives to develop iOS app with DJI drone integration.

I would like to ask if any detailed example code is available for video streaming via RTMP to any specific URL written in Swift?
2020-4-27
Use props
想养一条边牧
lvl.3
Flight distance : 1155 ft
Hong Kong
Offline

As I know there is not a swift sample but an object-c Livestream sample.
github.com/dji-sdk/Mobile-SDK-iOS/tree/master/Sample%20Code/ObjcSampleCode/DJISdkDemo/Demo/Liveview
2020-4-27
Use props
baymax.gr
lvl.2
Flight distance : 9793 ft
Singapore
Offline

Hi, thanks for info.
I tried the Objective-C sample code already.

I found that my RTMP always report DJIRtmpMuxerState_Stoped status only every time I run the app.
I wonder if anything I did wrongly:

private func setupVideoPreviewer() {
    DJIVideoPreviewer.instance().enableHardwareDecode = true
    DJIVideoPreviewer.instance().type = .autoAdapt
    DJIVideoPreviewer.instance().start()
    DJIVideoPreviewer.instance().reset()
}

private func setupVideoPreviewerAdapter() {
    guard let videoFeeder = DJISDKManager.product()?.videoFeeder else {
      print("WARN: No video feed is available for video streaming") // I found that this message is not printed
      return
    }
    let adapter = VideoPreviewerAdapter(
      videoPreviewer: DJIVideoPreviewer.instance(),
      with: videoFeeder.primaryVideoFeed
    )
    adapter.start()
    adapter.setupFrameControlHandler()
    self.previewAdapter = adapter
}

private func setupRtmp() {
    guard DJIRtmpMuxer.sharedInstance() != nil else {
      print("WARN: RTMP is not ready yet") // I found that this message is not printed
      return
    }
    DJIRtmpMuxer.sharedInstance()!.delegate = self
    DJIRtmpMuxer.sharedInstance()!.enabled = true
    DJIRtmpMuxer.sharedInstance()!.enableAudio = true
    DJIRtmpMuxer.sharedInstance()!.muteAudio = false
    DJIRtmpMuxer.sharedInstance()!.setupVideoPreviewer(DJIVideoPreviewer.instance())
    DJIRtmpMuxer.sharedInstance()!.serverURL = videoStreamingURL
    DJIRtmpMuxer.sharedInstance()!.streamProcessorEnabled()
    DJIRtmpMuxer.sharedInstance()!.videoProcessorEnabled()
    DJIRtmpMuxer.sharedInstance()!.start()
}

func startVideoStreaming() {
    self.setupVideoPreviewer()
    self.setupVideoPreviewerAdapter()
    self.setupRtmp()
}
2020-4-27
Use props
想养一条边牧
lvl.3
Flight distance : 1155 ft
Hong Kong
Offline

Hi,
guard let videoFeeder = DJISDKManager.product()?.videoFeeder else {
      print("WARN: No video feed is available for video streaming") // I found that this message is not printed
      return
    }
I think you need to check first you have connected the drone success and ensure to get this videoFeeder.
2020-4-28
Use props
想养一条边牧
lvl.3
Flight distance : 1155 ft
Hong Kong
Offline

And bind a view to display the camera view, then try again to start the live stream.
2020-4-28
Use props
baymax.gr
lvl.2
Flight distance : 9793 ft
Singapore
Offline

Thanks for advices.
I checked the drone connection before I run the functions but it doesn't work.
I wonder how should I verify the videoFeed? Shouldn't it be:

guard let videoFeeder = DJISDKManager.product()?.videoFeeder else {
      // I thought this message should be printed if no video feed is found but this message is not printed
      // Does it meat the videoFeeder exists?
      print("WARN: No video feed is available for video streaming")
      return
    }
2020-4-28
Use props
想养一条边牧
lvl.3
Flight distance : 1155 ft
Hong Kong
Offline

Hi,
Use
DJISDKManager.videoFeeder()?  but not DJISDKManager.product()?.videoFeeder

Refer to this code sample:
github.com/DJI-Mobile-SDK-Tutorials/iOS-FPVDemo-Swift/blob/master/FPVDemo/FPVViewController.swift
2020-4-29
Use props
djiuser_vgGdOtlP90d0
New
Flight distance : 62986 ft

China
Offline

I encountered the same problem as you. I found that self.rtmpMuxer? .Start () always returns false, resulting in the DJIRtmpMuxerState_Stoped state. After debugging, the reason was found because the _enableAudio in the satart method was false. The solution is to add the settings below the podfile in the official code:
# Please remove the code below if you don't want to implement the SDK Live Stream feature.
post_install do |installer_representation|
        installer_representation.pods_project.targets.each do |target|
                if target.name == 'DJIWidget'
                        target.build_configurations.each do |config|
                                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'ENABLED_LIVESTREAM_AUDIO_INPUT=1']
                        end
                end
        end
end


2020-5-19
Use props
djiuser_tVumibDb5q0K
lvl.2

United States
Offline

if anyone has a full working swift example or advice on how to setup the obj c example to work in swift - please let me know!
2020-11-4
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules