I finally found time to have a look at this bug, trying to figure out
why this set of DVDs were rejected by the dvdvideo-backup-image tool.
My test case now was a DVD from 2009, where these are the files shown
after mounting:

/dvd/:
total 2.0K
dr-xr-xr-x 2 nobody nogroup 768 Mar 16  2001 VIDEO_TS

/dvd/VIDEO_TS:
total 4.2G
-r--r--r-- 1 nobody nogroup  12K Mar 16  2001 VIDEO_TS.BUP
-r--r--r-- 1 nobody nogroup  12K Mar 16  2001 VIDEO_TS.IFO
-r--r--r-- 1 nobody nogroup 868K Mar 16  2001 VIDEO_TS.VOB
-r--r--r-- 1 nobody nogroup  70K Mar 16  2001 VTS_01_0.BUP
-r--r--r-- 1 nobody nogroup  70K Mar 16  2001 VTS_01_0.IFO
-r--r--r-- 1 nobody nogroup 7.7M Mar 16  2001 VTS_01_0.VOB
-r--r--r-- 1 nobody nogroup 1.0G Mar 16  2001 VTS_01_1.VOB
-r--r--r-- 1 nobody nogroup 1.0G Mar 16  2001 VTS_01_2.VOB
-r--r--r-- 1 nobody nogroup 1.0G Mar 16  2001 VTS_01_3.VOB
-r--r--r-- 1 nobody nogroup 708M Mar 16  2001 VTS_01_4.VOB
-r--r--r-- 1 nobody nogroup  20K Mar 16  2001 VTS_02_0.BUP
-r--r--r-- 1 nobody nogroup  20K Mar 16  2001 VTS_02_0.IFO
-r--r--r-- 1 nobody nogroup    0 Mar 16  2001 VTS_02_0.VOB
-r--r--r-- 1 nobody nogroup 448M Mar 16  2001 VTS_02_1.VOB

If I understand the code in question, it is trying to locate the last
block of the VTS_02_0.VOB file, which fail because its size is zero and
the file has no blocks on the DVD.  As the VTS_02_1.VOB file seem next
in line and more promising, I changed the code to fall back to *_1.VOB
if *_0.VOB had no blocks.  Is this a sensible approach?  With the
following patch, I am able to back up the DVD in question.

diff --git a/dvdvideo/volume.py b/dvdvideo/volume.py
index 17a3c5e..ce881d6 100644
--- a/dvdvideo/volume.py
+++ b/dvdvideo/volume.py
@@ -55,6 +55,9 @@ class VtsUdf:
             raise MalformedVolumePartError('Missing file %s' % e.args[0])
 
         file_menu_vob = media.get('%s_0.VOB' % prefix)
+        # If the first file is empty, try the next file
+        if 0 == len(file_menu_vob.entry.ad):
+            file_menu_vob = media.get('%s_1.VOB' % prefix)
 
         file_title_vob = []
         for i in range(1, 10):

The index out of range problem come from trying to extract ad[0] when ad
is the empty set aka (), which I assume is because the file have no
blocks.

I've seen this problem on several DVDs, and this patch seem to solve the
problem for all of them.  I have very limited understanding of the DVD
specification, so I do not know if the change is according to it.

Sharing the patch here in case others want to use it.  I've sent the
patch upstream already, but do not know if the project is still being
maintained there.

-- 
Happy hacking
Petter Reinholdtsen

Reply via email to