Package: dvdbackup Version: 0.1.1-3 Severity: normal Tags: patch When I do a backup from chapters using: dvdbackup -i /dev/dvd -o . -n dvd1 -t 1 -s 1 -e 10
and one of the chapters comes from two vobs, then there's a "back jump" in the chapter and the end of the chapter is missing. For example chapter 7 starts at 20:00 and ends at 30:00 in source dvd, the output contains this chapter from 20:00-27:30 and 26:00-28:30. Dvdauthor fails with "SCR moves backwards" when I try cat *.VOB | dvdauthor -o dvd - The problem is in DVDWriteCells function, when leftover>0. In the first turn sectors are read using soffset variable (until the end of the vob), then in the 2nd turn offset is used for the same thing (from the beginning of the next vob). At the end of the first turn soffset is greater then offset. I've completly rewritten this function making it more simple. Here's my patch: diff -Naur dvdbackup-0.1.1.orig/src/dvdbackup.c dvdbackup-0.1.1/src/dvdbackup.c --- dvdbackup-0.1.1.orig/src/dvdbackup.c 2005-12-11 08:32:33.000000000 +0000 +++ dvdbackup-0.1.1/src/dvdbackup.c 2005-12-11 08:40:06.000000000 +0000 @@ -298,11 +298,10 @@ /* Loop variables */ - int i, f; - + int i; /* Vob control */ - int vob; + int vob = 1; /* Temp filename,dirname */ char targetname[PATH_MAX]; @@ -316,17 +315,15 @@ int size; int left; - int leftover; + int vobsize = 524288; /* Buffer size in DVD sectors */ /* Currently set to 1MB */ int buff = 512; - int tsize; /* Offsets */ int soffset; - int offset; /* DVD handler */ @@ -334,236 +331,133 @@ int title_set; int number_of_vob_files; - + #ifdef DEBUG fprintf(stderr,"DVDWriteCells: length is %d\n", length); - #endif title_set = titles_info->titles[titles - 1].title_set; number_of_vob_files = title_set_info->title_set[title_set].number_of_vob_files; #ifdef DEBUG - fprintf(stderr,"DVDWriteCells: title set is %d\n", title_set); - fprintf(stderr,"DVDWriteCells: vob files are %d\n", number_of_vob_files); - + fprintf(stderr,"DVDWriteCells: title set is %d\n", title_set); + fprintf(stderr,"DVDWriteCells: vob files are %d\n", number_of_vob_files); #endif - - /* Remove all old files silently if they exists */ for ( i = 0 ; i < 10 ; i++ ) { sprintf(targetname,"%s/%s/VIDEO_TS/VTS_%02i_%i.VOB",targetdir, title_name, title_set, i + 1); #ifdef DEBUG fprintf(stderr,"DVDWriteCells: file is %s\n", targetname); - #endif - unlink( targetname); - } - - - /* Loop through all sectors and find the right vob */ - for (f = 0; f < length ; f++) { - - soffset=0; - offset=0; - - - /* Now figure which vob we will use and write to that vob and if there is a left over write to the next vob*/ - - for ( i = 0; i < number_of_vob_files ; i++ ) { - - - tsize = title_set_info->title_set[title_set].size_vob[i]; - - if (tsize%2048 != 0) { - fprintf(stderr, "The Title VOB number %d of title set %d doesn't have a valid DVD size\n", i + 1, title_set); - return(1); - } else { - soffset = offset; - offset = offset + tsize/2048; - } -#ifdef DEBUG - fprintf(stderr,"DVDWriteCells: soffset is %d\n", soffset); - fprintf(stderr,"DVDWriteCells: offset is %d\n", offset); -#endif - /* Find out if this is the right vob */ - if( soffset <= cell_start_sector[f] && offset > cell_start_sector[f] ) { #ifdef DEBUG - fprintf(stderr,"DVDWriteCells: got it \n"); -#endif - leftover=0; - soffset = cell_start_sector[f]; - if ( cell_end_sector[f] > offset ) { - leftover = cell_end_sector[f] - offset + 1; - } else { - size = cell_end_sector[f] - cell_start_sector[f] + 1; - } -#ifdef DEBUG - fprintf(stderr,"DVDWriteCells: size is %d\n", size); + for (i = 0; i < number_of_vob_files ; i++) { + fprintf(stderr,"vob %i size: %d\n", i + 1, title_set_info->title_set[title_set].size_vob[i]); + } #endif - vob = i + 1; - break; - } - } + /* Create VTS_XX_X.VOB */ + if (title_set == 0) { + fprintf(stderr,"Don't try to copy chapters from the VMG domain; there aren't any\n"); + return(1); + } else { + sprintf(targetname,"%s/%s/VIDEO_TS/VTS_%02i_%i.VOB",targetdir, title_name, title_set, vob); + } + #ifdef DEBUG - fprintf(stderr,"DVDWriteCells: Writing soffset is %d and leftover is %d\n", soffset, leftover); + fprintf(stderr,"DVDWriteCells: 1\n"); #endif - - - - /* Create VTS_XX_X.VOB */ - if (title_set == 0) { - fprintf(stderr,"Don't try to copy chapters from the VMG domain; there aren't any\n"); - return(1); - } else { - sprintf(targetname,"%s/%s/VIDEO_TS/VTS_%02i_%i.VOB",targetdir, title_name, title_set, vob); - } + if ((buffer = (unsigned char *)malloc(buff * 2048 * sizeof(unsigned char))) == NULL) { + fprintf(stderr, "Out of memory copying %s\n", targetname); + return(1); + } #ifdef DEBUG - fprintf(stderr,"DVDWriteCells: 1\n"); + fprintf(stderr,"DVDWriteCells: 2\n"); #endif - if ((buffer = (unsigned char *)malloc(buff * 2048 * sizeof(unsigned char))) == NULL) { - fprintf(stderr, "Out of memory copying %s\n", targetname); - return(1); - } + if ((streamout = open(targetname, O_WRONLY | O_CREAT | O_APPEND, 0644)) == -1) { + fprintf(stderr, "Error creating %s\n", targetname); + perror(""); + return(1); + } #ifdef DEBUG - fprintf(stderr,"DVDWriteCells: 2\n"); + fprintf(stderr,"DVDWriteCells: 3\n"); #endif - if ((streamout = open(targetname, O_WRONLY | O_CREAT | O_APPEND, 0644)) == -1) { - fprintf(stderr, "Error creating %s\n", targetname); - perror(""); - return(1); - } + if ((dvd_file = DVDOpenFile(dvd, title_set, DVD_READ_TITLE_VOBS))== 0) { + fprintf(stderr, "Failed opening TITLE VOB\n"); + free(buffer); + close(streamout); + return(1); + } + + size = 0; + left = cell_end_sector[length-1] - cell_start_sector[0] + 1; + soffset = cell_start_sector[0]; #ifdef DEBUG - fprintf(stderr,"DVDWriteCells: 3\n"); + fprintf(stderr,"DVDWriteCells: left is %d\n", left); #endif + while( left > 0 ) { - if ((dvd_file = DVDOpenFile(dvd, title_set, DVD_READ_TITLE_VOBS))== 0) { - fprintf(stderr, "Failed opening TITLE VOB\n"); + if (buff > left) { + buff = left; + } + if ( DVDReadBlocks(dvd_file,soffset,buff, buffer) != buff) { + fprintf(stderr, "Error reading MENU VOB\n"); free(buffer); + DVDCloseFile(dvd_file); close(streamout); return(1); } - left = size; - + if (write(streamout,buffer,buff * 2048) != buff * 2048) { + fprintf(stderr, "Error writing TITLE VOB\n"); + free(buffer); + close(streamout); + return(1); + } #ifdef DEBUG - fprintf(stderr,"DVDWriteCells: left is %d\n", left); + fprintf(stderr,"Current soffset changed from %i to ",soffset); #endif - - while( left > 0 ) { - - if (buff > left) { - buff = left; - } - if ( DVDReadBlocks(dvd_file,soffset,buff, buffer) != buff) { - fprintf(stderr, "Error reading MENU VOB\n"); - free(buffer); - DVDCloseFile(dvd_file); - close(streamout); - return(1); - } - - - if (write(streamout,buffer,buff * 2048) != buff * 2048) { - fprintf(stderr, "Error writing TITLE VOB\n"); - free(buffer); - close(streamout); - return(1); - } - - soffset = soffset + buff; - left = left - buff; - + soffset = soffset + buff; + left = left - buff; + size = size + buff; + if ((size >= vobsize) && (left > 0)) { +#ifdef DEBUG + fprintf(stderr,"size: %i, vobsize: %i\n ",size, vobsize); +#endif + close(streamout); + vob = vob + 1; + size = 0; + sprintf(targetname,"%s/%s/VIDEO_TS/VTS_%02i_%i.VOB",targetdir, title_name, title_set, vob); + if ((streamout = open(targetname, O_WRONLY | O_CREAT | O_APPEND, 0644)) == -1) { + fprintf(stderr, "Error creating %s\n", targetname); + perror(""); + return(1); + } } +#ifdef DEBUG + fprintf(stderr,"%i\n",soffset); +#endif - DVDCloseFile(dvd_file); - free(buffer); - close(streamout); - - - if ( leftover != 0 ) { - - vob = vob + 1; - - if (title_set == 0) { - fprintf(stderr,"Don't try to copy chapters from the VMG domain; there aren't any\n"); - return(1); - } else { - sprintf(targetname,"%s/%s/VIDEO_TS/VTS_%02i_%i.VOB",targetdir, title_name, title_set, vob); - } - - - if ((buffer = (unsigned char *)malloc(buff * 2048 * sizeof(unsigned char))) == NULL) { - fprintf(stderr, "Out of memory copying %s\n", targetname); - close(streamout); - return(1); - } - - - if ((streamout = open(targetname, O_WRONLY | O_CREAT | O_APPEND, 0644)) == -1) { - fprintf(stderr, "Error creating %s\n", targetname); - perror(""); - return(1); - } - - - if ((dvd_file = DVDOpenFile(dvd, title_set, DVD_READ_TITLE_VOBS))== 0) { - fprintf(stderr, "Failed opening TITLE VOB\n"); - free(buffer); - close(streamout); - return(1); - } - - left = leftover; - - while( left > 0 ) { - - if (buff > left) { - buff = left; - } - if ( DVDReadBlocks(dvd_file,offset,buff, buffer) != buff) { - fprintf(stderr, "Error reading MENU VOB\n"); - free(buffer); - DVDCloseFile(dvd_file); - close(streamout); - return(1); - } - - - if (write(streamout,buffer,buff * 2048) != buff * 2048) { - fprintf(stderr, "Error writing TITLE VOB\n"); - free(buffer); - close(streamout); - return(1); - } - - offset = offset + buff; - left = left - buff; - - } + } - DVDCloseFile(dvd_file); - free(buffer); - close(streamout); - } + DVDCloseFile(dvd_file); + free(buffer); + close(streamout); - } return(0); } -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.4.27-2-686 Locale: LANG=hu_HU, LC_CTYPE=hu_HU (charmap=ISO-8859-2) Versions of packages dvdbackup depends on: ii libc6 2.3.5-6 GNU C Library: Shared libraries an ii libdvdread3 0.9.4-5.1 Simple foundation for reading DVDs dvdbackup recommends no packages. -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]