Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Multimedia
  • Search

How do I copy a data track from a multi session cd? [solved]

Help with creation, editing, or playback of sounds, images, or video. Amarok, audacious, mplayer, grip, cdparanoia and anything else that makes a sound or plays a video.
Post Reply
Advanced search
6 posts • Page 1 of 1
Author
Message
Atle
Apprentice
Apprentice
Posts: 179
Joined: Thu Sep 16, 2004 1:32 pm

How do I copy a data track from a multi session cd? [solved]

  • Quote

Post by Atle » Tue Apr 19, 2011 10:10 pm

Consider a CD like this:

Code: Select all

$ cd-info --no-device-info
cd-info version 0.80 x86_64-pc-linux-gnu
Copyright (c) 2003, 2004, 2005, 2007, 2008 R. Bernstein
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
CD location   : /dev/scd0
CD driver name: GNU/Linux
   access mode: ioctl

__________________________________

Disc mode is listed as: CD-DA
CD-ROM Track List (1 - 15)
  #: MSF       LSN    Type   Green? Copy? Channels Premphasis?
  1: 00:02:00  000000 audio  false  no    2        no
  2: 05:03:27  022602 audio  false  no    2        no
  3: 08:50:07  039607 audio  false  no    2        no
  4: 13:23:35  060110 audio  false  no    2        no
  5: 16:33:17  074342 audio  false  no    2        no
  6: 21:23:55  096130 audio  false  no    2        no
  7: 26:53:55  120880 audio  false  no    2        no
  8: 31:11:42  140217 audio  false  no    2        no
  9: 34:08:07  153457 audio  false  no    2        no
 10: 39:11:42  176217 audio  false  no    2        no
 11: 42:52:30  192780 audio  false  no    2        no
 12: 47:09:57  212082 audio  false  no    2        no
 13: 51:59:37  233812 audio  false  no    2        no
 14: 57:00:52  256402 audio  false  no    2        no
 15: 65:10:67  293167 data   false  no   
170: 66:39:25  299800 leadout (672 MB raw, 672 MB formatted)
Media Catalog Number (MCN): 0000000000000
Last CD Session LSN: 293167
audio status: no status
 can't get volume levels
__________________________________
CD Analysis Report
session #2 starts at track 15, LSN: 293167, ISO 9660 blocks: 299648
ISO 9660: 299648 blocks, label `OMEGA                           '
As can be seen, track 15 is data, and part of session 2.

What I want is to copy this into two separate files, one for the audio and one for the data.

Audio is easy enough with several utilities, for example cdparanoia. But I'm struggling with the data part.

My first question is, what utility can I use to copy this track to a separate file?

cdrdao can copy the whole CD to a binary, and using bin2iso I can make wav files and an iso file. However this is more cumbersome than what I want. I'd like to just simply extract the data part as an iso. cdrdao has a --session argument, but this does not seem to work. Using --session 2 (or any other number) only gives session 1.

Over to question two. I've managed to extract one as mentioned above, and also with k3b. But I cannot mount them using loop devices and iso9660 as usual. What's wrong with iso files extracted from multi session CDs like this?
Last edited by Atle on Wed Apr 20, 2011 8:08 pm, edited 1 time in total.
Top
BradN
Advocate
Advocate
User avatar
Posts: 2391
Joined: Fri Apr 19, 2002 2:48 am
Location: Wisconsin (USA)

  • Quote

Post by BradN » Tue Apr 19, 2011 11:28 pm

Background:

The ISO filesystem has to actually be constructed with the knowledge of its start sector positioning on the disc - in other words, it doesn't work the same as partitions on a hard drive - more like a single file system that might have its file descriptors moved around and random audio tracks mixed in.

This is actually how multi-session data CDs are possible - the last track can refer to previous tracks, but the implementation that allows this doesn't use negative sectors to refer back to previous sessions (they could have, but it's too late now), but rather by placing the first session at the first sector, causing the whole mess. But hey, it saves a subtraction operation in whatever controller code seeks on the disc...


Hard solution:

The problem is the resulting ISO you've extracted doesn't start at the first sector. I think the easiest solution is to make it into a sparse file (logically filled with zeros up until the start point, but using a linux filesystem feature to not actually store the zeros).

Example for creating a sparse file:
http://prefetch.net/blog/index.php/2009 ... s-with-dd/

So once you figure out the amount of padding you need (Remember that CDROM block/sector size is 2KB, not 1KB!) and make the padding file, and you have the data contents of the iso, you can just append it to the end:
cat mydata.iso >> padding.dat
mv padding.dat mypaddeddata.iso

Then to mount it you will probably have to use the...

Code: Select all

sbsector=xxx
              Session begins from sector xxx. (Since 2.3.4.)
... option to specify where the actual data starts. Fun, huh?


--- OR ---

You could extract the data files and re-master an ISO that doesn't need the padding. No guarantee this will work with various copy protection schemes, but it's probably good enough. Or just put the data files in a .rar or .tar.bz2 or whatever.
Top
Atle
Apprentice
Apprentice
Posts: 179
Joined: Thu Sep 16, 2004 1:32 pm

  • Quote

Post by Atle » Wed Apr 20, 2011 10:24 am

Thanks for intereseting information, Brad. I'll figure out how to mount those things. In principle there should be a way to mount them with some offset information. :)

I still am looking for a way to extract the data parts directly, though. Anyone knows the right tool? Am I just using cdrdao wrong? K3b seems to be able to do it, but I'd like a direct CLI command if possible.
Top
BradN
Advocate
Advocate
User avatar
Posts: 2391
Joined: Fri Apr 19, 2002 2:48 am
Location: Wisconsin (USA)

  • Quote

Post by BradN » Wed Apr 20, 2011 5:14 pm

Have you tried dd with seek or skip (whichever affects input, I forget)?

It might be tricky to automate it without manually copying the sector number and size, but then again I was never a shell scripting wizard.

Also, it's possible to specify an offset into the image file with losetup (for creating a loop device) that's useful to access partitions within a disk image, but it doesn't allow specifying an offset into the block device it makes that would be good for mounting ISO images of non-first sessions. Really something for this should be added either there or in the iso9660 driver.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Wed Apr 20, 2011 6:13 pm

Atle,

You can get the audio conventionally with an audio ripper.
Try the -o session= option to mount to get the data session. I have a feeling that sessions are counted from 0 so try both 1 and 2.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
Atle
Apprentice
Apprentice
Posts: 179
Joined: Thu Sep 16, 2004 1:32 pm

  • Quote

Post by Atle » Wed Apr 20, 2011 7:31 pm

I've had some progress.

Using cd-read (dev-libs/libcdio) I've extracted raw sector data, and using readcd (app-cdr/cdrtools) I've extracted iso.

Referring to a different CD than above:

Code: Select all

#: MSF       LSN    Type   Green? Copy? Channels Premphasis?
  1: 00:02:00  000000 audio  true   yes   2        no
  2: 03:54:56  017456 audio  false  no    2        no
  3: 07:43:25  034600 audio  true   yes   2        no
  4: 15:05:05  067730 audio  true   yes   2        no
  5: 20:55:38  094013 audio  true   yes   2        no
  6: 29:32:08  132758 audio  false  no    2        no
  7: 34:44:08  156158 audio  false  no    2        no
  8: 39:48:43  178993 audio  true   yes   2        no
  9: 48:16:48  217098 audio  false  no    2        no
 10: 54:47:53  246428 audio  false  no    2        no
 11: 60:58:10  274210 audio  true   yes   2        no
 12: 70:37:08  317633 data   false  no   
170: 79:55:00  359475 leadout (806 MB raw, 806 MB formatted)
Based on above, the commands are:

Code: Select all

cd-read -s 317633 -e 359474 -C /dev/sr0 -m m2f1 -o cd-read-track12-m2f1.raw
readcd sectors=317633-359475 f=readcd-track12.iso
And the result:

Code: Select all

$ ls -l cd-read-track12-m2f1.raw readcd-track12.iso
-rw-r--r-- 1 atle users 97240808 Apr 20 15:24 cd-read-track12-m2f1.raw
-rw-r--r-- 1 atle users 85692416 Apr 20 21:08 readcd-track12.iso
Using readcd is much easier, and the latter is identical to iso file produced by k3b. Note that the cd-read result is bigger. Instead of 2048 bytes data * 41842 sectors = 85692416, there is 2324 bytes per sector, which includes error checking and more. (http://en.wikipedia.org/wiki/CD-ROM_XA, http://en.wikipedia.org/wiki/CD-ROM) I've not tried to extract iso from this.

To mount the iso I used Brad's tips about sparse files:

Code: Select all

dd if=/dev/zero of=track12.iso count=0 bs=2048 seek=317633
cat readcd-track12.iso>>track12.iso
mkdir /tmp/iso
mount -t iso9660 -o loop,ro,sbsector=317633 track12.iso /tmp/iso/
Next step is producing cue file of combined cdparanoia rip and readcd iso, and burning an "identical" copy from flac and iso.
Top
Post Reply

6 posts • Page 1 of 1

Return to “Multimedia”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic