Wednesday, April 8, 2009

Encoding for iPhone, OGM's and MKV's

Well, a while ago DirtyFinger posted a tutorial on how to encode hardcoded videos for iPhone, I am coming to the rescue for the most annoying thing on earth, softcoded videos... I try to avoid these whenever possible because, though they are perfect for watching on your computer, they are HORRIBLE for iPhone.

Edit:
Hey Guys, I have just realized something, the reason I though Mediacoder was unreliable for MKV's was wrong, just don't use built in subtitles, this is much quicker, and much easier. Demux the file like below, but only demux the subs, then in mediacoder, in subtitles, select your file, DON'T try to use the built in ones, its more trouble than its worth, this requires much less time and effort, and the next series to come out will show this method :) , I am still downloading, but they were MKV's so I played around with mediacoder and mkv's some, and found the best way to do it(in my opinion). Oh, you still need to select audio of course, just make sure its the right one by hitting "Play".

The first step is to get this software, I assume you already have MediaCoder iPhone edition.
WinFF
MKVExtractGUI and/or OGMDemuxer
And MKVtoolnix.
WinFF is on http://winff.org
MKVExtracterGUI and MKVtoolnix are here, under editors.
OGMDemuxer is here, and it will demux all the files by dragging them onto the executable of OGMDemuxer, from there, you can follow the tutorial, skipping the Extraction process.
Now, download all these things, and make sure MKVExtractorGUI is in the same folder as MKVtoolnix.
MKV's:
Firstly, open up MKVExtractorGUI and import your MKV file.
Now select all the video and audio streams and the subtitles(srt or ssa most likely).

Now hit extract. This will take a few seconds, or longer if its an anime movie or something.
You should have at least a video, audio and subtitle files, and a text file for the chapters, I have english audio, japanese audio, video and two subtitle tracks.
Now you want to open up MKVMergeGUI, which came with MKVToolNix.
Select the audio and video files you want, in my case, the japanese.
Oh, the video should be AVI and the audio should be OGG.
SKIP THIS NOW, FOLLOW THE NEW INSTRUCTIONS ABOVE:
"
Now hit start muxing, you should now have one MKV with japanese audio and video. Your thinking, what about the subs, DON'T SELECT THEM! THIS COMES LATER. Now open winff and select your Japanese audio and video mkv.
(I almost forgot to mention, if you skip this step, and encode straight with mediacoder, the audio and video will be misaligned, So don't get any ideas :) !)
Convert it to iTunes and iPod, though other hardcoded formats will most likely work as well(and faster maybe... I should try it. Edit: I tried it with mpg(in WinFF, NTSC DVD Fast(LQ) ), no it's not low quality, its just low for TV not for iPhone :) )
Once that's done(it will take a while), open that file in mediacoder(Mines an MP4 because I already converted it, yours will be an mv4 though).
"
Now you want to goto the bottom, select "Subtitle" and pick your SRT or SSA(maybe .sub even) file, select your font and size, do any resize or cropping, and convert it(Again) to ipod. When it's done you should have one hardcoded MP4 file ready for iPhone!
Edit:
Hey guys, this way is the most reliable, I've found that it almost always works, but you can do something similar in mediacoder to, I will explain this later.


Here's a more efficient, but less reliable way to do it, I've found it doesn't work nearly as often(Though sometimes videos just won't work, this is normal, search for a different version or give up :) ).
First, we need to find out about your video and audio, right click the name of your video(in mediacoder) and hit "Details of selected file". Now there should be a window open, if your scroll down you will see different video, audio and subtitle id's(under each's respective section). Make note of these. Now under the "Audio" button in the bottom window, select the id you want, then play the video to make sure it's right. under subtitles, enter the subtitle id, and so on. I suggest checking every time, and doing it for each video, because if its by different groups, the ID's can be different.
Here's what a normal MKV would look like under the "Details for Selected File" window, I highlighted the ID's.
"General
Complete name : D:\Users\Daniel\Desktop\[V-A]_D.N.ANGEL_-_01_[3AFD2F98].mkv
Format : Matroska
File size : 213 MiB
Duration : 23mn 22s
Overall bit rate : 1 272 Kbps
Encoded date : UTC 2009-04-09 20:08:16
Writing application : mkvmerge v2.6.0 ('Kelly watch the Stars') built on Mar 24 2009 15:23:17
Writing library : libebml v0.7.7 + libmatroska v0.8.1

Video
ID : 1
Format : MPEG-4 Visual
Format profile : Streaming Video@L1
Format settings, BVOP : Yes
Format settings, QPel : No
Format settings, GMC : 3 warppoints
Format settings, Matrix : Default
Codec ID : XVID
Codec ID/Hint : XviD
Duration : 23mn 21s
Bit rate : 954 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4/3
Frame rate : 23.976 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.129
Writing library : XviD 1.0.2 (UTC 2004-08-29)

Audio #1 (Under Audio it will start at zero, so this would actually be ID:0)
ID : 3 (In audio, this doesn't matter for some reason...)
Format : Vorbis
Format settings, Floor : 1
Codec ID : A_VORBIS
Duration : 23mn 22s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Writing library : libVorbis 1.0 (UTC 2002-07-17)

Audio #2 (Under Audio it will start at zero, so this would actually be ID:1)
ID : 4 (This doesn't matter for some reason...)
Format : Vorbis
Format settings, Floor : 1
Codec ID : A_VORBIS
Duration : 23mn 22s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Writing library : libVorbis 1.0 (UTC 2002-07-17)

Text
ID : 2 (I'd be careful with subs though, they can screw with you sometimes... It's usually better to ignore the subs included and use a demuxed sub file, even if you use this method.)
Format : UTF-8
Codec ID : S_TEXT/UTF8
Codec ID/Info : UTF-8 Plain Text"
Hope it works for you,
Daniel

7 comments:

DirtyFinger said...

Thank you for this elaborate tutorial.

I figured out how to do some of that stuff and I converted a few episodes by manually extracting subs, video and audio and merged them together again after converting (i think I did it with Mmemnosyne or so).
But since I haven't found a quick solution to do it with multiple videos at once without user interaction, I kinda lost my enthusiasm.

Maybe I'll give it another try.

Daniel said...

In mediacoder you can use ID's, but it screws up a lot, that's why I do this.
-Daniel

Daniel said...

Another way is to use something like Camtasia or Movie Maker.
The sub files you can add in Mediacoder though, but the video audio you can't, so camtasia and movie maker are great for that, though sometimes you have to convert the video to wmv for movie maker, I hate that program.
-Daniel

LoLyfe said...

Nice tutorial, at last I seem to have found a system that will actually do what I need!

LoLyfe said...

Hmmm... well after my original comment I went ahead and had a play.
I have an iPhone, an iPod Classic and an iPod Video. Can't get anything to format correctly in the iPhone - the Classic formats 'ok-ish' but anything I attempt to load to the iPod Video just won't work - iTunes states it's not compatible. And this is after it took the Lucky Star encode I dl'd via anirena. Colour me confused... I'll keep at it ...

Hoffmangler said...

Thanks for covering iPhone comic book apps. I found your site while doing research for my own app. It'll be available in the app store soon for free. It's a manga-inspired comic called Banana Panic. You can see a demo of it here: Banana Panic iPhone Demo we hope to licence the engine to self-publishers so they can release their own comics.

Evil Otaku said...

Okay, I know this is an oooooooooold post with no one really reading it anymore, but the EASIEST (not quite fastest) way to convert those files to something for ipod/iphone is quick media converter. Just used it to convert the entirety of Lucky Star. Took a while but it worked terrifically.