Opened 4 years ago

Last modified 20 months ago

#12073 new enhancement

VCD playback

Reported by: vidrep Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Audio & Video/Codecs Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All


Haiku currently lacks the ability to playback Video CD format. The VCD standard was created in 1993, and is still produced and sold in Asian countries and regions, such as Mainland China, Taiwan, Hong Kong, Singapore, Malaysia, Thailand, Burma, Indonesia, Philippines, Vietnam, India, Pakistan and Bangladesh.

Change History (3)

comment:1 Changed 2 years ago by pulkomandy

Can you provide a sample file (or disc image)?

comment:2 Changed 20 months ago by pulkomandy

So, it seems this format is not handled by ffmpeg. However, it is not too hard to convert the files. For example I found

Basically, the VCD sample I was given has "DAT" files, which are RIFF header followed by a short format ("fmt ") chunk and then a large "data" chunk. The data chunk has some padding at the start and end, and the remaining parts are actually a plain mpeg file.

So basically:

  • Parse the RIFF header (should be of type CDXA) to find the "data" chunk
  • Read the chunk contents, 2324 bytes at a time (this is because Video-CD have no error correction, hence the sector size is 2324 instead of the usual 2048 bytes)
  • Skip sectors which are filled with 00 bytes
  • Get the remaining data, which is an MPEG file that ffmpeg can decode just fine.

This will allow us to play a rip of a VCD. To play an actual VCD, we also need to handle these 2324 bytes sectors, which I'm not sure our iso9660 filesystem and ATAPI stack are able to.

I also don't know how we can integrate this with the media kit decoding framework. Does it support nested containers, so that we could write a plugin to just skip the RIFF header, and then the remaining parts would be fed to ffmpeg/libavformat?

comment:3 Changed 20 months ago by vidrep

I got this from the mplayer website, in case it helps:

3.6. VCD playback For the complete list of available options, please read the man page. The Syntax for a standard Video CD (VCD) is as follows: mplayer vcd://<track> [-cdrom-device <device>] Example: mplayer vcd://2 -cdrom-device /dev/hdc The default VCD device is /dev/cdrom. If your setup differs, make a symlink or specify the correct device on the command line with the -cdrom-device option. Note At least Plextor and some Toshiba SCSI CD-ROM drives have horrible performance reading VCDs. This is because the CDROMREADRAW ioctl is not fully implemented for these drives. If you have some knowledge of SCSI programming, please help us implement generic SCSI support for VCDs. In the meantime you can extract data from VCDs with readvcd and play the resulting file with MPlayer. VCD structure.  A Video CD (VCD) is made up of CD-ROM XA sectors, i.e. CD-ROM mode 2 form 1 and 2 tracks: The first track is in mode 2 form 2 format which means it uses L2 error correction. The track contains an ISO-9660 file system with 2048 bytes/sector. This file system contains VCD metadata information, as well as still frames often used in menus. MPEG segments for menus can also be stored in this first track, but the MPEGs have to be broken up into a series of 150-sector chunks. The ISO-9660 file system may contain other files or programs that are not essential for VCD operation. The second and remaining tracks are generally raw 2324 bytes/sector MPEG (movie) tracks, containing one MPEG PS data packet per sector. These are in mode 2 form 1 format, so they store more data per sector at the loss of some error correction. It is also legal to have CD-DA tracks in a VCD after the first track as well. On some operating systems there is some trickery that goes on to make these non-ISO-9660 tracks appear in a file system. On other operating systems like GNU/Linux this is not the case (yet). Here the MPEG data cannot be mounted. As most movies are inside this kind of track, you should try vcd://2 first. There exist VCD disks without the first track (single track and no file system at all). They are still playable, but cannot be mounted. The definition of the Video CD standard is called the Philips "White Book" and it is not generally available online as it must be purchased from Philips. More detailed information about Video CDs can be found in the vcdimager documentation.

About .DAT files.  The ~600 MB file visible on the first track of the mounted VCD is not a real file! It is a so called ISO gateway, created to allow Windows to handle such tracks (Windows does not allow raw device access to applications at all). Under Linux you cannot copy or play such files (they contain garbage). Under Windows it is possible as its iso9660 driver emulates the raw reading of tracks in this file. To play a .DAT file you need the kernel driver which can be found in the Linux version of PowerDVD. It has a modified iso9660 file system (vcdfs/isofs-2.4.X.o) driver, which is able to emulate the raw tracks through this shadow .DAT file. If you mount the disc using their driver, you can copy and even play .DAT files with MPlayer. But it will not work with the standard iso9660 driver of the Linux kernel! Use vcd:// instead. Alternatives for VCD copying are the new cdfs kernel driver (not part of the official kernel) that shows CD sessions as image files and cdrdao, a bit-by-bit CD grabbing/copying application.

Note: See TracTickets for help on using tickets.