开发者

How do I copy data from a defective DVD to my hard disk using Perl?

The situation is this: My system (Win XP Pro) is unable to copy a huge video file (around 6 gigs) from a DVD disk, which might be defective, scratched or whatever but which can be played back with mplayer with a few frames full of mosaic though. When the copying process lasted for a certain length of time, the system would abort the effort and give me this warning "A cyclic redundancy check checksum error occurred" . And then everything copied was automatically deleted.

I'm thinking a Perl app might solve the issue. My thought is this: I copy video data one meg at a time. If a reading error ever occurs, I let perl ignore this particular one meg of data and keep copying the rest of the video still one meg at a time.

Incidentally, I've also noticed tha开发者_开发知识库t some commercial software can do the job, but there're limitations in the trials.

The following script is what I've tried so far. It copies data one meg at a time from the defective dvd disk but it fails like Win XP. The only difference is perl doesn't delete what has already been copied. For my case, it copied around 900 megs of video data to my hard disk and this 900 megs part of the video can still be played back with mplayer. But my goal is to copy all that is good, the majority, only leaving all that is bad, the minority.

    use strict;
    use warnings;

    $/ = \1_048_576;  

    open my $in, "<", 'D:\tobecopied.mkv' or die $!;
        binmode $in;
    open my $out, ">", 'E:\copied.mkv' or die $!;
        binmode $out;

    while (<$in>) {
        print $out $_;
    }

The problem is I don't know how to achiev this. Hope someone here can give me a hint or clue. Thanks like always :)


You want ddrescue, no need to reinvent that wheel badly.

readline from your program is not low-level enough, one must use sysread instead where an offset can be specified to pick up after a portion failed reading.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜