User avatar
Ram.Sh
Posts: 32
Joined: Wed Oct 26, 2016 9:14 pm

omxplayer + Bluetooth = new problems... need some help

Thu Sep 12, 2019 9:47 pm

Hello,

I have no experience with omxplayer and really need some help.

I'm using Pi4 4G running Raspbian GNU/Linux 10 (buster)

my project is using the omxplayer to play very short mp3 files (1 second long), everything was working well until I've updated the project to play the same files to a Blue Tooth receiver instead of the 3.5 jack wired speakers followed by this tutorial, I route the playing to the BT by calling omxplayer with the additional -o alsa:

Code: Select all

subprocess.call(['omxplayer', '-o', 'alsa', fullPath])
i then realized that although it seems the file is being played there's no sound coming out of the wireless speaker, after some investigations I played the same file but added two seconds silence to it at the beginning and that "fixed" it so I've learned that very short mp3 files (less than 1.5 second) played with the -o alsa are not being heard but they do heard with 3.5 wired connection.

the second problem I've encountered using Blue Tooth receiver is the additional delay in time difference between playing the same file with -o alsa to the BT receiver and without to the wired speaker, it takes more than a full second via the BT to start the playing, and since those files are played in direct response to the user's joystick movements it feels like a lot of lag time and this translate to a horrible user experience.

1. how can I make the player to play the file instantly just like when using wired speakers?
2. is there any way to have the player play 1 second mp3 files?

the following are two sample mp3 files, 1.5 second and a 3 seconds file.
this will be heard
this will not be heard

many thanks in advance for any shared thought or advice!
Cheers,
Ram

User avatar
Douglas6
Posts: 4760
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: omxplayer + Bluetooth = new problems... need some help

Thu Sep 12, 2019 11:00 pm

Ram.Sh wrote:
Thu Sep 12, 2019 9:47 pm
1. how can I make the player to play the file instantly just like when using wired speakers?
You can't. Bluetooth streaming will always exhibit more latency than a wired connection. That's just Bluetooth. One second latency sounds a little extreme, but I would be surprised if you can cut it down to less than 200 or 300 milliseconds.
Ram.Sh wrote:
Thu Sep 12, 2019 9:47 pm
2. is there any way to have the player play 1 second mp3 files?
Many Bluetooth speakers will 'sleep' after some period of inactivity, and take some time to 'wake up'. Does the 1 second file play shortly after playing a longer audio clip?

In general, I question the suitability of Bluetooth to your goals.

User avatar
Ram.Sh
Posts: 32
Joined: Wed Oct 26, 2016 9:14 pm

Re: omxplayer + Bluetooth = new problems... need some help

Fri Sep 13, 2019 7:23 am

@Douglas6, many thanks for your reply.
In general, I question the suitability of Bluetooth to your goals.
I have my doubts also, my initial thought was to look for some short range (up to 5 meters) analog radio transmitter/receiver that will be used for data communication between the Pi and the device that holds the joystick an speakers, i was thinking of connecting the radio transmitter to the 3.5 wire and send the audio in its analog form to the receiver which in turns is connected to the amplifier of the speakers... do you think that that kind of solution could work?

User avatar
Douglas6
Posts: 4760
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: omxplayer + Bluetooth = new problems... need some help

Fri Sep 13, 2019 10:19 am

I'm afraid I'm not familiar with radios apart from WiFi and Bluetooth. I can't think of any advantage using a different frequency would have.

User avatar
Ram.Sh
Posts: 32
Joined: Wed Oct 26, 2016 9:14 pm

Re: omxplayer + Bluetooth = new problems... need some help

Fri Sep 13, 2019 10:21 am

I got to "solve" the short files and real time playing issues by changing the format of the files from MP3 to OGG, that part solved the short length problem (it seems the omxplayer has no problem with short ogg files), and the second "solution" (based on Douglas6's quiestion) was to use two omxplayers, the first omxplayer runs --loop of a 1 minute silence file in the background, this way it keeps the BT from going into "sleep" mode and the second one to play the ogg short files, the outcome of this is equal to the wired speakers setup.

Code: Select all

omxplayer -o alsa --loop silence.mp3
this is the silence.mp3 file if anyone needs

User avatar
Ram.Sh
Posts: 32
Joined: Wed Oct 26, 2016 9:14 pm

Re: omxplayer + Bluetooth = new problems... need some help

Fri Sep 13, 2019 10:22 am

Douglas6 wrote:
Fri Sep 13, 2019 10:19 am
I'm afraid I'm not familiar with radios apart from WiFi and Bluetooth. I can't think of any advantage using a different frequency would have.
nevertheless our conversation did help me a lot!!! many thanks!!!

Return to “Graphics, sound and multimedia”