5

When playing audio CDs with mplayer, I always get a choppy playback. Playing audio from files, like MP3 (from any optical media, or other drives), etc. works fine. Watching video DVDs is also ok. Listening to uncompressed media that's on my hard drives, like WAV or CDR, works fine as well.

But when playing audio CDs like so:

mplayer cdda://

It spins the CD, plays for a few seconds until the buffer runs out, then it spins the CD again, fills the buffer and the whole procedure repeats. I tried -nocache, that didn't help.

How do I make mplayer keep a constant buffer fill, i.e. read the CD continuously?

polemon
  • 11,133
  • 11
  • 69
  • 111
  • Which library to you use to read the CD, `libcdparanoia` or `libcdio`? – ByteNudger Feb 20 '12 at 19:41
  • @ByteNudger erm, I don't know, I didn't set anything specific, just ran it like I described in my 1st post. – polemon Feb 22 '12 at 00:09
  • I wanted to know against which of these libraries your `mplayer` is compiled. If you didn't compiled `mplayer` from source, you can get this information from the dependencies of the package. – ByteNudger Feb 22 '12 at 10:29
  • 1
    @ByteNudger `libcdda_paranoia.so.0 => /usr/lib64/libcdda_paranoia.so.0 (0x0000003420200000)` I used `ldd`, should be alright. – polemon Feb 26 '12 at 08:52

2 Answers2

4

The problem is the usage of mplayer cdda:// and the libcdparanoia library, because libcdparanoia has it's own caching method. This method bundles about 15 second in one request to read from the CD and that period is long enough that the CD spins down.

There are two options how you can solve this problem:

  1. mplayer which uses the library libcdio
  2. use the option -cache from mplayer with a value that's bigger then the file size you want to read

I know the second option is a bit of workaround, but when you use a package from some distribution, it's not that easy to change the library.

Also found some bug reports with the same problem from Debian and archlinux.

ByteNudger
  • 717
  • 7
  • 20
  • Well, filesize... I want to listen to audio CDs, not files on the CD. I'd have to cache the whole CD in this case. – polemon Feb 26 '12 at 18:55
  • Since I don't feel like compiling mplayer myself, what program would you suggest to use for CDDA playback? – polemon Feb 27 '12 at 04:53
  • 2
    I personally use [VLC](http://www.videolan.org/) and it has also a cli command `cvlc cdda://`, but this is just me ;). There are many other players with GUI or without, just pick one ... – ByteNudger Feb 27 '12 at 21:46
  • I talked to an mplayer developer. He confirmed mplayer only uses libcdparanoia, there is no support for libcdio. He said, that feature is poorly tested, since hardly anyone uses it. – polemon Feb 28 '12 at 23:30
  • 1
    `mplayer2` (http://www.mplayer2.org/) seemed like the best option. I just compiled it, and it plays CD-DA flawlessly! – polemon Mar 14 '12 at 00:10
1

As a follow up to the answer by ByteNudger, since the problem is that CD spins off, a counterintuitive solution/workaround is to actually decrease the cache size so that the OS is forced to read the CD more often thus preventing the spin off, but leaving the cache on, since there is a reason for it to exist. As ridiculous as it sounds, it is working for me:

mplayer -cache 1024 cdda://

The -cache argument is the cache in kilobyte. A CD rate (44.1 kHz, 16 bit stereo) is 176 kB, so 1024 kB is a bit more than 5 seconds, which was less than the spin off time of my CD reader. Since my reader is fairly noisy, I tuned that by ear listening how long it takes to spin off based on its noise.

This is an old question, but I had this exact problem right now with mplayer 1.3.0 (Gentoo Linux). I suppose I could just try bypassing cdparanoia by emergeing with USE='-cdparanoia', but that's distribution-specific.

Hamlet
  • 431
  • 4
  • 4
  • I don't think it's bad practice to add additional or new information to old questions at all. In fact, it's quite interesting to see the issues are still kind of unresolved to this day. It's just that usage of audio CDs has dropped so much, that people simply don't run into those issues anymore. The cache "trick" is actually not a bad one at all. – polemon Nov 11 '19 at 02:06