Here is my today's post in my Google Buzz and Google+
Since I am a command line and GNU/Linux+FOSS lover, here is my way to trancdode MKV to MP4 and make the TF101 flawlessly played in HW decoding mode.
Last few weeks ago, I tried to trancode a 1920x1080p H264 encoded movie in MKV container to 1280x720p H264 mkv format which I wanted to play it back in Asus Transformer TF101. As usual, I used FFMPEG (latest svn), and I had few problems handling streams' mapping. The original mkv has a H264 video, a 5.1 DTS audio, a 5.1 Dolby Digital audio and a subtitle. FFMPEG complained that tke output mkv must have matching numbers of streams. This can be solved by using -an, -sn and -map options.
After transcoding a short clip of couple of minutes, and uploaded to the tablet for a test playback, The video 720p playback was smooth, due to the hardware decoding, but, I found that, the audio was cut off after 20 or 30 seconds. I start and rewind few seconds back, and the audio resumed, and it cuts off again after several seconds. I tried several audio codecs, such as, AAC, MP3 and MP2, I also tried Baseline and High profile H264 video encoding... but, the results were same.
I still can played the mkv file with third party players using software (sw) decoding mode, which make the video playback was choppy and with out of synced audio but no cut off.
Then I tried, to converted it to mpeg4 in .avi format. It runs well, but the stock player in the tablet cannot play .avi. I used MoboPlayer but, the quality is not as good as H264 hardware decoding. Then, I looked up in Internet, and there were many problems related to mkv playback in the tablet. The solution is, to use MP4 container.
Code:
$ ffmpeg -i /path/to/IN.1080p.X264.AC3.DTS.mkv -b 800k -ac 2 -ab 160k -aspect 16:9 -s hd720 -threads 0 OUT.mp4 -map 0.0 -map 0.2
Here I transcoding /path/to/IN.1080p.X264.MKV.AC3.DTS.mkv to OUT.mp4 using video bitrate at 800kbps, and 2 channels audio biterate at 160kbps. Here I did not put the video and audio codecs type, because FFMPEG will automatically choose a proper audio and video codecs based on the container's format/type. For MP4 container, FFMPEG chosed High profiled H264 video codecs and mp4a or AAC audio codecs. Result..... it played both audo and video beautifully on the tablet, in hardware decoding mode.
You can increase the video bitrate if you want a better video quality, but, it also produced bigger file. If you have less than 720p H264 encoded file, you can use -vcodec copy, to copy the video content without any encoding, which will be produce the exact video quality as the original.
I hope, Asus can resolve the MKV playback issue in the next update.
Thank you.
Reference,
Here is the original source...
Code:
$ ffprobe /path/to/IN.1080p.X264.AC3.DTS.mkv
ffprobe version N-32077-g5f5e37e, Copyright (c) 2007-2011 the FFmpeg developers
built on Sep 2 2011 11:29:35 with gcc 4.4.4
configuration: --prefix=/usr --libdir=/usr/lib64 --enable-vdpau --enable-gpl --enable-pthreads --enable-nonfree --enable-postproc --enable-x11grab --enable-libx264 --enable-libfaac --enable-libvpx --enable-libmp3lame --enable-libdc1394
libavutil 51. 13. 0 / 51. 13. 0
libavcodec 53. 12. 0 / 53. 12. 0
libavformat 53. 9. 0 / 53. 9. 0
libavdevice 53. 3. 0 / 53. 3. 0
libavfilter 2. 34. 2 / 2. 34. 2
libswscale 2. 0. 0 / 2. 0. 0
libpostproc 51. 2. 0 / 51. 2. 0
[matroska,webm @ 0x1ce8460] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from '/path/to/IN.1080p.X264.AC3.DTS.mkv':
Duration: 01:42:33.37, start: 0.000000, bitrate: 2176 kb/s
Stream #0.0(eng): Video: h264 (High), yuv420p, 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 640 kb/s (default)
Metadata:
title : AC3
Stream #0.2: Audio: dts (DTS), 48000 Hz, 5.1, s16, 1536 kb/s
Metadata:
title : DTS
Stream #0.3(dut): Subtitle: text (default)
Metadata:
title : Nederlands
Unsupported codec with id 94210 for input stream 3
Transcoded file using the above ffmpeg options. Here I chose to use DTS audio stream. (source's stream 0.2)
Code:
$ ffprobe OUT.mp4
ffprobe version N-32077-g5f5e37e, Copyright (c) 2007-2011 the FFmpeg developers
built on Sep 2 2011 11:29:35 with gcc 4.4.4
configuration: --prefix=/usr --libdir=/usr/lib64 --enable-vdpau --enable-gpl --enable-pthreads --enable-nonfree --enable-postproc --enable-x11grab --enable-libx264 --enable-libfaac --enable-libvpx --enable-libmp3lame --enable-libdc1394
libavutil 51. 13. 0 / 51. 13. 0
libavcodec 53. 12. 0 / 53. 12. 0
libavformat 53. 9. 0 / 53. 9. 0
libavdevice 53. 3. 0 / 53. 3. 0
libavfilter 2. 34. 2 / 2. 34. 2
libswscale 2. 0. 0 / 2. 0. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'OUT.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.9.0
Duration: 01:42:33.32, start: 0.000000, bitrate: 956 kb/s
Stream #0.0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 790 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 159 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00