Introducing scrcast: Kotlin-first configure and go screen recording on Android

I'm excited to announce scrcast - an open-source Kotlin-first configure and go screen recording library for Android. scrcast aims to be the screen recording app's or QA team's best friend. scrcast is an abbreviation of the full feature screen capture

Here's how simple a screen recording could be:

val recorder = ScrCast.use(this) // activity required for media projection

But with a little configuration unlocks a world of possibilities:

ScrCast.use(this).apply {
    // Options are configurable via a DSL
    options {
        video {
            maxLengthSecs = 360 // terminate recording after X seconds
        storage {
            directoryName = "scrcast-sample"
        // allow srcast to internally drive your notification
        // with simple idiomatic fields
        notification {
            title = "Super cool library"
            description = "shh session in progress"
            icon = resources.getDrawable(R.drawable.ic_camcorder, null).toBitmap()
            channel {
                id = "1337"
                name = "Recording Service"
            // even control the UX with pause, resume, and stop support
            showStop = true
            showPause = true
            showTimer = true
        moveTaskToBack = false
        stopOnScreenOff = true
        startDelayMs = 5_000

    // scrcast also supports running your own notifications completely
    // by simply provide a NotificationProvider

    // with state change callbacks
    onRecordingStateChange { state -> handleRecorderState(state) }
    // and output file on complete
    onRecordingComplete { file ->
        Snackbar.make(bottom_bar, "Recording located at ${file.absolutePath}", Snackbar.LENGTH_SHORT).show()

scrcast will also handle the storage permission requirement and request for you!


Why a screen recording library?

While this is probably an edge case need for some, the hoops to setup a a MediaProjection, VirtualDisplay and provide it to MediaRecorder for recording purposes isn't the most straight forward task and it's not well known or documented really, so I felt the opportunity was available to simply this for developers. Also, with the number of QA teams that I have worked with consistently asking for why their isn't a streamlined and simple screen recording app matching the native iOS experience (prior to Android 11), it's something that I felt that I could take advantage of as well. Scrcast was created with the concept of a simple API being available for developers to add a screen recording service to their users without having to struggle. This was done by:

  • Leveraging Kotlin language features including extension functions, lambda parameters and sealed classes to create a simple API.
  • Use modern dependencies. Taking full advantage of Android Jetpack was the primary focus, with future support for lifecycle hooks via AndroidX in the works.
  • Lightweight. scrcast is only 1000 lines of code.


So you now are probably asking where would I use this?

  • Add it to any app hidden by developer flags for your QA team to record your app from your app.
    • Quick, no context switching
  • Existing screen recording apps out their looking to offload some of the heavy lifting of the MediaProject → VirtualDisplay → recording process.

Getting started

I'm extremely excited to being sharing scrcast with the community. There is a world of configurations available to fit you and your users needs/wants that I didn't want to flood this post with, so be sure to check out the documentation and the Github repository. You can also find me on Twitter here.