BlakeJames
Posts: 2
Joined: Fri Nov 08, 2019 10:57 pm

Distorted/slow audio when using Picamera

Fri Nov 08, 2019 11:16 pm

When using Picamera to capture still images in a continuous loop, my audio playback becomes significantly distorted (think robot voice at ~1/4 normal playback speed). Furthermore, the time.sleep() delays that I have seem to also be significantly stretched out in time once the camera is turned on.
- I'm using a CM3 module, but have also replicated the same thing on a 3B+ board.
- My audio files are being played with pygame, playing .mp3 files.
- Images are being captured in a separate thread with:

Code: Select all

with picamera.PiCamera(resolution='3280x2464') as camera:
...
    camera.capture(imageLocation, format=format, quality=100, use_video_port=False )
- If I take only one photo and allow the camera thread to end, there is no audio issue.
- I've isolated the issue to be only active while the

Code: Select all

with picamera.PiCamera(resolution='3280x2464') as camera:
line remains active. It does not matter whether I capture a photo or not, only if the above line has been executed and that thread remaint within the

Code: Select all

with
teir.

I've really struggled to find anyone else online with this issue. Any help would be much appreciated.
Cheers,

BlakeJames
Posts: 2
Joined: Fri Nov 08, 2019 10:57 pm

Re: Distorted/slow audio when using Picamera

Tue Nov 12, 2019 3:31 am

Anyone got any feedback here? Or maybe a suggestion to move this to a different topic?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7420
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Distorted/slow audio when using Picamera

Tue Nov 12, 2019 12:17 pm

What does "top" report the CPU usage to be?
Python threads aren't always as clean and independent as you might hope. Is "top" reporting your workload as being split across multiple cores?

Run raspistill or raspivid whilst playing your audio from Python. If there is no change in the audio then it's an issue within Python. If there is a change then it's possibly the overhead of running the camera pipeline that is interrupting your audio process.

What audio output device are you using? Analog audio jack, HDMI, or USB / I2S sound card?
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”