RTMP streaming from mobile device

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
RTMP streaming from mobile device
Complex
from 1 week to 3 months
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    757
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1054
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    874
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    449

RTMP Streaming from Mobile Device

RTMP — a protocol from 2002, invented by Macromedia for Flash. In 2025 it still lives because YouTube Live, Twitch, Facebook Live, Restream, and most media servers accept it. From mobile, RTMP streams launch via specialized libraries — native iOS/Android doesn't do this out of the box.

Why RTMP and Not Something Else

RTMP uses TCP, ensures reliable data delivery, and works through most corporate firewalls (port 1935). Latency — 1–3 seconds, acceptable for streaming to platforms. For ultra-low latency (<500 ms) use WebRTC or SRT, but YouTube and Twitch don't accept them directly — need a re-streamer on server.

iOS: HaishinKit

The best Swift-native option. No FFmpeg dependency, hardware encoding via VideoToolbox.

Minimal setup:

import HaishinKit

let rtmpConnection = RTMPConnection()
let rtmpStream = RTMPStream(connection: rtmpConnection)

rtmpStream.videoSettings = VideoCodecSettings(
    videoSize: CGSize(width: 1280, height: 720),
    bitRate: 2_000_000,
    profileLevel: kVTProfileLevel_H264_High_AutoLevel as String
)
rtmpStream.audioSettings = AudioCodecSettings(bitRate: 128_000)

// Attach camera
let camera = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)
try rtmpStream.attachCamera(camera)
try rtmpStream.attachAudio(AVCaptureDevice.default(for: .audio))

// Preview
let hkView = MTHKView(frame: previewView.bounds)
hkView.videoGravity = .resizeAspectFill
rtmpStream.addOutput(hkView)
previewView.addSubview(hkView)

// Start
rtmpConnection.connect("rtmp://live.example.com/live")
rtmpStream.publish("stream_key")

Reconnection on break: subscribe to RTMPConnection.Event.rtmpStatus, on code == RTMPStatusCode.connectClosedreconnectDelay(3) and retry connect(). HaishinKit has built-in reconnect mechanism.

Monitoring: rtmpStream.info.byteCount and RTMPStream.currentFPS — track actual FPS. If below 20 — signal of poor connection.

Android: rtmp-rtsp-stream-client-java

Library by Pedro Vicente. Supports Camera1, Camera2, CameraX, Screen capture. Hardware encoding via MediaCodec.

val rtmpCamera = RtmpCamera2(binding.surfaceView, object : ConnectCheckerRtmp {
    override fun onConnectionSuccessRtmp() { /* update UI */ }
    override fun onConnectionFailedRtmp(reason: String) {
        rtmpCamera.stopStream()
        retryConnection()
    }
    override fun onDisconnectRtmp() { retryConnection() }
    override fun onAuthErrorRtmp() { /* show error */ }
    override fun onAuthSuccessRtmp() {}
    override fun onNewBitrateRtmp(bitrate: Long) { updateBitrateUI(bitrate) }
})

// Prepare (resolution, bitrate, FPS, audio)
rtmpCamera.prepareVideo(1280, 720, 30, 2_000_000) && rtmpCamera.prepareAudio(128_000, 44100, true)
rtmpCamera.startStream("rtmp://live.example.com/live/stream_key")

RtmpCamera2 accepts SurfaceView or TextureView. For Jetpack Compose: AndroidView { RtmpCamera2(context, ...) }.

Bitrate adaptation: rtmpCamera.setVideoBitrateOnFly(newBitrate) — change bitrate without restarting stream.

RTMP Authentication

Twitch, YouTube, Facebook require stream key in URL: rtmp://live.twitch.tv/app/{stream_key}. Some services use RTMP auth: rtmp://user:pass@server/app/stream.

For YouTube Live additionally need rtmps:// (TLS): HaishinKit supports, rtmp-rtsp-stream-client-java — via RtmpsCamera2.

Common Issues

Startup delay. First seconds stream is unstable — SPS/PPS NAL units not yet cached on server. Solution: on iOS set kVTCompressionPropertyKey_AllowFrameReordering: false — B-frames disabled, latency reduced.

Video without audio for viewers. Audio stream not initialized before broadcast. Ensure prepareAudio() called before startStream().

Black screen at startup. AVCaptureSession not initialized in time — startStream() called before startPreview(). Order matters: attachCamerastartPreviewrtmpConnection.connectrtmpStream.publish.

Crash on background. AVCaptureSession should stop on applicationDidEnterBackground if broadcast shouldn't continue in background. If it should — need UIBackgroundTask and UIBackgroundModes: audio.

Timeline

Integrate RTMP streaming on one platform with preview, connection to specific server, and error handling — 2–3 work days.