SkillAgentSearch skills...

StreamUI.swift

🎥 〜StreamUI: Make videos with SwiftUI (and even stream them to Youtube, Twitch, etc)

Install / Use

/learn @StreamUI/StreamUI.swift
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

〜StreamUI [BETA!]

Team Chat MIT License

<!--[![Swift 5.10+](https://design.vapor.codes/images/swift510up.svg)](https://swift.org)--> <!--[![Discord](https://img.shields.io/discord/1071029581009657896?style=flat&logo=discord&logoColor=fff&color=404eed)](https://discord.gg/NpHj7brca4)--> <!--[![CI](https://github.com/pointfreeco/swift-clocks/workflows/CI/badge.svg)](https://github.com/pointfreeco/swift-clocks/actions?query=workflow%3ACI)--> <!--[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-clocks%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/pointfreeco/swift-clocks)--> <!--[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-clocks%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/pointfreeco/swift-clocks)--> <!--![ChatGPT](https://img.shields.io/badge/chatGPT-74aa9c?style=for-the-badge&logo=openai&logoColor=white)--> <!--![X](https://img.shields.io/badge/X-%23000000.svg?style=for-the-badge&logo=X&logoColor=white)-->

🎥 Make videos programmatically with SwiftUI (and even stream them live to Youtube, Twitch, or more). I am still actively developing this and testing it so please give feedback!

What is StreamUI?

StreamUI is a library designed for SwiftUI that enables developers to create dynamic videos programmatically. It goes beyond traditional video generation tools like Remotion, offering real-time video rendering and live streaming capabilities. Ideal for applications ranging from faceless Tiktok/Youtube shorts videos to live event broadcasting, and much more. StreamUI lets you create video templates in SwiftUI and render them with dynamic inputs.

If you are familular, StreamUI is a SwiftUI alternative to the following, that supports things they do not like live streaming:

This video is 100% SwiftUI code generated with StreamUI 👇

Video created with StreamUI. See example code here

https://github.com/StreamUI/StreamUI/assets/775808/99176027-a4f2-459f-a180-cc02a00f9ee9

  • Real-Time Video Rendering <br> Generate and manipulate video content on the fly using Swift code. Integrate animations, text overlays, and media, adapting dynamically to user interactions or external data.

  • Live Streaming <br> Broadcast live video streams directly from your application. You can create videos with SwiftUI that stream in realtime. So you could be receiving events from outside which then gets reflected into the live stream in real time. Magic!

  • Dynamic video generation <br> Generate dynamic videos. Pull in data from your database, react to outside events, generate batches of videos in different sizes, AB test videos in bulk. You can do it all.

| | Why StreamUI & why create videos with SwiftUI? | |-------|------------------------------------------------| | 📡 | The only programatically generated video library that supports Live streaming capabilities to platforms like YouTube and Twitch | | 🔄 | Videos are rendered in Real-time instead of requiring you to render on serverless functions in a parellel manner | | 💻 | Leverage Swift's power and SwiftUI's declarative syntax | | 🎨 | Create reusable video templates with SwiftUI | | 🔧 | Highly customizable and extensible. Use variables, functions, API calls, remote events, access your database, pull in remote images/audio/video and incorporate any of those into dynamically generated videos | | 📊 | Generate batches of videos with different params, sizes or more variables for A/B testing |

Requirements

If people want support for < less please open a ticket. I wanted to use @Observable which meant I needed to be on Sonoma. But I could very well fall back to @ObservableObject if there is demand.

  • Xcode 15+
  • Swift 5.10
  • MacOS Sonoma

Get started

  • Download the starter:

    • git clone https://github.com/StreamUI/streamui-starter
  • Or start from scratch, and create a Package.swift file

    
    // swift-tools-version:5.10
    
    import PackageDescription
    
    let package = Package(
        name: "MyNewExecutable",
        platforms: [
            .macOS(.v14),
        ],
        dependencies: [
            .package(url: "https://github.com/StreamUI/StreamUI.git", from: "0.1.2"),
        ],
        targets: [
            .executableTarget(
                name: "MyNewExecutable",
                dependencies: [
                    .product(name: "StreamUI", package: "StreamUI"),
                ]
            ),
        ]
    )
    
  • Make sure target is MacOS

  • Simple Example

import StreamUI
import SwiftUI

public struct SwiftUIVideoExample: View {
    @Environment(\.recorder) private var recorder

    @State private var currentImageIndex = 0

    let imageUrls = [
        "https://sample-videos.com/img/Sample-jpg-image-5mb.jpg",
        "https://mogged-pullzone.b-cdn.net/people/8336bde2-3d36-41c3-a8ad-9c9d5413eff6.jpg?class=mobile",
        "https://mogged-pullzone.b-cdn.net/people/0880cf5d-10d1-49b2-b468-e84d19f5bdca.jpg",
        "https://mogged-pullzone.b-cdn.net/people/08c08ae7-732e-4966-917f-f94174daa024.jpg",
        "https://mogged-pullzone.b-cdn.net/people/0a4f6fc6-bc77-4b4a-9dfb-c690b5931625.jpg"
    ]

    public init() {}
    public var body: some View {
        VStack {
            StreamingImage(url: URL(string: imageUrls[currentImageIndex])!, scaleType: .fill)
                .frame(width: 1080, height: 1920)
                .id(currentImageIndex)
        }
        .onAppear(perform: startTimer)
    }

    private func startTimer() {
        Task {
            while true {
                try await recorder?.controlledClock.clock.sleep(for: .milliseconds(1000))
                currentImageIndex = (currentImageIndex + 1) % imageUrls.count
            }
        }
    }
}


let recorder = createStreamUIRecorder(
    fps: 30,
    width: 1080,
    height: 1920,
    displayScale: 2.0,
    captureDuration: .seconds(30),
    saveVideoFile: true,
     livestreamSettings: [
        .init(rtmpConnection: "rtmp://localhost/live", streamKey: "streamKey")
    ]
) {
	SwiftUIVideoExample()
}

recorder.startRecording()

try await Task.sleep(for: .seconds(5))
recorder.pauseRecording()
try await Task.sleep(for: .seconds(10))
recorder.resumeRecording()

// Wait for the recording to complete
await recorder.waitForRecordingCompletion()
  • swift run or build xcode

  • Video will automatically stop recording after the specified time and if specified will start live streaming!

Docs

createStreamUIRecorder

| Property | Required | Type | Description | |--------------------|----------|------------------------------------------|-----------------------------------------------------------------------------------------------------| | fps | ✓ | Int32 | The frame rate for capturing the view. | | width | ✓ | CGFloat | The width of the capture area. | | height | ✓ | CGFloat | The height of the capture area. | | displayScale | ✓ | CGFloat | The scale factor for the display. | | captureDuration | | Duration? | The duration for which to capture the view. | | saveVideoFile | | Bool | Whether to save the captured video to a file. | | livestreamSettings | | [LivestreamSettings]? | Settings for live streaming, such as RTMP connection and bitrate. | | content | ✓ | SwiftUI View | A SwiftUI view builder that provides the content to be captured.

Description

Creates a UI recorder that captures a SwiftUI view at a specified frame rate and resolution, optionally saving the video file and configuring live stream settings.

Usage Example

let recorder = createStreamUIRecorder(
    fps: 30,
    width: 1920,
    height: 1080,
    displayScale: 2.0,
    captureDuration: .seconds(7),
    saveVideoFile: true
) {
    Text("Hello, Stream!")
        .font(.largeTitle)
        .foregroundColor(.white)
}

LivestreamSettings

| Property | Required | Type | Description | |----------------|----------|---------------|-----------------------------------------------------------------------------| | rtmpConnection | ✓ | String | The RTMP connection URL for streaming. | | streamKey | ✓ | String | The stream key for authentication with the streaming server. | | profileLevel |

View on GitHub
GitHub Stars258
CategoryContent
Updated12d ago
Forks6

Languages

Swift

Security Score

100/100

Audited on Mar 9, 2026

No findings