Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
dd fails to read DVD until after it has been played in VLC
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Sipos
Tux's lil' helper
Tux's lil' helper


Joined: 10 Sep 2004
Posts: 121
Location: London

PostPosted: Mon Sep 19, 2011 4:30 pm    Post subject: dd fails to read DVD until after it has been played in VLC Reply with quote

I'm encountering some strange behaviour from dd that, while it isn't really causing me much of a problem, I am puzzled as to why it happens.

I am making an image of a DVD video, on my hard disk, using dd (I'm running dd if=/dev/sr0 of=dvdImage.iso). If I try this for any disk I have just inserted, it fails with the following error:
Code:
dd: reading `/dev/sr0': Input/output error
after copying some data.

This happens whether or not the disk is mounted. The amount of data copied before the error is the same for the same disc but, different between different discs. If I simply try again, it fails after the same amount of data is copied.

If I play the DVD for a few seconds in VLC. The above works with no errors. I can make the image while the film is paused or, exit VLC but, something about having played it already seems to make it work.

Ejecting the DVD and re-inserting it makes it fail again. I need to play it in VLC again to make it work.

I have no idea why this is happening. Anybody got any ideas?
Back to top
View user's profile Send private message
mingdao
n00b
n00b


Joined: 19 Sep 2011
Posts: 10
Location: Alabama, USA

PostPosted: Mon Sep 19, 2011 5:00 pm    Post subject: Reply with quote

FWIW my system works fine with that command. This is the output
after running it for ~10 seconds then stopping with "Ctrl+C":
Code:
silas iso # dd if=/dev/sr0 of=FLO.iso
^C89313+0 records in
89312+0 records out
45727744 bytes (46 MB) copied, 13.7374 s, 3.3 MB/s

silas iso # ls -lh
total 7.8G
<snip>
-rw-r--r-- 1 root    root     44M Sep 19 11:37 FLO.iso
<snip>

Running sys-apps/coreutils-8.7 on amd64

I did nothing more than open my drive with "eject -T"; insert the DVD;
close the drive with "eject -T" then issue the dd command.

NB: I much prefer dcfldd to dd and always use it instead.
_________________
Are the things you're living for worth Christ dying for?
~ Leonard Ravenhill
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Mon Sep 19, 2011 6:12 pm    Post subject: Reply with quote

Sipos,

Many dvds cannot be copied with dd nor by mounting the filesystem and copying the files.
The problem is that DVDs are made with deliberately corrupt data blocks, so you get I/O errors.

These deliberately corrupt data blocks do not interfere with DVD players and your enjoyment of the film as they are never read by DVD players.
Instead, DVDs are played by reference to a block list.

A DVD player operates by reading a list of blocks on the DVD which provides the list of blocks to be played and the order to play them in.
Trying to make an image of a DVD is a lost cause. This is why DVDs are not normally mounted to play the video - the file system is not used.

Code:
mplayer -dvd-device /dev/sr0 dvd://1 -dumpstream -dumpfile <file>
will dump the first title from /dev/sr0 to <file>
Thats often but not always the main content of the DVD.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Gusar
Advocate
Advocate


Joined: 09 Apr 2005
Posts: 2665
Location: Slovenia

PostPosted: Mon Sep 19, 2011 6:30 pm    Post subject: Reply with quote

That command often won't work, you need to use dvdnav://1

The reason is intentionally physically corrupt sectors on the disk. The parts of the disc which contain dvdnav info also contain a list of which sectors those are, so a player can skip them.

Maybe using ddrescue instead of dd would work, but there's no guarantee such an image will work correctly. You can give it a try though, and report.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Mon Sep 19, 2011 7:33 pm    Post subject: Reply with quote

Gusar,

ddrescue will be very slow and never terminate as it can't read the corrupt sectors.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Gusar
Advocate
Advocate


Joined: 09 Apr 2005
Posts: 2665
Location: Slovenia

PostPosted: Mon Sep 19, 2011 7:41 pm    Post subject: Reply with quote

Shouldn't ddrescue skip the corrupt sectors and put zeros in that place in the resulting image?

That's the problem we have now - apps, including mplayer, hang while trying to read a corrupt sector. If ddrescue can't get around that, what benefit does it bring then over the plain dd?
Back to top
View user's profile Send private message
Sipos
Tux's lil' helper
Tux's lil' helper


Joined: 10 Sep 2004
Posts: 121
Location: London

PostPosted: Mon Sep 19, 2011 9:14 pm    Post subject: Reply with quote

I think that the discs I was asking about don't have intentionally bad sectors. As I said, I can copy them fine with dd after I have played them once. There are no errors and the resulting images seem to work fine. I can also mount them, copy the files with cp and play them. If they had some bad sectors, surely dd and cp should still fail to copy them, whether or not I played them once with VLC first? How would playing them with VLC affect dd? This is what I am confused about.

As it happens, I do have another DVD that does seem to have intentionally bad sectors and, your replies have helped me dump a stream from that using
Code:
mplayer dvdnav://46 -dumpstream -dumpfile file.dump
(I don't seem to need to specify the DVD device because there is a symlink from /dev/dvd). I had no way of backing up this disc before so thanks a lot, that's a huge help! :D

I do need to use dvdnav://, dvd:// just hangs.

I think Neddy is right, making an image of these DVDs with bad sectors is a lost cause. I have tried this in the past but gave up. I tried
Code:
dd conv=noerror if=/dev/dvd of=image.iso
but, there are thousands of IO errors and it takes infeasibly long (only a few MB overnight). I also tried ddrescue. I think that, in theory, ddrescue should eventually find all the bad sectors and extract the usable ones into an image but, it also takes forever so, I gave up on that too. I guess that making a true image of DVDs like this would have to involve figuring out which sectors are bad from the data the player reads.

Interestingly, they also seem to have deliberately screwed up the file-system on the disc. There are no obvious problems with it except that the total file size is 54GB, despite being a 8.54GB capacity disc. They have also done something screwey with the titles on the disc too. There are 99 titles and, apart from a few containing trailers etc, they are all copies of most of the film, all with slightly different offsets. Since the disc doesn't have enough capacity to contain that many separate copies, they must all really be of the same data. Playing it with VLC using menus, clicking 'play movie' from the main menu causes VLC to play title 46 which seems to be the complete film.

Edit: Also, playing any of the titles in VLC, without using the menus seems to cause the sound to be offset from the video. Using dvdnav:// with mplayer plays them fine though.


Last edited by Sipos on Mon Sep 19, 2011 9:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Mon Sep 19, 2011 9:20 pm    Post subject: Reply with quote

Gusar,

ddrescue will only exit when it has read the entire filesystem without errors. It does not so much ship the corrupt blocks as come back to them later.
It tries very hard to read defective blocks, by stepping the read head in from both sides, by reading bigger/smaller 'chunks' and always fails as the sectors are corrupt be design.

You need to stop it manually.

mplayer (or any other DVD player) will never attempt to read the corrupt blocks as it uses the same approach that all DVD players do to avoid them.
It fetches the useful data only by following the block list(s).
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Mon Sep 19, 2011 9:27 pm    Post subject: Reply with quote

Sipos,

DVD drives come in two flavours. Old ones are RPC1 recent ones (the last 10 years) are RPC2.

A RPC1 drive will always give raw access to the DVD. I still have one of those somewhere.
A RPC2 drive will only allow raw access after the region code has been verified.

cp and dd will not carry out region code negiotiation but a DVD player will.
So vlc or whatever, does the region code check then the drive allows dd raw block level access.

Note that if you have a region code mismatch between the drive and DVD, you won't get raw access and cannot play the video.
Thats the theory anyway.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Sipos
Tux's lil' helper
Tux's lil' helper


Joined: 10 Sep 2004
Posts: 121
Location: London

PostPosted: Mon Sep 19, 2011 9:38 pm    Post subject: Reply with quote

NeddySeagoon wrote:
ddrescue will only exit when it has read the entire filesystem without errors. It does not so much ship the corrupt blocks as come back to them later.
It tries very hard to read defective blocks, by stepping the read head in from both sides, by reading bigger/smaller 'chunks' and always fails as the sectors are corrupt be design.


I think there are various options to stop after a set number of retries or only split blocks to a certain level.

I was under the impression though, that ddrescue started by trying to copy large portions of the disc. If any of these failed, it tries to split them into smaller chuncks. The idea is that you get a lot of data quickly because most of the disc is good and, by continuing, the bad parts are cut into smaller and smaller chuncks and more good parts are found. I thought that, once it can't divide them any more it finally marks the parts it couldn't read anything from as bad. Reading the log file, this is how it seems to work. The manual seems to indicate to me that it will eventually terminate and decide it is finished even if there are still unreadable sections of the disk because it explains how you can use another copy of the disc to try to recover these.

In any case, with a disc like this, with thousands of small bad regions (single bad sectors?) it just keeps going, dividing the sections of the disc with errors into smaller and smaller, good and bad parts but, because there are so many errors, it is just finding that each bad section is in fact composed of some good and some bad sections. It is still going to take forever to find all the bad sectors so, this isn't a practicals way to do this. I think Neddy is right that this is a lost cause. It's not clear to me why it is any better than using
Code:
dd conv=noerror ...
for a disc like this where you don't expect the bad regions to be grouped up in a few parts of the disc.
Back to top
View user's profile Send private message
Sipos
Tux's lil' helper
Tux's lil' helper


Joined: 10 Sep 2004
Posts: 121
Location: London

PostPosted: Mon Sep 19, 2011 9:45 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Sipos,

DVD drives come in two flavours. Old ones are RPC1 recent ones (the last 10 years) are RPC2.

A RPC1 drive will always give raw access to the DVD. I still have one of those somewhere.
A RPC2 drive will only allow raw access after the region code has been verified.

cp and dd will not carry out region code negiotiation but a DVD player will.
So vlc or whatever, does the region code check then the drive allows dd raw block level access.

Note that if you have a region code mismatch between the drive and DVD, you won't get raw access and cannot play the video.
Thats the theory anyway.


Sorry, I missed this post while writing my previous one. That explains my original question. Thanks!
Back to top
View user's profile Send private message
Sipos
Tux's lil' helper
Tux's lil' helper


Joined: 10 Sep 2004
Posts: 121
Location: London

PostPosted: Mon Oct 10, 2011 8:37 pm    Post subject: Reply with quote

Do either of you know of a program I can use that will just make sure that the region lock stuff is done and a disc is readable properly?

Obviously, I can try playing in mplayer but, ideally, I'd like something that will exit with a non-zero exit code only if there is a problem with the region (for example if I used a disc with a region not supported by my drive).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum