A Study of DVD Files & their Conversion

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

A Study of DVD Files & their Conversion

Postby meRobs » Mon Dec 14, 2009 4:09 pm

[Updated 28 Feb 2010]
This study began because of confusing and inconsistent results when converting VOB files and the use of Add Track in MediaCoder.

For this study, I used MediaCoder build 4526 for the conversions, via MEncoder as the video source and FFmpeg, as encoder, and Adobe Premiere CS3, a quality video editor, was used to accurately examine the results. Premiere (see Figs below) is able to independently shift the video and audio tracks, examine the audio waveforms and view the video stream frame by frame.

The VOBs from a number of PAL and a few NTSC discs were converted to DV-AVI (for PAL) and Huffyuv-AVI (NTSC), formats chosen because Premiere behaves best with them. I also tried a few conversions to WMV and MPEG2, to confirm the findings.
The VOB set for each movie was also joined to form a single AVI file while converting ('Group' in MediaCoder) and the converted IFO file (see below) for the movie was included as reference.

The AVI files from the individual VOBs, their Joined-VOB and the AVI from the IFO were placed on parallel tracks on the Timeline.
The AVI-converted IFO was perfectly in sync throughout the movie, judged at various impact (sharp) noises, and it contained all audio and video data as would be seen on playing the DVD.

By examining the waveform of each audio track in Premiere CS3 and independently playing it, they were shifted to align with the audio of the IFO. The audio for the Joined-VOB matched that for the IFO within about 1 frame, but had been truncated at the end, during the conversion, sometimes losing useful content.

All video tracks of the individual and joined VOBs, while unlinked from their audio streams, were shifted to align with the video from the IFO to the nearest frame. As a result, there were gaps on the Timeline between the video streams of the individual VOBs and these missing frames were also missing from the Joined-VOB.

General Comment
When a DVD “Title” is represented on a disc, the data is cut up into VOB chunks no bigger than 1 GB. These cuts seem to cause a number of problems:
(1) the metadata in each VOB file will contain a value of 'video delay' (see below) that is negative for all VOBs but the first, which may be positive or negative but is often zero. A negative video delay means that the video is ahead of the audio stream.
(2) there are video frames that appear missing from the start/end of each VOB – they are neither accessible when an individual VOB is played in a software player nor when converted by an encoder.

If a VOB file is in the queue (input) panel of MediaCoder, its Video delay value may be got from Item (menu) > 'Details of selected file (F8)', listed under Audio. If not in the queue, it may be read using the freebie: “MediaInfo'. However, this App may not work directly on a Copyright-protected disc or, if it does, the values may be incorrect.

Conversion of an individual VOB
If an individual VOB is converted (to AVI, WMV, etc), the start and end of the file will have missing video frames, but the audio should be intact. When a VOB is converted, the duration of the audio will match that of the available video and, so, will be truncated at the last available video frame.

The audio in a VOB may be delayed (see: viewtopic.php?f=17&t=8160&start=0).
If the VOB is converted while applying an audio delay equal to that stated for the video, the audio will be shifted earlier and be in sync with the video. The resultant gap at the end will then be filled with audio copied from near the end of the VOB, but not exactly from the end (Fig. 2 below). Thus, this region will have duplicate audio that does not match the video!

If the audio delay applied in MediaCoder is greater than required by the stated video delay, the shift earlier will be greater and the extra space at the end will be filled by more audio copied from earlier in the VOB, also near the end not the same region as before.

The problems occurring at the start/end of each VOB are probably due to the fact that its MPEG-2 data are stored in GOP groups of maybe 15 frames and when cutting the VOBs into 1-GB chunks, the cuts are likely to occur within a GOP. The first and last frame of a GOP is a complete I-frame.

Since Players and Encoder, etc, need to start and end at an I frame, not from within a GOP, some video frames will not be accessed (not available). This may be seen in an App such as Avidemux. On opening a single VOB in Avidemux, the first and last available frames for the VOB will be indicated as I-frames. If, instead, the complete set of VOBs are included (appended) the missing frames around the joins will also be present!

Illustration of Missing Frames
The following Figures show the Timeline for a movie. It has the audio and video tracks for the Converted-IFO (innermost tracks), the Joined-VOB and the individual VOBs. They were placed in parallel and aligned to the same video and audio frames – those in the IFO were the reference, being in perfect sync.

The lower 4 tracks are the audio with their waveforms visible (not for the Joined-VOB).

Fig. 1 shows a 14-frame gap in video between VOB-2 and VOB-3 (VTS_01_3) and that there is a 19-frame excess of audio at the start of VOB-3. When VOB-3 is converted with the correct delay applied, the audio data is shifted earlier by 19 frames and the excess is truncated.

(!empty($user->lang['IMAGE'])) ? $user->lang['IMAGE'] : ucwords(strtolower(str_replace('_', ' ', 'IMAGE')))

Fig. 2 shows a gap in video of only 4 frames between VOB-3 and VOB-4. It also shows the result of applying the above delay to the audio of VOB-3. The 19-frame shift to the left created a region that was filled with copied audio not appropriate for the video.

(!empty($user->lang['IMAGE'])) ? $user->lang['IMAGE'] : ucwords(strtolower(str_replace('_', ' ', 'IMAGE')))

Join VOBs and Convert
When a group of VOBs are converted (joined) to AVI with no audio delay applied in MediaCoder all the available video frames will be stacked in series as will those for the audio. The video frames missing from the individually-converted VOBs will also be missing, yet all the audio present in the VOBs will be included. As a result the video will be out of sync, getting progressively worse after each join, finally being out by, approximately, the sum of the stated 'video delays'. For example, for one DVD, with 5 joined (VOB) segments, the progressive out-of-sync was 1, 4, 16, 31 and 47 frames.

The joined-VOB will also be truncated shortly after the last non-black video frame and sometimes earlier (for one disc there were 55 frames missing from the end)!

Conversion of an IFO file
In this study, the Movie on each DVD was Title 1 (VTS_01), and its IFO file was VTS_01_0.IFO. Each such IFO file was loaded into MediaCoder and when converted, it contained the complete Movie with its video and audio in perfect sync – to the nearest video frame!
Have you checked out the Tips & Guides for MediaCoder? Try: http://forum.mediacoderhq.com/viewtopic.php?f=17&t=8061
Also, get older builds at: http://www.videohelp.com/tools/MediaCoder/old-versions#download

Return to “Generic Discussions”

Who is online

Users browsing this forum: No registered users and 5 guests