Update README.md

This commit is contained in:
shogo4405 2023-04-30 14:54:28 +09:00
parent 263689ffaa
commit fdc9aa3272
4 changed files with 33 additions and 15 deletions

View File

@ -43,7 +43,22 @@ final class LiveViewController: UIViewController {
if let orientation = DeviceUtil.videoOrientation(by: UIApplication.shared.statusBarOrientation) {
rtmpStream.videoOrientation = orientation
}
rtmpStream.videoSettings.videoSize = .init(width: 720, height: 1280)
rtmpStream.audioSettings = AudioCodecSettings(
bitRate: 64 * 1000
)
rtmpStream.videoSettings = VideoCodecSettings(
videoSize: .init(width: 854, height: 480),
profileLevel: kVTProfileLevel_H264_Baseline_3_1 as String,
bitRate: 640 * 1000,
maxKeyFrameIntervalDuration: 2,
scalingMode: .trim,
bitRateMode: .average,
allowFrameReordering: nil,
isHardwareEncoderEnabled: true
)
rtmpStream.mixer.recorder.delegate = self
videoBitrateSlider?.value = Float(VideoCodecSettings.default.bitRate) / 1000
audioBitrateSlider?.value = Float(AudioCodecSettings.default.bitRate) / 1000

View File

@ -208,18 +208,21 @@ stream.videoCapture(for: 0).preferredVideoStabilizationMode = .auto
// rtmpStream.videoCapture(for: 1).isVideoMirrored = false
// Specifies the audio codec settings.
stream.audioSettings = [
.bitrate: 32 * 1000,
]
stream.audioSettings = AudioCodecSettings(
bitRate: 64 * 1000
)
// Specifies the video codec settings.
stream.videoSettings = [
.width: 640, // video output width
.height: 360, // video output height
.bitrate: 160 * 1000, // video output bitrate
.profileLevel: kVTProfileLevel_H264_Baseline_3_1, // H264 Profile require "import VideoToolbox"
.maxKeyFrameIntervalDuration: 2, // key frame / sec
]
stream.videoSettings = VideoCodecSettings(
videoSize: .init(width: 854, height: 480),
profileLevel: kVTProfileLevel_H264_Baseline_3_1 as String,
bitRate: 640 * 1000,
maxKeyFrameIntervalDuration: 2,
scalingMode: .trim,
bitRateMode: .average,
allowFrameReordering: nil,
isHardwareEncoderEnabled: true
)
// Specifies the recording settings. 0" means the same of input.
stream.startRecording([
@ -280,7 +283,7 @@ connection.connect("rtmp://username:password@localhost/appName/instanceName")
```swift
// iOS
let screen = IOUIScreenCaptureUnit(shared: UIApplication.shared)
screen.delegate = rtmpStream
screen.delegate = stream
screen.startRunning()
// macOS

View File

@ -8,7 +8,7 @@ public protocol TSReaderDelegate: AnyObject {
func reader(_ reader: TSReader, id: UInt16, didRead sampleBuffer: CMSampleBuffer)
}
/// The TSReader class represents read MPETF-2 transport stream data.
/// The TSReader class represents read MPEG-2 transport stream data.
public class TSReader {
/// Specifies the delegate object.
public weak var delegate: TSReaderDelegate?

View File

@ -6,12 +6,12 @@ import Foundation
import SwiftPMSupport
#endif
/// MPEG-2 TS (Transport Stream) Writer delegate
/// The interface an MPEG-2 TS (Transport Stream) writer uses to inform its delegates.
public protocol TSWriterDelegate: AnyObject {
func writer(_ writer: TSWriter, didOutput data: Data)
}
/// MPEG-2 TS (Transport Stream) Writer Foundation class
/// The TSWriter class represents writs MPEG-2 transport stream data.
public class TSWriter: Running {
public static let defaultPATPID: UInt16 = 0
public static let defaultPMTPID: UInt16 = 4095