Archive:HOW-TO:Create high-definition Xvid/DivX movies from TS (Transport Stream) video files

From Official Kodi Wiki
Jump to navigation Jump to search
Time.png THIS PAGE IS OUTDATED:

This page or section has not been updated in a long time, no longer applies, refers to features that have been replaced/removed, and/or may not be reliable.

This page is only kept for historical reasons, or in case someone wants to try updating it.

This guide will show you how to reencode your recorded MPEG2 Transport Streams into a XBMC playable HD XviD. Only movies with 2.35:1 aspect ratio are currently supported. A basic understanding of video encoding might be a good start.


Requirements

- A recorded movie contained in a Transport Stream (TS) file.

- Project X - DVB demux tool [1]
- DGIndex - MPEG2 decoder and frame server [2]
- AVISynth [3]

 Plugins:
 - ColorMatrix 2 [4]
- Decomb [5]
- DGIndex [6]

- VirtualDubMod [7]
- XviD codec [8]

- Plugh's XviD VideoForWindows (xvidvfw.dll) dll [9]


Installation

Install all software like usually except Plugh's DLL. After installation of XviD codec, you need to locate your current xvidvfw.dll and overwrite it with the new one (rename old one to xvidvfw.dll.org). Put the following AVISynth plugins with your TS (and AVS) file(s); - ColorMatrix.dll - Decomb.dll - DGDecode.dll


Demuxing video and audio

DGIndex can actually take your TS as an input but tests show that it's not a good idea, as DGIndex does not like reception errors inthe TD file all too well. Instead Project X is used, an application which demuxes and fixes a wide range of problems in the TS file.

Open your TS file or files and mark start and end of movie (if needed) - also cut out commercials if any are in the capture. Press "prepare>>" and then "Start (Play icon)". Now wait awhile while Project X demuxes your audio and video into a MPEG2 video file and Audio files in AC3 or MPEG Layer 2 audio. You might need to change or play with some settings. More info on this might be added later if proves needed.


Indexing

Now that we have our video file, we need to index it to get a D2V file. Open up DGIndex and load your MPEG2 video file. Go to "Video" / "Cropping filter". Enable and cut 132 from top and bottom (some movies needs alittle more cutting). Now it's important that what you cut follows this rule: - Cut video height divided by 1.5 must be an integer - no digits! For example you are cutting 1920 to 1920x816 (removing black borders). 816 divided by 1.5 equals 544. Perfect! NB! Do not cut any of the horizontal resolution as you will find yourself looking at some weird calculations. Let us keep it simple.

Now press F4 ("File" / "Save project") and save the D2V. Notice the information window which pops up. Write the info down or take a screenshot. Notice in particular; - Frame Rate (23.97, 29.97, 25.00) - Video type (NTSC/PAL) - Frame Type (Interlaced/Progressive) - Colorimetry (FCC, 709, etc)


Scripting

Now we have a D2V file, we need to create a AVISynth script which we can open in VirtualDubMOD. Now this is the hard part as it's totally dependant on the TS source.

Progressive source:

LoadPlugin("DGDecode.dll") LoadPlugin("Decomb.dll") LoadPlugin("ColorMatrix.dll") mpeg2source("<index file>.d2v") BicubicResize(1280,544) ColorMatrix(mode="FCC->Rec.601")


Interlaced source:

LoadPlugin("DGDecode.dll") LoadPlugin("Decomb.dll") LoadPlugin("ColorMatrix.dll") mpeg2source("<index file>.d2v") Telecide(guide=2,post=0) BicubicResize(1280,544) ColorMatrix(mode="Rec.709->Rec.601")


Notice Telecide/Telecine and ColorMatrix. You need to read up on their manuals to learn how to properly use them (when and how). XBMC needs 601 color matrix so you need to convert the colors of your movie to this. In the examples about you see one movie with FCC and one with 709.

BicubicResize says 544 rows, but it depends on your calculations done in the indexing step!

Now save your AVISynth (AVS) file!


Reencoding

Now it's time for the fun! Reencoding of movie in two passes. Start VirtualDubMod and open your AVS file created in the scripting step.

Time for first pass encoding of video.

Go to: "Streams" / "Stream list" and add the audio of your choice. "Videos" and choose "Fast reencode" "Videos" and then "Compression" Select XviD codec at the bottom of the list and press "Configure" Select your XBMC profile. I prefer XBMC SMB as the result is streamable over a network from a server or NAS Select "Two pass - 1st pass" encoding type. Press "More" next to encoding type. Check "Full quality first pass" and uncheck "Discard first pass" Now "File" and "Save as" Choose a name like this "<movie> pass 1.avi"

Now wait a number of hours depending on your computer/CPU. Usually going to bed or work will be a good idea here ;)

Pass two.

When encoding is done, you have a playable AVI file. If you play it back in XBMC you will notice that some scenes play fine and others with huge numbers of frame drops. Now it's time for the magic of Plugh. Plugh made changes and fixed bugs in the XviD codec to control the peak limits of the encode to match XBMC/Xbox's restrictions.

Go to "Videos" and then "Compression" and press "Configure" Select "Twopass - 2nd pass _ALT_" encoding type. It's vital that you choose ALT type as this is actually Plugh's magic code. Press "Calc" to enter the bitrate calculator. Enter these values: Target size: 4082144 (less than FATx limitation) Video: Enter the duration of the movie and the FPS. Audio: Those your format and bitrate. Press OK. Go to "File" and "Save as" Choose a name like this "<movie> pass 2.avi"

Now you wait again and afterwards your XBMC HD encode is done!


Final words

This guide was thrown together by a tired mind from the top of the head. It needs images and more info, but it's a start to get people going. Feel free to contribute if you can. /ultrabrutal