Open dbpete opened 9 years ago
I've been looking into this and I can't find anything particularly wrong with the code on libavformat/mpeg.c which is what's parsing all this stuff.
I have the feeling that the program stream (vob files) actually contain subpicture stream duplicates. Seems they are getting a different startcode id 0x2X for every stream and the startcode comes straight from the PES header, so it's not a result you would expect from a bug in the code.
vgtmpeg adds the streams on the IFO file + whatever is found during probing. This obviously needs to be rethought. Will try to get into this once the merge with 2.6.x is complete. I'll also look into getting that metadata through for the subtitles you mentioned in the other issue.
I've been poking around in the code and from what I can tell, vgtmpeg isn't adding the subtitle streams from the IFO file. It does this for video and audio streams, but not for subtitle streams. All the subtitle streams are added during probing. I actually discovered this when I went to see if I could figure out how to add the metadata for subtitles. I'll add a comment to that issue about what I did.
Unfortunately, just adding the subtitle streams from the IFO doesn't fix this issue, the "duplicate streams" still get added during probing.
I wonder if this is a bug in libdvdread? Or maybe it's something odd with how some dvds are produced and maybe libdvdread could deal with it in some way?
You are correct that at the moment, subtitles streams are just added during probing.
I think the problem with the duplicate streams could be that there are simply duplicated in the vob files, therefore even if you make vgtmpeg add the streams from the IFO file they will still be found during probing because they are physically in the program stream. A possible solution would be to disallow streams that are not declared on the IFO. I have to think a bit how to implement this cleanly.
When accessing some DVDs, the number of subtitle streams detected is double the actual number. I've seen this behavior on multiple DVDs.
Here's an example of a DVD that contains 5 subtitle streams on title 1, but vgtmpeg detects 10 subtitle streams. I've trimmed some of the output (chapters, audio tracks) just to make it a bit briefer. If you want to see the entire output I'll be happy to include it. The vgtmpeg version I'm using is the latest available from source.
You'll notice vgtmpeg sees 10 subtitle streams (0:6 - 0:15).
For comparison, here's the output from lsdvd, which shows only 5 subtitle streams:
I'm fairly sure lsdvd is only looking at the subtitle information found in VIDEO_TS/VTS_XX_0.IFO, whereas vgtmpeg is scanning (I assume) the actual files to detect the subtitle streams.
After some experimentation, I've found that every other subtitle stream detected by vgtmpeg is a duplicate of the previous stream. In other words, 0:6 is a duplicate of 0:5, 0:8 is a duplicate of 0:7, etc.
As an indication of this, I ran vgtprobe (I renamed the vgtmpeg version of ffprobe to vgtprobe) to count the number of frames in each subtitle stream:
You'll notice the number of frames for every other stream is exactly the same as the previous stream. Stream #1 (aka 0:6) is the same as stream #0 (aka 0:5), etc. While this isn't absolute proof the streams are the same, I think it's a pretty good indication. I've also done some spot comparisons by generating sections of video containing each of the subtitle streams and the subtitles displayed are identical between the 2 pairs.
FYI. I don't believe this is an issue confined to vgtmpeg. I've seen the same type of behavior using mplayer (-dumpstream), mpv (-stream-dump) and vobcopy. Maybe it's a problem with libdvdread? Or maybe it's just something similar in the way all these tools are using libdvdread?
The only tool I've seen that doesn't exhibit this behavior is makemkvcon (command line tool for makemkv). Unfortunately, the source for makemkvcon doesn't seem to be available.