beandog / dvd_info

Linux/BSD/Cygwin DVD utilities - dvd_info, dvd_copy, dvd_backup, dvd_player, dvd_rip, dvd_drive_status
http://dvds.beandog.org
GNU General Public License v2.0
22 stars 4 forks source link

Differences when extracting Audio LPCM #5

Closed remenor closed 10 months ago

remenor commented 3 years ago

While it is not the original purpose of the program, I am trying to extract LPCM audio without losses, by chapters in a pipe with ffmpeg. In most cases some (few) samples are missing at the end of each chapter. In cases of classical music or live concerts (where audio should be continuous among chapters) some thousandths of a second between chapters are discarded. The same happens if the complete title is extracted: the discarded samples match exactly the discarded samples when individual chapters are extracted. The audio does not coincide with the continuous audio of the full VTS extracted with FFMPEG or with some other program (lplex, dvddecrypter and others, not related to each other, which match exactly with ffmpeg) An example (here chapters 2 and 3 coincide exactly)

dvd_copy+ffmpeg

length expanded size cdr WAVE problems fmt ratio filename 18:09.309 209147300 B cxx -- ---xx flac 0.4148 t1.c1.flac 5:39.634 65209844 B cxx -- ---xx flac 0.3451 t1.c2.flac 13:39.818 157405156 B cxx -- ---xx flac 0.4243 t1.c3.flac 21:17.444 245269212 B cxx -- ---xx flac 0.3392 t1.c4.flac 58:46.205 677031512 B 0.3829 (4 files)

dvddecrypter (=ffmpeg, etc.)

length expanded size cdr WAVE problems fmt ratio filename 18:09.319 209149308 B cxx -- ----- wav 1.0000 CHAPTER_01_1 - 48kHz - 16bit - DELAY 0ms.WAV 5:39.634 65209844 B cxx -- ----- wav 1.0000 CHAPTER_02_1 - 48kHz - 16bit - DELAY -102ms.WAV 13:39.818 157405156 B cxx -- ----- wav 1.0000 CHAPTER_03_1 - 48kHz - 16bit - DELAY -106ms.WAV 21:17.452 245270748 B cxx -- ----- wav 1.0000 CHAPTER_04_1 - 48kHz - 16bit - DELAY -97ms.WAV 58:46.223 677035056 B 1.0000 (4 files)

Sorry for my english

tremon015 commented 11 months ago

I think the problem is with cell size determination. This is not just a problem with audio dvd's, all extractions have this problem: dvd_copy seems to be underreporting the size of each cell. It's just that with video dvd's this problem tends to go unnoticed because the last sector typically contains only bookkeeping information (private stream timing data).

Comparing the output of dvd_copy with vobcopy, it seems the first_sector and last_sector bounds should always be inclusive.

in dvd_cell.c:

-   blocks = last_sector - first_sector;
-
-   // Include the last cell
-   if(last_sector == first_sector)
-       blocks++;
+   blocks = last_sector - first_sector + 1;
beandog commented 10 months ago

Thanks for tracking this one down, no idea how it slipped in. Copying files is hard. It wasn't just the last sector of a title that was missing, either, it was from every cell. Changing the number of blocks to be reported isn't enough, it needs to read it when copying it as well, so you can see the change in dvd_copy.c in latest commit there.

Debug option (-z) will print out the # of blocks written at the very end.

Thanks for reporting!

remenor commented 9 months ago

It works perfectly. Thanks to both

beandog commented 9 months ago

Thank you @remenor !