Questions tagged [cmsamplebuffer]
106 questions
2
votes
1 answer
Playing back a CMSampleBuffer
I'm trying to create an application that streams video and audio to an other computer.
On the "server" side, I'm able to capture (using AVCaptureSession) video and audio, to preview them and to send them over the network using the delegate and…

Louis Borsu
- 135
- 1
- 2
- 10
1
vote
1 answer
Apply mute to CMSampleBuffer in Swift5
I'm trying to save captured video & audio through a camera and mic on an iOS device using AVAssetWriter. I finished developing a basic function like a user can record both image(video) and audio using CMSampleBuffer, and now I'm trying to make the…

Yuuu
- 715
- 1
- 9
- 32
1
vote
1 answer
Adding UIImage to CMSampleBuffer in Swift
I'm searching for a way to add a custom UIImage to CMSampleBuffer which we can get in didOutput sampleBuffer in AVFoundation.
I'm working on a live-streaming app and use sampleBuffer and submit the frame to the broadcaster. Then, I'm trying to add a…

Yuuu
- 715
- 1
- 9
- 32
1
vote
1 answer
Dispatch_async in captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer, EXC_BAD_ACCESS error on sample buffer
I am trying to get the sample buffer from captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer, process it and then append it to an AVAssetWriter. The whole code works, however it gets really slow and I get low fps on older devices.…

reapf
- 89
- 6
1
vote
1 answer
Modifying CVPixelBuffer
I'm using the method below to add drawings to a pixel buffer, then append it to an AVAssetWriterInputPixelBufferAdaptor.
It works on my Mac mini (macOS 12 beta 7), but the drawingHandler draws nothing on my MacBook (macOS 11.5.2).
Is there anything…

scchn
- 315
- 3
- 16
1
vote
0 answers
How can I create CMSampleBuffers in Swift without a memory leak?
I'm reading video data with an AVAssetReader and "looping" the content by reading it again and modifying the timestamps. The relevant code is:
private func readFrame() -> CMSampleBuffer? {
let buffer = output?.copyNextSampleBuffer()
guard…

Adam A
- 14,469
- 6
- 30
- 38
1
vote
0 answers
Record camera output before Vision recognises event
My app recognises an event using Vision and uses CMSampleBuffer to do so.
After the event I am recording the video already using AVWriter successfully.
Now I want to record the full motion and thus record 1-2 seconds before the event occurred.
I…

bnassler
- 591
- 6
- 15
1
vote
0 answers
CMSampleBuffer duplicate audio channel
Given a mono audio CMSampleBuffer with one channel, how do I create a new CMSampleBuffer which has two channels and whose other channel audio samples are duplicate of the other channel? In other words, I need to create stereo from mono audio.

Deepak Sharma
- 5,577
- 7
- 55
- 131
1
vote
0 answers
Audio CMSampleBuffer volume change in Swift
I am trying to record a video with AVAssetwriter. Now want to control volume for my final output video file. Any Help?
Solutions I had tried:-
self.avAssetInputAudio?.preferredVolume = 0.2 //The value for this property should typically be in the…

Ankita Pundir
- 49
- 4
1
vote
2 answers
Can you play audio directly from a CMSampleBuffer?
I have mic audio captured during an ARSession that I wish to pass to another VC and play back after the capture has taken place, but whilst the app is still running (and audio in memory).
The audio is currently captured as a single CMSampleBuffer…

MightyMeta
- 599
- 4
- 14
1
vote
1 answer
First audio CMSampleBuffer lost when reading mp4 file using AVAssetReader
I'm using AVAssetWriter to write audio CMSampleBuffer to an mp4 file, but when I later read that file using AVAssetReader, it seems to be missing the initial chunk of data.
Here's the debug description of the first CMSampleBuffer passed to writer…

Grzegorz Aperliński
- 848
- 1
- 10
- 23
1
vote
0 answers
How to increase the speed of audio in CMSampleBuffer
What is the process to speed up audio recieved via CMSampleBuffer so that is recorded at 2X speed.

Abhiraj Kumar
- 160
- 1
- 6
1
vote
1 answer
iPhone11 unexpected number of Audio Samples
I have an app that captures audio and video using AVAssetWriter. It runs a fast fourier transform (FFT) on the audio to create a visual spectrum of the captured audio in real time.
Up until the release of iPhone11, this all worked fine. Users with…

JCutting8
- 732
- 9
- 29
1
vote
0 answers
Convert CMSampleBuffer to Data and Data back to CMSampleBuffer
I'm receiving the cmsamplebuffer from broadcast upload extension and I need to send it to the main app so that it can be sent via webrtc. Webrtc strictly needs to be in the main app. In order to send the cmsamplebuffer to the main app, I need to…

FH-
- 133
- 1
- 9
1
vote
0 answers
kCMSampleBufferAttachmentKey_TrimDurationAtStart error
Getting an error when trying to convert a video recorded from camera or picked from gallery:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[AVAssetWriterInput appendSampleBuffer:]
Cannot append sample buffer:…

user3500462
- 125
- 7