Results 1 to 1 of 1

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: My guide for transcoding HD (h264 mkv) videos to iphone4 video...

  1. #1
    Default My guide for transcoding HD (h264 mkv) videos to iphone4 video...
    Things you will need for this guide:

    1. CUDA-enabled video card
    2. DGDecNV - only non-free thing here...$15
    3. MKVtoolnix
    4. MeGUI
    5. mkvextracgui-2
    6. [ame="http://forum.doom9.org/showthread.php?t=125966"]eac3to[/ame]

    7. ActivePerl
    8. Nero AAC Encoder
    9. Avisynth
    10. My perl scripts

    This is more of an advanced guide, but videos come out a lot better than one-click programs. Numbers 1 and 2 can be substituted for just DGAVCDec, which comes with MeGUI. Now I work out of one directory on a different partition. In my perl scripts you will have to edit paths to where you are working, and for the other locations of working programs. Remember for the paths you need a double-backslash for each directory level. You will also need to have neroAacEnc_SSE.exe and x264.exe in your working directory. You will need copy DGDecodeNV.dll to your Avisynth 2.5\plugins directory. Perl scripts need to be in the working directory, too.

    1. Load your .mkv video into DGDecNV by clicking Open, then OK in the next window. If it says it needs to be cropped, let this program do it.

    2. File -> Save. Save to your working directory.

    3. After that is done you will need to demux your audio. This can be done with DGDecNV but I have better success with mkvextractgui-2. If you use mkvextractgui-2 you need to take the "_track#" off the end of the file name.

    4. Open up a command prompt and navigate to your working directory.

    5. If your audio file is an .ac3, run ac3tom4a.pl, if it is a .dts run dtstom4a.pl. Just type in ac3tom4a.pl or dtstom4a.pl.

    6. After that is done you need to make an avisynth script. If you are doing a bunch of videos at once, like a show series, you can use makeavs.pl. You will need to edit the sizes in the script to your aspect ratio. To figure out what the size needs to be open a calculator:
    1. Take the source width, divide by the height.
    2. Copy that number then clear the calculator.
    3. Type 960, divide, paste copied number, enter.
    There you have your height. If the video is a 1080p source, just divide that height by half. You will only need the calculator method for 720p video that is not 16:9. If any video is 16:9 then the height is simply 540. You will need to add black bars. To find out the height of these, take 640, subtract your height, and divide by 2. Here is what your avisynth script will look like:
    Code:
    dgsource("source.dgi")
    lanczosresize(960,540)
    addborders(0,50,0,50)
    If the video comes out to be a non-standard rate, you need to add assumefps() as the second line of the avisynth scripts. You can find this out by opening the .dgi file with Notepad. Standard rates are: 24000/1001, 24, 25, 30000/1001, 30. DGDecNV sometimes also doesn't give you the proper framerate, so always check. The assumefps would look like assumefps(24000,1001) for the weird ntsc rates. Simple number rates would just look like assumefps(25).

    7. Once you have your avisynth scripts created run encode-264.pl.

    8. Once that is done run mp4mux.pl. My script is preset with English as the audio language and 23.976 fps. You will need to change these if you need a different language or framerate. If you ae encoding a silent video you will need to use the mp4 muxer in MeGUI.

    9. There you will be with a muxed .mp4 of your movie.

    Here are some specifics about my scripts:

    ac3tom4a.pl and dtstom4a.pl:
    Both scripts will transcode any .ac3 or .dts files in the working directory. Line 8 is where paths are. The first path is your eac3to path. The other 2 paths also need to be full, and need to be your working directory. If you want your source audio file to be automatically deleted, just un-comment line 18 by deleting the # in front of that line.

    encode-264.pl:
    The only thing in this script worth changing is the CRF number. The lower you go, the more quality you get. I stick with 20 and I am a quality nut. 17 is the lowest I would go if you are that insane about quality.

    indexer.pl
    This script is for DGDecNV to index all .h264 files in the working directory. You get these files by demuxing them with mkvextractgui-2. Line 9 has your paths. If you are on 32-bit Windows you will need to edit this right away.

    makeavs.pl:
    This will make an avs script for any .dgi files in your working directory. Line 10 should be un-commented if you need to fix your framerate. Line 11 hold your dimensions. Line 12 holds the black bar adder. This is set up for 16:9 pictures, which most show series are, you you may not need to even mess with the file.

    mp4mux.pl:
    This will see any .264 file that was transcoded and mux it with the appropriate .m4a file to make your .mp4 video file. You can only use this if you have audio to go along with your raw video. Line 8 has a bunch of info you may need to change, like paths, FPS, and language. It is set 23.976 fps and English as the language. The mp4box program comes with MeGUI.

    Any questions, shoot...
    Last edited by ramicio; 2010-08-09 at 06:25 PM.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •