[MPlayer-users] How do you play multiple audio files as a continuous stream?
Corey Hickey
bugfood-ml at fatooh.org
Wed Jul 26 08:26:53 CEST 2006
Richard Bromley wrote:
> On 7/25/06, Corey Hickey <bugfood-ml at fatooh.org> wrote:
>> Why is the ao reinitialization a problem? Do the files you're working
>> with not have silence at the beginning and end?
>
> Yes, and while in theory I could permanently join the files, there is
> no universal way to encode track information in sound container
> formats, so I would have to seek within them manually to start playing
> at the beginning of any of the original segments.
>
>> Anyway, you can work around mplayer's limitation by joining the files
>> before you play them, probably with sox or maybe just with 'mplayer -ao
>> pcm'. If this part gives you trouble, ask me again and I'll dig up how
>> to do it.
>>
>> As long as your computer is fast enough, you should be able to start
>> mplayer right after starting sox. Use some -cache value so the disk I/O
>> doesn't make mplayer hiccup.
>
> So as I understand it, after a quick glance at the sox manpage,
> something like this
>
> $ soxmix 1.mp3 2.mp3 - | mplayer -
>
> should get me what I want by playing back sox's output of the joined
> files. However, just running
>
> $ soxmix 1.mp3 2.mp3 -
>
> for me produces no output. I have also tried this with .wav files.
> Help to get this working would be appreciated.
soxmix mixes the two files, which means you'll hear them both at once.
What you want to do is concatenate them, which regular sox does.
$ sox 1.mp3 2.mp3 - | mplayer -
That still won't work, though, so don't expect the above command to
work. sox silently errors out with an exit status 2, which isn't very
helpful. The problem is, sox determines the output format based on the
output filename you provide. If the filename is -, sox doesn't know if
you want wav, ogg, or what. You can manually specify the format and make
sox happy.
$ sox 1.mp3 2.mp3 -t wav - | mplayer -
...however, now mplayer isn't happy. It wants to seek when opening the
file, but can't do that when reading from stdin, so the above command
will fail too. There might be some way to make that work, but it's
probably not worth it, since you still won't be able to seek when you
want to. As long as you have the disk space, just write a temporary file:
$ sox 1.mp3 2.mp3 out.wav ; mplayer out.wav ; rm out.wav
Now, I've been assuming this whole time that you're going to be joining
files with the same sample rate and format. If they were all made as
part of a matching set, then that is almost certainly the case, but if
they aren't then sox will get mad. Working around that is kind of a
headache, so unless anybody needs me to explain, I'd just as soon leave
that issue alone.
-Corey
More information about the MPlayer-users
mailing list