mmkw43
Posts: 705
Joined: Tue Dec 24, 2013 6:18 pm

MPG123 -- first 1 or 2 seconds of audio cut off

Tue Nov 24, 2020 7:04 pm

Been spending days on this, so thought I'd throw this out there to see if anyone has experienced it. Using RPI 3 and Raspian (even tried this with latest OS and other Pi's. Even tried mpg321. And it's NOT the hdmi cable or TV avc control.

Simplest way I can explain this is to do this --
reboot the PI and open Lxterminal.
sudo mpg123 (play your mp3)

do it again.

I have found that on your FIRST attempt to play an mp3 file, you get the first second or 2 completely chopped off. Sometimes your lucky, often times not. On the second and subsequent attempts it (mostly) plays fine but I've also seen either complete lack of play, 50/50 etc but mostly on 2nd or further attempts it's OK. It's especially bad on short (few seconds long) files for some reason) and that's what I need -- to play short announcements.

The issue (for me ) is that consistent problem on first attempt (after reboot) and maybe someone has some ideas. I've tried all sorts of mpg123 options. Is it some sort of buffer issue? HDMI negotiation problem? Giving the PI plenty of time to "settle in" after reboot. Please Help !

I also have raspi-comfig setup for forcing hdmi audio but I made want a refresher on that to double check it. BIG THANKS.

Oh yeah, also -- if you "walk away" for a while hour etc without rebooting and open terminal and try to play, quite often the same cutoff thing happens.

User avatar
dickon
Posts: 1886
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Tue Nov 24, 2020 8:19 pm

It's usually down to power management. The kernel will power down the sound infrastructure when it isn't in use to save power. My desktop does it, too.

No idea what to do about it, though. Might well be barking up the wrong tree.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

mmkw43
Posts: 705
Joined: Tue Dec 24, 2013 6:18 pm

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Tue Nov 24, 2020 9:40 pm

Thanks. Yeah, this is a serious problem for what I want to do. At least you know I'm not imagining things. If anyone has ANY ideas on how to get around this it would be much appreciated. I have mpg123 in a script and yeah, the audio may not be called that often. Maybe I can just open it at regular intervals and mute the output (?) so it would be "ready to go" when called upon to play a file? I hate to do it but I'll try it.

I can even just walk away from it sometimes (without rebooting) for just a few minutes and it will chop a bit off the front. But it ALWAYS does it after a reboot and fresh run of mpg123. From what you say though, it's an OS problem. -- Sucks.

BMS Doug
Posts: 4422
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Tue Nov 24, 2020 9:49 pm

mmkw43 wrote:
Tue Nov 24, 2020 9:40 pm
Thanks. Yeah, this is a serious problem for what I want to do. At least you know I'm not imagining things. If anyone has ANY ideas on how to get around this it would be much appreciated. I have mpg123 in a script and yeah, the audio may not be called that often. Maybe I can just open it at regular intervals and mute the output (?) so it would be "ready to go" when called upon to play a file? I hate to do it but I'll try it.

I can even just walk away from it sometimes (without rebooting) for just a few minutes and it will chop a bit off the front. But it ALWAYS does it after a reboot and fresh run of mpg123. From what you say though, it's an OS problem. -- Sucks.
How timing critical are your announcements?

Can you add 3 seconds of dead noise time to the beginning of each announcement without issues or would that cause issues?
Doug.
Building Management Systems Engineer.

User avatar
dickon
Posts: 1886
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Tue Nov 24, 2020 9:57 pm

If you can't find out how to fix it, simply playing silence in a loop on one instance might do it. You may have volume / mixing issues.
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

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

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Tue Nov 24, 2020 10:06 pm

It may be the OS. I think it's more likely to be the speaker. Some 'green' speakers will go into shutdown mode after a period of silence. It takes a second for them to 'warm up'.

mmkw43
Posts: 705
Joined: Tue Dec 24, 2013 6:18 pm

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Tue Nov 24, 2020 10:08 pm

It's funny you should bring that up because I tried 2 seconds of silence and it worked well -- problem is I wasn't sure why, which always makes me uptight. Yeah I did the audio at freettss.com and you can add a pause if you want. The only problem with that is if I ask users to "add silence", it will be rather unprofessional but like I say, it did help considerably. I only added 2 seconds of silence in the ones I did -- sounds like 3 may fix it. Wish though there was another way. ( ! )

I may try that mute thing. I actually have my audio stuff in a thread so I could have a continuous loop maybe and play 1 instance of muted audio. ? Will try that.

Wish I had a better understanding of what's really going on with the kernel thing mentioned etc. (Just for my own education).

mmkw43
Posts: 705
Joined: Tue Dec 24, 2013 6:18 pm

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Thu Nov 26, 2020 7:21 pm

I was hoping playing silence would do it but no luck, I can create a silence file at freetts -- even tried 4 seconds. Adding silence at beginning helps but sure would be nice if the problem were addressed by the brainicacs at it's very source. -- hint
major problem for me.

User avatar
dickon
Posts: 1886
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Thu Nov 26, 2020 7:29 pm

Do mplayer or ffplay suffer from the same thing?
As it is apparently board policy to disallow any criticism of anything, as it appears to criticise something is to criticise all the users of that something, I will no longer be commenting in threads which are not directly relevant to my uses of the Pi.

mmkw43
Posts: 705
Joined: Tue Dec 24, 2013 6:18 pm

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Thu Nov 26, 2020 11:50 pm

It's on my list to try them. Which is "leaner"? Do you know? That's what I like about mpg123.
Thanks.

dustnbone
Posts: 465
Joined: Tue Nov 05, 2019 2:49 am

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Fri Nov 27, 2020 2:16 am

They're both pretty tiny, I'd give them a try.

What format is the audio in? If it's uncompressed WAV aplay is another option.

I assume we're dealing with ALSA direct here and not using PulseAudio?

User avatar
scruss
Posts: 3837
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: MPG123 -- first 1 or 2 seconds of audio cut off

Fri Nov 27, 2020 4:47 am

You never confirmed that you tried the options in your other identical thread. Answers don't appear by magic: you're describing a problem that others can't repeat exactly.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “General discussion”