Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now

メニュー

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

ビデオの制限を指定する

Deprecation Notice - all 1.x Versions
Please note that all Programmable Video iOS SDK 1.x versions are deprecated. Version 3.x is the latest version of the Programmable Video iOS SDK. Please see the Getting Started Guide for more information.

You can customize the properties of the video produced by a TVIVideoCapturer using TVIVideoConstraints. Constraints allow you to choose at runtime between one of the many TVIVideoFormats that are supported by the capturer. The included TVICameraCapturer class exposes formats based upon what your device's cameras are capable of.

Constraints allow you to filter by several criteria including size, frame rate, and aspect ratio. While constraints are used to resolve the actual capture format, the video sent to other Participants may be downscaled (temporally or spatially) in response to network and device conditions.

In Swift

// Create camera object
let camera = TVICameraCapturer(source: .frontCamera)

// Setup the video constraints
let videoConstraints = TVIVideoConstraints { (constraints) in
    constraints.maxSize = TVIVideoConstraintsSize960x540
    constraints.minSize = TVIVideoConstraintsSize960x540
    constraints.maxFrameRate = TVIVideoConstraintsFrameRateNone
    constraints.minFrameRate = TVIVideoConstraintsFrameRateNone
}

// Add local video track with camera and video constraints
localVideoTrack = TVILocalVideoTrack(capturer: capturer,
                                     enabled: true,
                                     constraints: videoConstraints)

// If the constraints are not satisfied, a nil track will be returned.
if (localVideoTrack == nil) {
    print ("Error: Failed to create a video track using the local camera.")
}

In Objective-C

// Create camera object
TVICameraCapturer *camera = = [[TVICameraCapturer alloc] init];

// Setup the video constraints
TVIVideoConstraints *videoConstraints = [TVIVideoConstraints constraintsWithBlock:
                              ^(TVIVideoConstraintsBuilder * _Nonnull builder) {
    builder.maxSize = TVIVideoConstraintsSize960x540;
    builder.minSize = TVIVideoConstraintsSize960x540;
    builder.maxFrameRate = TVIVideoConstraintsFrameRateNone;
    builder.minFrameRate = TVIVideoConstraintsFrameRateNone;
}];

// Add local video track with camera and video constraints
TVIVideoTrack *localVideoTrack = [TVILocalVideoTrack trackWithCapturer:camera
                                                               enabled:YES
                                                           constraints:videoConstraints];

// If the constraints are not satisfied, a nil track will be returned.
if (localVideoTrack == nil) {
    NSLog(@"Error: Failed to create a video track using the local camera.");
}
Rate this page:

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。