本來這個blog是記錄開發輸入法的點滴的,後來越來越雜,現在什麼都記錄了。

2009年2月6日 星期五

Howto convert TV recorded program (trp format) with subtitle to mkv format?

  1. Install the following free software
    • K-lite codec pack,
    • Virtual Dub
    • VobSub
    • Project-X
    • TSRemux
    • mkvtoolnix
    • AviSynth
    • ffmpeg (WinFF)
    • Son2VSub
       
  2. Assume the video files are recorded and are in
    • D:\temp\~DATA\DATA00.trp
    • D:\temp\~DATA\DATA01.trp
    • D:\temp\~DATA\DATA02.trp


  3. Join the 3 trp files into one.
    • In START menu, Run, type cmd.
    • Type the following:
      • d:
      • cd d:\temp\~DATA
      • type DATA00.trp DATA01.trp DATA02.trp > final.trp
        Microsoft Windows [? 6.0.6001]
        Copyright (c) 2006 Microsoft Corporation. All rights reserved.

        C:\Users\ylam>d:

        D:\>d:

        D:\>cd d:\temp

        d:\temp>cd ~DATA

        d:\temp\~DATA>type DATA00.trp DATA01.trp DATA02.trp > final.trp

        DATA00.trp

        DATA01.trp

        DATA02.trp

        d:\temp\~DATA>

  4. Extract subtitle information:
    • Open Project-X http://sourceforge.net/projects/project-x
    • In menu Presettings -> subtitle tab:
      • Simulate DVB subpictures IRD color model, choose NRX
      • tick "additional export as VobSub (idx+sub)



         
      • Choose to export only subtitle

         
      • Add final.trp, choose Quick start

         
      • You should be able to see many files generated.
        Keep only final.sup.sub, final.sub.idx and remove other files generated
         
  5. Use TSRemux to convert the final.trp to final.ts.
    Choose only 1 video and 1 audio stream.
    Note: for audio stream, the one with smaller number is the original language.

     
  6. Adjust the subtitle color:
    • Open the program SubResync in VobSub.
    • Drag final.sup.idx into SubResync.
    • Quickly browse the subtitle, you will find some of them are not very clear:

      To fix this problem:
      • Save the subtitle in DVDMaestro format in a separate directory, say "son".
      • In son\final.sup.son, modify it from:
        Directory .
        Subtitle final.sup
        Display_Area (0 2 719 575)
        Contrast (15 15 15 0)

        SP_NUMBER START END FILE_NAME
        Color (1 14 0 15)
        Contrast (15 15 0 15)

        0001 00:01:00:20 00:01:02:13 final.sup_0001.bmp
        Color (1 2 0 8)
        Contrast (11 15 0 15)

        0002 00:01:09:11 00:01:13:23 final.sup_0002.bmp
        Color (15 2 0 13)
        Contrast (8 15 0 15)

        0003 00:01:14:01 00:01:17:11 final.sup_0003.bmp
        to

        Subtitle    final.sup
        Display_Area  (0 2 719 575)
        Contrast   (15 15 0 15)
        Color       (1 2 0 3)

        SP_NUMBER START    END        FILE_NAME
        0001  00:02:44:13  00:02:46:06   final.sup_0001.bmp
        0002  00:02:46:10  00:02:49:03   final.sup_0002.bmp
        0003  00:02:59:21  00:03:01:05   final.sup_0003.bmp


        Note that color with index 0 is a transparent color.
         
      • Start the Son2VSub program.
        Open the son\final.sup.son directory.
        Change the output from 720x480 to 720x576

         
      • In the output file son\final.idx file, change from

        # The original palette of the DVD in PGC#1
        palette: 000060, 2b2b2b, 2c2c2c, 353535, 535353, 414141, 626262, 7c7c7c, a9a9a9, c8c8c8, 8f8f8f, ebebeb, b8b8b8, dbdbdb, 9c9c9c, 2b2b2b


        to

        # The original palette of the DVD in PGC#1
        palette:
        000000, 000000, 000000, ffffff, 535353, 414141, 626262, 7c7c7c, a9a9a9, c8c8c8, 8f8f8f, ebebeb, b8b8b8, dbdbdb, 9c9c9c, 2b2b2b
         
      • The subtitle now looks better:


         

  7. Adjust the subtitle time:
    • Find the first subtitle in final.sup.idx
    • Play D:\temp\~DATA\final.ts in Media Player Classic (in K-lite Codec pack).
      Play until the first subtitle is heard. Write down the time of the first subtitle.
    • In SubResync, right click the subtitle chosen 2 times, until seeing the red triangle
    • Enter the correct time of the subtitle chosen. Save as final.idx
    • Reopen final.ts in Media Player Classic. The subtitle time should be correct now.
       
  8. Find the cropping details for movie, in Virtual Dub.
    • In D:\temp\~DATA\, create a file called final.avs (using notepad) with the following content:

      DirectShowSource("final.ts")
      LoadPlugin("c:\Program Files\K-Lite Codec Pack\Filters\vsfilter.dll")
      VobSub("final.idx")
       
    • Drag "final.avs" into Virtual Dub.
    • In Virtual Dub, "Video" Menu, choose "Filter".
    • Add "Null Transformation"
    • Choose "Cropping...".
    • Determine the cropping details (i.e. Write down X1, X2, Y1, Y2. Note they must be even number):
         
       
  9. Using ffmpeg to convert final.ts to XVID encoded (MPEG4) AVI file final.avi:
    • Start a command prompt.
    • type the following:
      • d:
      • cd d:\temp\~DATA
      • "C:\Program Files\WinFF\ffmpeg.exe" -i final.ts -vcodec xvid -vtag XVID -deinterlace -croptop 76 -cropbottom 76 -cropleft 4 -cropright 4 -s 640x360 -qmin 4 -qmax 4 -bufsize 4096 -mbd 2 -bf 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -g 300 -acodec mp3 -ar 44100 -ab 128k -ac 2 final.avi
    • Note:
      • replace the value for croptop, cropbottom, cropleft, cropright with the values found in Y1, Y2, X1 and X2 found in Step (8).
      • for the best quality video, set qmin, qmax to 1. (the smaller value the better video quality)
      • -g 300 means for every 300 fames (12seconds), there is a I frame. Set to a smaller value if you need to editing.
      • the above example uses 44100kbps, 128kpbs 2-channels mp3 audio. you can modify as your wish
         
  10. Merge final.avi, final.idx into final.mkv
    • Start mkvtoolnix\mmg.exe, add final.avi, final.idx. Press "Start muxing".

5 則留言:

匿名 提到...

wonderful issues altogether, you just received a logo new
reader. What could you recommend in regards to your submit that you just
made some days in the past? Any positive?
Also visit my site : manchester united transfer news latest

匿名 提到...

As a lupus diagnosis should avoid fatigue and possibly even more effective; especially because it has not attempted
to determine if indeed I am never tired. Someday, someday soon
- his memories won't feel like listing more.
Here is my weblog lupus specialist Tennille

匿名 提到...

Wow that was strange. I just wrote an really long
comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again.
Regardless, just wanted to say wonderful blog!
My webpage ; perfumes baratos

匿名 提到...

great points altogether, you just won a new reader. What may you recommend about your
publish that you made some days in the past?
Any positive?

Stop by my homepage; candy crush saga game cheats
level 70 - -

匿名 提到...
網誌管理員已經移除這則留言。