Monday, March 26, 2012

Playing .mkv files on Internet TV's

 This is outdated.  See Reformatting and recoding video files for Internet TV's and other devices.

As you know, my small and sexy netbook do not play 1080p files well under Ubuntu without hardware driver for video acceleration.  In Windows 7, it's barely OK, but the default media player do not recognise .mkv format.  Other players suffers from the same thing on Linux, without hardware driver that use video acceleration.

It is very frustrated when these Internet  TV's can play 2x1080p from the blu-ray player, 1080p 3D movies from Vudu and even Youtube.

My TV says the media app can only play mp3 and view pictures from the USB ports.  It will only support flash thumb drives.  And that the format have to be the old FAT.  (It' the E3D420VX for the bathroom :-)  This is very wrong, protectionism.  This is pure software.  The hardware can obviously play anything from anywhere, USB or even stream via Wifi.

Out of frustration I plugged in my external USB drive in the standard Windows format - NTFS.  It works and plays mp4!!!  Another upgrade it should connect to your PC or file server via wifi and no need to carry your USB drive around.  Now almost any USB drive works.  I have a 1 TB Western Digital, and another very old laptop hard drive savaged and put in an external box to adapt it into a portable usb drive.  This one is even better as it uses y-cable instead of power adaptor.  No need to find another power socket.

There are only two problems.  Like Windows, the media play won't recognise .mkv files.  Even though it's not FAT, the video file size is limited to 4Gb.  It will play larger files, but would crash at the 4Gb point.  I think if these are sorted out, they will update the manuals.

On Ubuntu you need to install two packages to solve everything.
#sudo apt-get install gpac mkvtoolnix

First you need to find the exact frame rate and the tracks.
#mkvinfo hugo.mkv

You should read the exact video frame rate, eg, 23.976 fps.  So far all the movies are on this rate.


Usually track 1 is the video, 2 and 3 are alternative audio formats, DTS and AC3. Next extract the tracks you want.  Extensions are important.  This is how the file formats are recognized.
#mkvextract tracks hugo.mkv 1:hugo.h264 3:hugo.ac3

Since dts and ac3 in the same language are not put in blu-rays, you need to convert the dts audio track obtained the same way as above.

#ffmpeg -i hugo.dts -acodec ac3 -ab 640000 hugo.ac3
where -ab is the audio bit rate, 640kb/s may be the max for ac3, while dts is higher.

Now put them back in mp4 format.
#MP4Box -fps 23.976 -add hugo.h264 -add hugo.ac3 hugo.mp4

For some reasons, mp4box cannot detect the video frame rate correctly.  And if you put in 24 instead of 23.976, it will be out of audio sync sooner or later.  Audio sampling rates are well defined with no problems.

In contradiction to what I have researched, ac3 audio works perfectly in the mp4 format, and on my TV.  So mp4 got updated, the TV player cheated, or mkv is a mistake.  The mkv file is 11 GB, while the mp4 file is only 9 GB.  Still mp4box don't support DTS format.

Finally split up the big mp4 file into 4GB trunks.
#MP4Box -splits 4000000 hugo.mp4

This is totally lossless.  Totally fastest.  You can also concat the split files so you don't need to store the complete movie file.  Can totally be done in the cloud.  Now EC2 provides 30Gb free for one year for new signups.  But Amazon will be totally not suitable for movies because they charge bandwidth.

My prediction is that the most popular file format will be mp4 with ac3 audio or whatever what is in blu-ray.  And the 3D format will be HTB.  The blu-ray format is full side by side, meaning 2x 1080p.  To keep the current HD bit rate, the more common format is half that - HSBS.  However, in passive 3D TV's, half the vertical resolution is dropped so each eye can see all the time on a 1080p display.  So half top-bottom is best for passive, with no further loss of resolution.

Now the cheapest Vizio becomes the best.  A lot of people says passive are better.  Passive allow gamers to play 3D 24 hours instead of an hour or two.  Passive is a few times brighter.  Surprisingly, you can see finer small text in passive.  Anyway, if you know a thing or two about active, it seems like an electronic gadget for torture via your eyes.

No comments: