{"id":1218,"url":"https://github.com/Awalz/SwiftyCam","last_synced_at":"2025-07-30T20:32:49.157Z","repository":{"id":37381908,"uuid":"77353899","full_name":"Awalz/SwiftyCam","owner":"Awalz","description":"A Snapchat Inspired iOS Camera Framework written in Swift","archived":false,"fork":false,"pushed_at":"2022-02-04T10:24:45.000Z","size":1930,"stargazers_count":2087,"open_issues_count":90,"forks_count":327,"subscribers_count":67,"default_branch":"master","last_synced_at":"2024-11-14T12:15:54.058Z","etag":null,"topics":["avfoundation","camera","flash","image-capture","photos","retina-flash","snapchat","video-capture","video-recording"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Awalz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-26T02:58:55.000Z","updated_at":"2024-11-06T17:00:37.000Z","dependencies_parsed_at":"2022-07-21T09:02:21.393Z","dependency_job_id":null,"html_url":"https://github.com/Awalz/SwiftyCam","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyCam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyCam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyCam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Awalz%2FSwiftyCam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Awalz","download_url":"https://codeload.github.com/Awalz/SwiftyCam/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187586,"owners_count":17882329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avfoundation","camera","flash","image-capture","photos","retina-flash","snapchat","video-capture","video-recording"],"created_at":"2024-01-05T20:15:41.516Z","updated_at":"2024-12-04T20:31:07.810Z","avatar_url":"https://github.com/Awalz.png","language":"Swift","funding_links":[],"categories":["Hardware","Swift","Media"],"sub_categories":["Camera","Other free courses"],"readme":"\u003cimg src=\"SwiftyCamBanner.jpg\"  align=\"center\"\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/platform-iOS%208%2B-blue.svg?style=flat\" alt=\"Platform: iOS 8+\"/\u003e\n    \u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-swift%204.2-4BC51D.svg?style=flat\" alt=\"Language: Swift 4.2\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://cocoapods.org/pods/SwiftyCam\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/SwiftyCam.svg?style=flat\" alt=\"CocoaPods compatible\" /\u003e\u003c/a\u003e\n    \u003cimg src=\"http://img.shields.io/badge/license-BSD-lightgrey.svg?style=flat\" alt=\"License: BSD\" /\u003e \u003cbr\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n## Overview\n\nSwiftyCam is a a simple, Snapchat-style iOS Camera framework for easy photo and video capture. SwiftyCam allows users to capture both photos and videos from the same session with very little configuration.\n\nConfiguring a Camera View Controller in AVFoundation can be tedious and time consuming. SwiftyCam is a drop in View Controller which gives complete control of the AVSession.\n\n### For Swift 4 support, see Swift4 branch\n\n## Features\n\n|                              | SwiftyCam        \n| ------------------------------------- | ---------------------\n| :sunglasses:                  | Snapchat-style media capture               \n| :+1:        \t\t\t\t\t  | Support iOS8+                \n| :camera:  \t\t\t\t\t\t  | Image capture               \n| :movie_camera:  \t\t\t      | Video capture                \n| :chart_with_upwards_trend:    | Manual image quality settings                \n| :tada:                        | Front and rear camera support              \n| :flashlight:                  | Front and rear flash  \n| :sunny:                       | Retina flash support               \n| :mag_right:                   |  Supports manual zoom               \n| :lock:                        | Supports manual focus\n| :last_quarter_moon_with_face: |  Low light setting               \n| :speaker:                     | Background audio support                 \n\n\n\n## Requirements\n\n* iOS 8.0+\n* Swift 4.2+\n\n## License\n\nSwiftyCam is available under the BSD license. See the LICENSE file for more info.\n\n\n## Installation\n\n### Cocoapods:\n\nSwiftyCam is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"SwiftyCam\"\n```\n\n### [Carthage](https://github.com/Carthage/Carthage)\n\nAdd this to `Cartfile`\n\n```\ngithub \"Awalz/SwiftyCam\" ~\u003e 2.2.1\n```\n\n```\n$ carthage update SwiftyCam\n```\n\n### Manual Installation:\n\nSimply copy the contents of the Source folder into your project.\n\n## Usage\n\nUsing SwiftyCam is very simple.\n\n### Prerequisites:\n\nAs of iOS 10, Apple requires the additon of the `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` strings to the info.plist of your application. Example:\n\n```xml\n\u003ckey\u003eNSCameraUsageDescription\u003c/key\u003e\n\t\u003cstring\u003eTo Take Photos and Video\u003c/string\u003e\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\t\u003cstring\u003eTo Record Audio With Video\u003c/string\u003e\n```\n\n\n### Getting Started:\n\nIf you install SwiftyCam from Cocoapods, be sure to import the module into your View Controller:\n\n```swift\nimport SwiftyCam\n```\n\n\nSwiftyCam is a drop-in convenience framework. To create a Camera instance, create a new UIViewController subclass. Replace the UIViewController subclass declaration with `SwiftyCamViewController`:\n\n```swift\nclass MyCameraViewController : SwiftyCamViewController\n```\n\nThat is all that is required to setup the AVSession for photo and video capture. SwiftyCam will prompt the user for permission to use the camera/microphone, and configure both the device inputs and outputs.\n\n## Capture\n\n### SwiftyCamButton:\n\nSwiftyCam comes with a very convenient method of capturing media. SwiftyCamButton captures photos with a `UITapGestureRecognizer` and captures video with a `UILongPressGestureRecognizer`\n\nTo use a SwiftyCamButton, simply create one and assign the delegate to your SwiftyCamViewController:\n\n```swift\nlet captureButton = SwiftyCamButton(frame: buttonFrame)\ncaptureButton.delegate = self\n```\n\n### Manual:\n\nCapturing media with SwiftyCam is very simple. To capture a photo, simply call the `takePhoto` function:\n\n```swift\ntakePhoto()\n```    \n\nCapturing Video is just as easy. To begin recording video, call the `startVideoRecording` function:\n\n```swift\nstartVideoRecording()\n```\n\nTo end the capture of a video, call the `stopVideoRecording` function:\n\n```swift\nstopVideoRecording()\n```\n\n\n### Delegate\n\nIn order to acquire the photos and videos taken by either the SwiftyCamButton or manually, you must implement the `SwiftyCamViewControllerDelegate` and set the `cameraDelegate` to your view controller instance:\n\n```swift\nclass MyCameraViewController : SwiftyCamViewController, SwiftyCamViewControllerDelegate {\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        cameraDelegate = self\n    }\n    ...\n}\n```   \n\n#### Delegate methods:\n\n```swift\nfunc swiftyCam(_ swiftyCam: SwiftyCamViewController, didTake photo: UIImage) {\n     // Called when takePhoto() is called or if a SwiftyCamButton initiates a tap gesture\n     // Returns a UIImage captured from the current session\n}\n\nfunc swiftyCam(_ swiftyCam: SwiftyCamViewController, didBeginRecordingVideo camera: SwiftyCamViewController.CameraSelection) {\n     // Called when startVideoRecording() is called\n     // Called if a SwiftyCamButton begins a long press gesture\n}\n\nfunc swiftyCam(_ swiftyCam: SwiftyCamViewController, didFinishRecordingVideo camera: SwiftyCamViewController.CameraSelection) {\n     // Called when stopVideoRecording() is called\n     // Called if a SwiftyCamButton ends a long press gesture\n}\n\nfunc swiftyCam(_ swiftyCam: SwiftyCamViewController, didFinishProcessVideoAt url: URL) {\n     // Called when stopVideoRecording() is called and the video is finished processing\n     // Returns a URL in the temporary directory where video is stored\n}\n\nfunc swiftyCam(_ swiftyCam: SwiftyCamViewController, didFocusAtPoint point: CGPoint) {\n     // Called when a user initiates a tap gesture on the preview layer\n     // Will only be called if tapToFocus = true\n     // Returns a CGPoint of the tap location on the preview layer\n}\n\nfunc swiftyCam(_ swiftyCam: SwiftyCamViewController, didChangeZoomLevel zoom: CGFloat) {\n\t  // Called when a user initiates a pinch gesture on the preview layer\n\t  // Will only be called if pinchToZoomn = true\n\t  // Returns a CGFloat of the current zoom level\n}\n\nfunc swiftyCam(_ swiftyCam: SwiftyCamViewController, didSwitchCameras camera: SwiftyCamViewController.CameraSelection) {\n     // Called when user switches between cameras\n     // Returns current camera selection   \n}\n```   \n\n## Flash\n\nThe flash(torch) can be enabled by changing the `flashEnabled` property:\n\n```swift\nflashEnabled = true\n```   \n\nFlash is now supported for front and rear facing cameras.\n\n### Rear Camera\n\nFor photos, the camera will flash much like the stock iOS camera. For video, the torch(flash) will enable for the duration of the video capture.\n\n### Front Camera\n\nFor models that support [Retina Flash](https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Cameras/Cameras.html#//apple_ref/doc/uid/TP40013599-CH107-SW7), the front camera will use the default flash for image capture. If Retina Flash is not supported, a faux Retina Flash is used similar to Snapchat.\n\nFor front facing videos, a white, 85% opaque view will be placed over the video feed for the duration of the video capture.\n\n## Switching Camera\n\nBy default, SwiftyCam will launch to the rear facing camera. This can be changed by changing the `defaultCamera` property in `viewDidLoad`:\n\n```swift\noverride func viewDidLoad() {\n    super.viewDidLoad()\n    defaultCamera = .front\n    ...\n}\n```\n\nSwiftyCam supports capture from both the front and back cameras. To switch cameras, call the function:\n\n```swift\nswitchCamera()\n```\n\nTap-to-focus, pinch-to-zoom and camera flash are not supported when the front facing camera is selected. *Switching video while video is being recorded is not currently supported*\n\nSwiftyCam also enables switching between cameras with a double tap gesture. To disable this feature, use the `doubleTapCameraSwitch` property:\n\n```swift\ndoubleTapCameraSwitch = false\n```\n\n## Configuration\n\nSwiftyCam has several options for configurating the functionality of the capture:\n\n### Video Quality\n\nVideo quality can be set by the **videoQuality** property of SwiftyCamViewController. The choices available correspond to the matching **AVCaptureSessionPreset**:\n\n| VideoQuality                          | AVCaptureSessionPreset        \n| ------------------------------------- | ---------------------\n| `.high`                           | **AVCapturePresetHigh**                \n| `.medium`        \t\t\t\t\t   | **AVCapturePresetMedium**                \n| `.low`  \t\t\t\t\t\t\t   | **AVCapturePresetLow**                \n| `.resolution352x288`  \t\t\t   | **AVCaptureSessionPreset352x288**                \n| `.resolution640x480`              | **AVCaptureSessionPreset640x480**                \n| `.resolution1280x720`             | **AVCaptureSessionPreset1280x720**              \n| `.resolution1920x1080`            | **AVCaptureSessionPreset1920x1080**  \n| `.resolution3840x2160`            | **AVCaptureSessionPreset3840x2160**               \n| `.iframe960x540`                  | **AVCaptureSessionPresetiFrame960x540**               \n| `.iframe1280x720`                 | **AVCaptureSessionPresetiFrame1280x720**               \n\n\nThe default value is **.high**. For use with the front-facing camera, **.high** will always be used.\n\n### Maximum Video Duration\n\nIf using a SwiftyCamButton, you can set a maximum video duration for the length of video. The video recording will me automatically stopped once the time limit has been reached and the delegate method `SwiftyCamDidFinishRecordingVideo` will be called. To set this value, simply change the `maximumVideoDuration` value:\n\n```swift\nmaximumVideoDuration = 10.0\n```\n\nA value of **0.0** will allow for unlimited video recording via the SwiftyCamButton. The default value is **0.0**.\n\n## Camera Zoom\n\nSwiftyCam supports digital zoom of the camera session via pinch and pan gestures. The gestures work similar to the default iOS app and will zoom to the maximum supported zoom level. Camera zoom is only supported on the rear facing camera. AVFoundation does not currently support front facing camera zoom. To disable this feature, change the `pinchToZoom` property:\n\n```swift\npinchToZoom = false\n```   \n\nBy default, ```pinchToZoom``` is enabled.\n\nSwiftyCam also supports the ability to zoom the rear facing camera with vertical pan gestures. To disable this feature, change the `swipeToZoom` property:\n\n```swift\nswipeToZoom = false\n```   \n\nBy default, ```swipeToZoom``` is enabled. The default gestures zoom in the capture session with a downward swipe, and zoom out with an upward swipe. This can be reversed by changing the ```swipeToZoomInverted``` property:\n\n```swift\nswipeToZoomInverted = true\n```\n\nYou can also restrict the amount that the rear facing camera can zoom. To do this, use the         `maxZoomScale` property:\n\n```swift\nmaxZoomScale = 2.0\n```   \n\nBy default, `maxZoomScale` is set to **infinite**. The actual maximum zoom level is determined by the device's [videoMaxZoomFactor](https://developer.apple.com/reference/avfoundation/avcapturedeviceformat/1624635-videomaxzoomfactor).\n\n## Camera Focus\n\nSwiftyCam, by default, support tap to focus on the video preview. SwiftyCam will set the focus and exposure levels of the session to the tapped point. While tap to set exposure is supported on both cameras, tap to focus is only supported on rear facing cameras. Autofocus and autoexposure will be resumed once SwiftyCam detects significant movement from the tapped point. To disable this feature, change the `tapToFocus` property:\n\n```swift\ntapToFocus = false\n```\n\nBy default, `tapToFocus` is enabled. If you wish to show a on screen animation when a tap to focus is initiated, you can use the `SwiftyCamDidFocusAtPoint(focusPoint:)` to get the coordinates of tap and provide your own tap animation\n\n## Device Orientation\n\nBy default, SwiftyCam will set the photo orientation to be portrait. If you wish to preserve the orientation of the capture photos to allow support for landscape images, use the `shouldUseDeviceOrientation` property:\n\n```swift\nshouldUseDeviceOrientation = true\n```\n\n\n## Background Audio\n\nSwiftyCam has the ability to allow background audio to continue playing within the session, and to be captured by the video recording. By default, this is enabled. If you wish to disable this feature, change the `allowBackgroundAudio` property:\n\n```swift\nallowBackgroundAudio = false\n```\n\n## Low Light Boost\n\nFor supported models (iPhone 5 and 5C), AVCaptureDevice supports a low light boost when it is detected that the capture session is in a low light area. By default, this is set to true. It can be modified with the `lowLightBoost` variable:\n\n```swift\nlowLightBoost = false\n```\n\n## Privacy\n\nWhen a user firsts launch SwiftyCamViewController, they will be prompted for permission for access to the cameras and microphones. By default, if a user declines access to the hardware, SwiftyCam will provide a prompt to the App privacy settings inside the iOS settings application.\n\n## Miscellaneous\n\nOther properties:\n\n* `isCameraFlashOn` -  **Boolean**\n* `isVideoRecording` - **Boolean**\n* `isSessionRunning` - **Boolean**\n* `currentCamera` - **CameraSelection**\n\n\n### Contact\n\nIf you have any questions, requests, or enhancements, feel free to submit a pull request, create an issue, or contact me in person:\n\n**Andrew Walz**\n**andrewjwalz@gmail.com**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAwalz%2FSwiftyCam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAwalz%2FSwiftyCam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAwalz%2FSwiftyCam/lists"}