Capture image via captureStillImageAsynchronouslyFromConnection with no shutter sound
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Overview
Capturing images in an iOS application using captureStillImageAsynchronouslyFromConnection method from the AVFoundation framework is a common requirement for developers building camera applications. Sometimes, you might need to capture an image without the default shutter sound for privacy or user experience reasons. This article explores how to achieve this without altering system settings or requiring special permissions.
Understanding captureStillImageAsynchronouslyFromConnection
The captureStillImageAsynchronouslyFromConnection method is part of the AVFoundation framework, allowing developers to capture still images asynchronously. This method is typically used together with an AVCaptureSession for configuring inputs, outputs, and connections between them.
Sample Method Usage
Key Challenges of Disabling Shutter Sound
Why Does the Shutter Sound Occur?
The shutter sound is a byproduct of the capture session, as the operating system simulates a camera shutter. This sound is intended to indicate that a photo has been taken. On iOS devices, the sound serves as a notification and privacy measure, especially in regions where silent photo capture is restricted.
Methods to Disable the Shutter Sound
By default, iOS does not provide a direct API to disable the camera shutter sound. However, some tricks and workarounds achieve this:
- Device Volume: Lower the device's media volume to zero. However, this affects all system sounds and requires user intervention.
- Silent Mode: Encourage users to switch their devices to silent mode. Like the device volume method, this affects all system sounds.
- Video Capture Trick: Capture a video frame instead, which inherently does not produce a shutter sound, and extract a still image from the video.
Implementing Silent Image Capture with Video Frame Extraction
To silently capture an image, you can capture a short video and extract a frame. This method requires more processing and slightly more delay than traditional image capture. Here’s how you can implement it:
Step-by-Step Implementation
- Configure a
AVCaptureVideoDataOutput:
- Capture a Video Buffer:
- Extract an Image from the Buffer:
Considerations & Best Practices
- Resource Utilization: Video frame extraction requires more CPU and memory usage. Monitor performance on older devices.
- Delay: This method introduces a delay compared to instant photo capture.
Conclusion
While Apple does not provide a native option to silence the shutter sound directly through the API, these techniques can help achieve the requirement with acceptable user experience trade-offs. Always test on various devices to ensure smooth operation and compliance with privacy regulations.
Summary Table
| Method | Description | Pros | Cons |
| Device Volume | Adjust the media volume to zero | Simple to execute | Affects all system sounds |
| Silent Mode | Users toggle silent switch | Non-intrusive | Manual user intervention required |
| Video Frame Extract | Capture video, extract frame, no sound | Effective and silent | More CPU usage & slight capture delay |
By understanding and implementing these workarounds, developers can effectively manage their iOS applications' needs for silent image capture while considering different user and device contexts.
Related reading
- Cassandra Hector How to retrieve all rows of a column family?
- Cassandra Java Driver- QueryBuilder API vs PreparedStatements
- Chain multiple Alamofire requests
- Change number of threads for Tensorflow inference with C API
- Capture iOS Simulator video for App Preview
- Capturing self weak or unowned on asynchronous network requests
- Changing API level Android Studio
- Changing Java Date one hour back

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.