lucian
Posts: 17
Joined: Wed May 08, 2013 10:33 am

Pi Zero W jittery audio via bluetooth

Thu Feb 28, 2019 8:40 am

Hello all,
I have been trying to play some youtube audio streams to a bluetooth connected speaker. I have a raspberry pi zero W with latest raspbian installed in console mode.
After a lot of trial and error I finally managed to find this guide that got me some sound to the speaker:
https://youness.net/raspberry-pi/blueto ... spberry-pi
I am using the following python script to play the music (is part of a project I am trying to make)

Code: Select all

!/usr/bin/env python                                                                                                                                                                                                                        
import re                                                                                                                                   
import sys                                                                                                                                  
import pafy                                                                                                                                 
import vlc                                                                                                                                  
url = "https://www.youtube.com/watch?v=G0OqIkgZqlA"                                                                                         
video = pafy.new(url)                                                                                                                       
best = video.getbestaudio()                                                                                                                 
playurl = best.url                                                                                                                          
player = vlc.MediaPlayer(playurl)                                                                                                           
player.play()                                                                                                                               
while True: pass 
The trouble is that the sound I am getting is unintelligible. It sound like the sound one would get on a bad connection. Very jittery. The same thing happens if I try to play with:

Code: Select all

cvlc --no-video https://www.youtube.com/watch?v=G0OqIkgZqlA
The line above, plays the sound through vlc in a terminal without opening a window.

Does anyone have any idea why the sound is so bad via bluetooth? are there any better guides to connect a bluetooth speaker to raspbbery pi and use it for music?

Cheers

Edit: I forgot to mention that the same code above works great with wired headphones connected to a usb sound card. So the problem doesn't seem to be with the code but with the bluetooth connection.

Return to “General discussion”