VideoHelp Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. The real way.

    If you own the Lord of the Rings Extended Editions on either DVD or Blu-Ray, you know that at the end of each "Disc 1", and at the start of "Disc 2" is a bit of a black pause. You can append one file to the end of another like this, but you'll get an unsightly black gap that may or may not bother you. It bothered me, so I decided to figure out how to remove it.

    I once read a thread on another site about how somebody figured out specific times to cut the m2ts files at so you could merge them at the end and get very little black pause. I followed this guide, and was fairly happy with the resulting ~1 second pause, but I felt I could do much better. I wanted NO black between the two parts. And I wanted the audio in part 1 - the part that trails off into the black - to be merged onto the start of part 2.

    Follow this guide to get that result, as well as (optionally) have all commentary tracks in each file...

    I'm using "The Two Towers" as an example. You can modify the steps to accomodate for the differences for the other two movies. I'll list all the numbers at the end.

    I used the following free tools:
    • DVDFab HD Decrypter
    • eac3to
    • tsMuxer
    • AviSynth
    • VirtualDub
    • MeGUI
    • mkvmerge
    First off, obviously, you need to rip both discs to your computer. You can use various tools for this, but I've used DVDFab 8 to rip my Blu-Rays. I did a full disc copy, not just main movie. I ended up with two folders: G:\FullDisc\THE_TWO_TOWERS_EXT_PT1 and G:\FullDisc\THE_TWO_TOWERS_EXT_PT2.

    I just realized that doing this guide with a DVD may not work, because I think the framerate of the DVDs are different, and the frame numbers will not match up. If you have the DVDs and want to try this, let me know if it works.

    Next, you need eac3to and optionally, for best results, the Arcsoft DTS decoder. Without Arcsoft, you'll only get 5.1 and not 6.1 audio.

    From command prompt, I ran the following:

    eac3to g:\FullDisc\THE_TWO_TOWERS_EXT_PT1 1) 3: p:\!temp\part1.wavs

    What this command does is simultaniously read track 3 in the main m2ts file (which happens to be G:\FullDisc\THE_TWO_TOWERS_EXT_PT1\BDMV\STREAM\000 12.m2ts) and convert each channel to individual mono wavs. You could opt to convert straight to FLAC here, but I ran into a few issues while experimenting and opted to do it this way to ensure I had everything correct.

    This was the output from eac3to:

    Code:
    eac3to v3.24
    command line: eac3to  g:\FullDisc\THE_TWO_TOWERS_EXT_PT1 1) 3: p:\!temp\part1.wavs
    ------------------------------------------------------------------------------
    M2TS, 1 video track, 6 audio tracks, 11 subtitle tracks, 1:46:39, 24p /1.001
    1: Chapters, 30 chapters
    2: h264/AVC, 1080p24 /1.001 (16:9)
    3: DTS Master Audio, English, 6.1 channels, 24 bits, 48kHz
       (core: DTS-ES, 6.1 channels, 24 bits, 1509kbps, 48kHz)
    4: DTS Master Audio, French, 5.1 channels, 16 bits, 48kHz
       (core: DTS-ES, 5.1 channels, 16 bits, 1509kbps, 48kHz)
    5: AC3 Surround, English, 2.0 channels, 192kbps, 48kHz, dialnorm: -27dB
    6: AC3 Surround, English, 2.0 channels, 192kbps, 48kHz, dialnorm: -27dB
    7: AC3 Surround, English, 2.0 channels, 192kbps, 48kHz, dialnorm: -27dB
    8: AC3 Surround, English, 2.0 channels, 192kbps, 48kHz, dialnorm: -27dB
    9: Subtitle (PGS), English
    10: Subtitle (PGS), French
    11: Subtitle (PGS), English
    12: Subtitle (PGS), French
    13: Subtitle (PGS), English
    14: Subtitle (PGS), French
    15: Subtitle (PGS), English
    16: Subtitle (PGS), French
    17: Subtitle (PGS), English
    18: Subtitle (PGS), French
    19: Subtitle (PGS), French
    [a03] Extracting audio track number 3...
    [a03] Remapping channels...
    [a03] Decoding with ArcSoft DTS Decoder...
    [a03] Writing WAVs...
    [a03] Creating file "p:\!temp\part1.L.wav"...
    [a03] Creating file "p:\!temp\part1.C.wav"...
    [a03] Creating file "p:\!temp\part1.BC.wav"...
    [a03] Creating file "p:\!temp\part1.SR.wav"...
    [a03] Creating file "p:\!temp\part1.R.wav"...
    [a03] Creating file "p:\!temp\part1.LFE.wav"...
    [a03] Creating file "p:\!temp\part1.SL.wav"...
    [a03] The original audio track has a constant bit depth of 24 bits.
    Video track 2 contains 153427 frames.
    eac3to processing took 13 minutes, 44 seconds.
    Done.
    Do the same with the rip of Disc 2 by running the following:

    eac3to g:\FullDisc\THE_TWO_TOWERS_EXT_PT2 1) 3: p:\!temp\part2.wavs

    Next, we need to do some massaging of the audio so that we have two 6.1 (or 5.1 if you don't have Arcsoft) FLAC files that are seamless. Using avisynth with a couple of plugins makes this a very easy task. You'll want AviSynth with bassAudio and SoundOut plugins. You can find bassAudio here. SoundOut can be found here. Make sure those plugins are in your AviSynth plugin folder.

    You'll need the following three .avs files to export the audio to the FLAC files we need. Be sure to change any path/file names to match your circumstances:

    Code to export Part 1, minus silence at end:

    Code:
    video = DirectShowSource("G:\FullDisc\THE_TWO_TOWERS_EXT_PT1\BDMV\STREAM\00012.m2ts", fps=23.976, audio=false)
    
    #Map the individual wav files to their respective channels
    fl = WavSource("P:\!temp\part1.L.wav")
    fr = WavSource("P:\!temp\part1.R.wav")
    c = WavSource("P:\!temp\part1.C.wav")
    lfe = WavSource("P:\!temp\part1.LFE.wav")
    bc = WavSource("P:\!temp\part1.BC.wav")
    sl = WavSource("P:\!temp\part1.SL.wav")
    sr = WavSource("P:\!temp\part1.SR.wav")
    
    audio = MergeChannels(fl,fr,c,lfe,bc,sl,sr)
    
    #Mix the audio and video together, and trim off the black at the end
    AudioDub(video,audio)
    trim(0,153307)
    spline36resize(960,408)
    
    #Export the audio
    SoundOut()
    Code to export the part of part 1 that needs to be mixed into part 2:

    Code:
    video = DirectShowSource("G:\FullDisc\THE_TWO_TOWERS_EXT_PT1\BDMV\STREAM\00012.m2ts", fps=23.976, audio=false)
    
    #Map the individual wav files to their respective channels
    fl = WavSource("P:\!temp\part1.L.wav")
    fr = WavSource("P:\!temp\part1.R.wav")
    c = WavSource("P:\!temp\part1.C.wav")
    lfe = WavSource("P:\!temp\part1.LFE.wav")
    bc = WavSource("P:\!temp\part1.BC.wav")
    sl = WavSource("P:\!temp\part1.SL.wav")
    sr = WavSource("P:\!temp\part1.SR.wav")
    
    audio = MergeChannels(fl,fr,c,lfe,bc,sl,sr)
    
    #Mix the audio and video together, and trim off the black at the end
    AudioDub(video,audio)
    trim(153308,0)
    spline36resize(960,408)
    
    #Export the audio
    SoundOut()
    And finally: Code to make the second FLAC file, that has the first 5 seconds merged with the end of the original Part 1:

    Code:
    video = DirectShowSource("G:\FullDisc\THE_TWO_TOWERS_EXT_PT2\BDMV\STREAM\00001.m2ts", fps=23.976, audio=false)
    audio_part1 = bassAudioSource("p:\!temp\part1_end.flac")
    
    #Get the individual channels from the first part
    fl_part1 = GetChannel(audio_part1,1)
    fr_part1 = GetChannel(audio_part1,2)
    c_part1 = GetChannel(audio_part1,3)
    lfe_part1 = GetChannel(audio_part1,4)
    bc_part1 = GetChannel(audio_part1,5)
    sl_part1 = GetChannel(audio_part1,6)
    sr_part1 = GetChannel(audio_part1,7)
    
    #Map the individual wav files to their respective channels
    fl_part2 = WavSource("P:\!temp\part2.L.wav")
    fr_part2 = WavSource("P:\!temp\part2.R.wav")
    c_part2 = WavSource("P:\!temp\part2.C.wav")
    lfe_part2 = WavSource("P:\!temp\part2.LFE.wav")
    bc_part2 = WavSource("P:\!temp\part2.BC.wav")
    sl_part2 = WavSource("P:\!temp\part2.SL.wav")
    sr_part2 = WavSource("P:\!temp\part2.SR.wav")
    
    fl = MixAudio(fl_part2,fl_part1,1.0,1.0)
    fr = MixAudio(fr_part2,fr_part1,1.0,1.0)
    c = MixAudio(c_part2,c_part1,1.0,1.0)
    lfe = MixAudio(lfe_part2,lfe_part1,1.0,1.0)
    bc = MixAudio(bc_part2,bc_part1,1.0,1.0)
    sl = MixAudio(sl_part2,sl_part1,1.0,1.0)
    sr = MixAudio(sr_part2,sr_part1,1.0,1.0)
    
    audio = MergeChannels(fl,fr,c,lfe,bc,sl,sr)
    
    #Mix the audio and video together, and trim off the black at the end
    AudioDub(video,audio)
    trim(24,0)
    spline36resize(960,408)
    
    #Export the audio
    SoundOut()
    Open each of these three files individually using VirtualDub. A popup box will appear asking you to export the audio. Click on FLAC, choose the compression you want (I chose best) and then choose where you want to save them. You'll need to match what you choose to save the files as and make sure the .avs files above match, otherwise you'll run into problems. I named the files as follows:

    part1_new.flac
    part1_end.flac
    part2_new.flac


    Make sure you do them in order since part 3 requires that part 2 be done.

    Now you should have the two FLAC files needed to make the two separate MKV files. Now you can optionally demux the commentary and subtitle streams to include in the final MKV. If you use subtitles, you'll need to convert them to SRT and alter the timing of the second one by 1001 milliseconds since we chopped off that much of the start. I won't cover these instructions here since I didn't bother to do it. You can use tsmuxer to demux the Dolby 2.0 audio streams from the m2ts files.

    Now you can use pretty much any program you like to encode the video to MKV, but I chose to use MeGUI following the instructions here for best quality. Note that these settings are extremely high, so unless you have a powerful enough computer, you could be running this process for almost 5 days before you finish just one of the three movies. I chose this method because it best lets me control (at least, among the various tools I've tried in the past) the output size of my final MKV while maintaining the best quality. I'm going to encode the videos so that each file is no larger than a DVD-9.

    If you choose to use MeGUI as I did, then do the following. In notepad, paste the following text into a file named "part 1.avs"

    Code:
    DirectShowSource("G:\FullDisc\THE_TWO_TOWERS_EXT_PT1\BDMV\STREAM\00012.m2ts", fps=23.976, audio=false)
    crop(0,132,0,-132).spline36resize(1920,816)
    trim(0,153307)
    ConvertToYV12()
    Do the same for a file named "part 2.avs" with the following:

    Code:
    DirectShowSource("G:\FullDisc\THE_TWO_TOWERS_EXT_PT2\BDMV\STREAM\00001.m2ts", fps=23.976, audio=false)
    crop(0,132,0,-132).spline36resize(1920,816)
    trim(24,0)
    ConvertToYV12()
    In MeGUI, encode the second part first, because it is the larger of the two. I want to use the same bitrate on both videos, so the first video will be smaller, ensuring that both files can each fit on their own DVD-9 disc.

    Once you have part 2.avs open, go to the bitrate calculator as described in the guide I listed earlier. Choose DVD-9 as the target size, and add the part2_new.flac file as an audio source. If you're putting the commentary tracks in as well, be sure to add 4 more audio sources and add each .ac3 file in so that it can calculate the file size to reserve. Click Apply and copy the bitrate to your preset. Queue the encode and then proceed to wait a very long time (unless you have a beast of a computer).

    Repeat the last step with part 1.avs, except don't use the bitrate calculator. Use the same preset with the same bitrate used for part 2. Queue up that one and wait again.

    Now you should have two MKV files with just video in them. Using mkvmerge, open each MKV file and drop in the FLAC and AC3 files that belong to that part. Remux them into their individual MKV files for storage on DVD. Finally, you can open mkvmerge fresh and open up the first part, and then append the second part and output it into one very large 15-16GB MKV file that will be completely seamless in the middle.

    -----------------------------------------------------------------------------

    The process to find these settings was mind-blowingly annoying to figure out. I had to find exact frame numbers where the scene ended in disc 1 and again when it starts in disc 2. I've tried a few other methods to get this result, ranging from using tsMuxer to cut the file at an exact point in milliseconds to merging the audio with Audacity. The process I described here was the easiest of all of them, though a bit time consuming.

    As of this writing, I only have the data figured out for The Two Towers. Once I'm done encoding that at full quality, i'll work on the other two and then post the frame numbers here where you need to cut. Very likely disc 2 of all three movies will be the same: First 24 frames (10001 milliseconds) will be black. But for summary, here's what I have:

    Note: These frame numbers are based on frame 1 being at point 0. So the total number of actual frames in the video will be one higher than I list here

    Two Towers:
    Disc 1 formally ends after frame 153307. First black frame is at 153308.
    Disc 2 formally starts on frame 24.
    Last edited by agent154; 17th May 2012 at 10:49. Reason: Fixed misspelling of topic.
    Quote Quote  
  2. Agent154, Did you ever figure out the data required to merge the other LOTR films? If so, would you mind posting that information?

    What tool did you use to obtain the frame rate?

    Thanks
    Quote Quote  
  3. Unfortunately I neglected to continue with the other movies yet. It was a long process, and encoding them took almost 48 hours on my hardware, so it was tying up my computer for too long. I did find the numbers for the first movie, but did not encode yet. I'll look and see if I can find them to put in here. I actually forgot all about this thread. I'll have to update it since I've found a slightly more straightforward way to do some of the work.. As for the frame rate, I just assumed it was standard 24000/1001 and it turned out to be true. This is for the blu-ray source of course.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!