VK Live streaming integration in mobile app

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
VK Live streaming integration in mobile app
Medium
~5 business days
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
    445

VK Live Streaming Integration from Mobile Application

VK Live doesn't provide official mobile SDK for third-party apps — first thing to understand. Broadcasting organized via RTMP/RTMPS protocol to endpoint user gets in broadcast settings. Developer's task — capture video from camera, encode to H.264/H.265, send to rtmp://vp.vkforms.ru/live with correct stream key.

Key Technical Challenges

Most common problem — getting RTMP key without user. VK API (video.startStreaming) requires VK Connect authorization with video scope. If token expired or missing scope, method returns error_code: 15 (access denied), broadcast doesn't start. Store token in Keychain/EncryptedSharedPreferences, refresh via refresh flow before expiry, not on error.

Encoding on mobile. On iOS use VideoToolbox via AVAssetWriter + AVAssetWriterInput with parameters:

  • AVVideoCodecKey: AVVideoCodecType.h264
  • AVVideoWidthKey: 1280, AVVideoHeightKey: 720
  • AVVideoCompressionPropertiesKeyAVVideoAverageBitRateKey: 2_500_000
  • AVVideoMaxKeyFrameIntervalKey: 60 (keyframe every 2 seconds at 30fps)

Without explicit AVVideoMaxKeyFrameIntervalKey encoder spaces keyframes too far, VK ingestion server buffers longer, viewers notice stuttering on scene change.

Android — MediaCodec with MediaFormat.MIMETYPE_VIDEO_AVC, MediaFormat.KEY_BITRATE_MODE = BITRATE_MODE_CBR. VBR mode on unstable connection gives spikes which dropped packets on VK ingestion turn into artifacts for 2–3 seconds.

How We Implement

For RTMP delivery on iOS use HaishinKit (Swift, actively maintained). Android — rtmp-rtsp-stream-client-java by pedroSG94 or custom MediaMuxer with RTMP client over java.net.Socket. Production projects prefer native MediaCodec path with custom RTMP without heavy dependencies.

Scheme for iOS with HaishinKit:

let rtmpConnection = RTMPConnection()
let rtmpStream = RTMPStream(connection: rtmpConnection)
rtmpStream.videoSettings = VideoCodecSettings(
    videoSize: CGSize(width: 1280, height: 720),
    bitRate: 2_500_000,
    profileLevel: kVTProfileLevel_H264_High_AutoLevel as String
)
rtmpStream.audioSettings = AudioCodecSettings(bitRate: 128_000)

rtmpConnection.connect("rtmp://vp.vkforms.ru/live")
rtmpStream.publish(streamKey)

Quality monitoring — subscribe to RTMPConnection.Event.rtmpStatus, track NetStream.Publish.BadName (invalid key), NetStream.Failed (connection break). On NetStream.Failed log to Firebase Crashlytics with params: bitrate at break, connection type (Wi-Fi/Cellular), OS version.

Reconnection implement with exponential backoff: 2s → 4s → 8s → 16s → 30s (max). Infinite retry without pause will block account on VK for flood.

Authorization and Stream Key

Via VK SDK (iOS: VKSDK, Android: vk-android-sdk) or direct OAuth2 flow:

  1. Open WebView or SFSafariViewController to https://oauth.vk.com/authorize?client_id=APP_ID&scope=video&response_type=token
  2. Intercept redirect to https://oauth.vk.com/blank.html#access_token=...
  3. Call video.startStreaming with obtained token
  4. From response take rtmp_url and key

Key is session-based — valid for one broadcast. Can't save between sessions.

Timeline

Integration on one platform (iOS or Android): 2–3 weeks accounting OAuth flow, video capture, basic network error handling. Adding adaptive bitrate and auto-reconnection — another week. Cost calculated individually after requirements analysis.