[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to seamlessly play audio clip

On Sat 08 Feb 2020 at 07:38:10 (+0000), Long Wind wrote:
> On Saturday, February 8, 2020, 10:51:14 AM GMT+8, David Wright <deblis@lionunicorn.co.uk> wrote:  
> > On Fri 07 Feb 2020 at 23:53:06 (+0000), Long Wind wrote:
> > > i use mplayer -loop 0 to play white noise(it might help sleep by masking other noise)
> > > but when it reach end and restart to play againthere's some interval, which isn't desirable
> > > any mplayer option or other player i can use so that it plays seamlessly??
> > 
> > You might try mpv instead. It displays the timings at the bottom of
> > the picture, and they stay on screen if you leave the mouse there
> > (otherwise it times out and disappears).
> > 
> > But you can set looping points interactively. Play the video, then
> > press l where you want looping to loop back to (ie the start of
> > section), and again at the end of the section.
> > 
> > mpv also has a configuration parameter for sound files, particularly
> > useful for classical music:
> > 
> > # Music tracks often segue
> > gapless-audio=yes
> Thanks! i've tried mpv with --gapless-audio=yesthe result is somewhat similar to mplayer
> mpv is based on mplayer

Odd, that. I can duplicate your mplayer problem: I generated some
test files of pink noise, a sine wave, and a snippet from an
organ recording's prolonged final chord.

$ sox -n /tmp/pink.wav synth 2 pinknoise
$ lame -b 128 /tmp/pink.wav /tmp/pink.mp3 2> /dev/null

With both wav and mp3 files, the break can be heard clearly using

$ mplayer -noconfig all -loop 0 /tmp/pink.wav
$ mplayer -noconfig all -loop 0 /tmp/pink.mp3

However, I can detect nothing untoward using

$ mpv --no-config --loop=inf /tmp/pink.wav
$ mpv --no-config --loop=inf /tmp/pink.mp3

with all three waveforms.

What emerges on the console seems to indicate that, on looping,
mplayer restarts from scratch, even determining what sort of
file is about to be read (again), whereas mpv just goes back to
the start of the file. (strace could probably confirm this.)

I didn't bother with gapless-audio. It might only be important when
different input files are being processed, rather than looping the
one file.

But also note that these are short files, where everything can
obviously be in held memory. Behaviour may differ with longer ones.

For *noise options, it obviously makes sense to use the posted
solution, and not use files at all.


Reply to: