xboxscene.org forums

Author Topic: Mkv (h264) To Mp4  (Read 133 times)

M3_DeL

  • Archived User
  • Hero Member
  • *
  • Posts: 1190
Mkv (h264) To Mp4
« on: February 05, 2008, 09:39:00 PM »

CODE

mkvinfo file.mkv  //This is to determine which track the video and audio is

mkvextract tracks file.mkv 1:video.h264 2:audio.ac3  //This varies, of course, depending on what tracks the audio/video is on.

hexedit video.h264 //I change the 67 64 00 33 byte to 67 64 00 29. This is to replace what h264info does to change the level from 5.1 to 4.1. According to MP4Box's analysis of the resulting mp4 the file is in fact seen as a 4.1 file.

mkfifo audiodump.wav //to create a dummy wav file for mplayer to dump the audio into

neroAacEnc -lc -ignorelength -q 0.50 -if audiodump.wav -of audio.m4a & mplayer audio.ac3 -vc null -vo null -channels 2 -ao pcm:fast //This is converting the ac3 to aac in a m4a container using the low complexity stereo that the xbox 360 requires.

MP4Box -add video.h264 -add audio.m4a -fps 23.976 newfile.mp4 //re-mux your new and improved video (with 4.1 level) and audio (aac-lc stereo) into a mp4 container.


This file runs great in linux and windows. Not so much on the Xbox. Now here is the kicker. I follow the same steps in windows using the same tools (different hex editor and megui with nero's encoder) and the file works. I do not use h264info to change the levels. Furthermore I check the files details with MP4Box -info and the results are identical. Can someone hook a brother up?
Logged

M3_DeL

  • Archived User
  • Hero Member
  • *
  • Posts: 1190
Mkv (h264) To Mp4
« Reply #1 on: February 11, 2008, 05:50:00 PM »

CODE

mkvinfo file.mkv  //This is to determine which track the video and audio is and what type of audio is being used (dts, ac3, etc)

mkvextract tracks file.mkv 1:video.h264 2:audio.ac3  //This varies, of course, depending on what tracks the audio/video is on. Also this example is for ac3 audio, If your audio happens to be DTS or any other format just replace the .ac3 with the appropriate extension.

hexedit video.h264 //I change the 67 64 00 33 byte to 67 64 00 29. This is to replace what h264info does to change the level from 5.1 to 4.1. According to MP4Box's analysis of the resulting mp4 the file is in fact seen as a 4.1 file.

mkfifo audiodump.wav //to create a dummy wav file for mplayer to dump the audio into

neroAacEnc -lc -ignorelength -q 0.20 -if audiodump.wav -of audio.m4a & mplayer audio.ac3 -vc null -vo null -channels 2 -ao pcm:fast //This is converting the ac3 to aac in a m4a container using the low complexity stereo that the xbox 360 requires. If the audio is dts then just change the .ac3 to .dts

MP4Box -new fileoutput.mp4 -add video.h264 -add audio.m4a -fps 23.976 //re-mux your new and improved video (with 4.1 level) and audio (aac-lc stereo) into a mp4 container.
Logged

M3_DeL

  • Archived User
  • Hero Member
  • *
  • Posts: 1190
Mkv (h264) To Mp4
« Reply #2 on: February 18, 2008, 12:10:00 PM »

I am not looking into encoding these video files. Thank you!


Updated: 2/17/2008 8:00pm

Many Props to this post:
http://ubuntuforums....ad.php?t=548547

Here is the process I use to conver MKV files (with AC3 audio) to MP4's that can play on an Xbox 360

First we need to get and install gpac tools that actually work for files larger than 2gb.

CODE

cd ~
wget http://downloads.sourceforge.net/gpac/gpac-0.4.4.tar.gz
tar -xzf gpac-0.4.4.tar.gz


Now we want to get a patch file that will fix the 2gb limit in the linux MP4Box

The patch is located HERE

Copy the following into a file named "gpac.patch" (without the quotes) in you home dir (outside of the dir named gpac
CODE

diff -rc gpac/src/Makefile gpac-0.4.4-os_drivers/src/Makefile
*** gpac/src/Makefile     2007-05-08 17:15:25.000000000 +0200
--- gpac-0.4.4-os_drivers/src/Makefile  2007-07-01 02:14:16.000000000
+0200
***************
*** 90,95 ****
--- 90,102 ----
  CFLAGS+=-DGPAC_BIG_ENDIAN
  endif

+ #4- flags used in utils/os_divers.c
+ ifeq ($(CONFIG_LINUX), yes)
+ CFLAGS+=-DCONFIG_LINUX
+ endif
+ ifeq ($(CONFIG_FREEBSD), yes)
+ CFLAGS+=-DCONFIG_FREEBSD
+ endif

  ## libgpac scenegraph compilation and linking options
  SCENEGRAPH_CFLAGS=


Next we want to apply the patch

CODE

patch -p0 < gpac.patch


Now that the makefile is patched lets continue on by installing the app

CODE

cd ~/gpac
chmod +x configure
./configure
make
sudo make install


Other apps to install  (this is for debain and ubuntu distros, if you have a different distro install using what ever package manager you have available (yum, emerge, etc)

CODE

sudo apt-get install mkvtoolnix hexedit mplayer


Then you need neroAacEnc. You may download it for free here:
http://www.nero.com/...-aac-codec.html
Unpack linux directory, chmod +x neroAacEnc and copy it to a location of your choice (whitin the path, like /usr/bin)

That should do it! Now go ahead with the steps below and make some stereo MP4's for your xbox from MKV's Lets hope soon Microsoft allows for 5.1 MP4's


I still would like to code this into a smart script (maybe in ruby?!?!?) to do all of this for you (determine what audio format, etc) Any help would be appreciated. I mention Ruby as that is what I am currently learning. But enough babble read on!

CODE

mkvinfo file.mkv  //This is to determine which track the video and audio is and what type of audio is being used (dts, ac3, etc)

mkvextract tracks file.mkv 1:video.h264 2:audio.ac3  //This varies, of course, depending on what tracks the audio/video is on. Also this example is for ac3 audio, If your audio happens to be DTS or any other format just replace the .ac3 with the appropriate extension.

hexedit video.h264 //I change the 67 64 00 33 byte to 67 64 00 29. This is to replace what h264info does to change the level from 5.1 to 4.1. According to MP4Box's analysis of the resulting mp4 the file is in fact seen as a 4.1 file.

mkfifo audiodump.wav //to create a dummy wav file for mplayer to dump the audio into

neroAacEnc -lc -ignorelength -q 0.20 -if audiodump.wav -of audio.m4a & mplayer audio.ac3 -vc null -vo null -channels 2 -ao pcm:fast //This is converting the ac3 to aac in a m4a container using the low complexity stereo that the xbox 360 requires. If the audio is dts then just change the .ac3 to .dts

MP4Box -new fileoutput.mp4 -add video.h264 -add audio.m4a -fps 23.976 //re-mux your new and improved video (with 4.1 level) and audio (aac-lc stereo) into a mp4 container.


Interesting information about MP4Box and files larger than 2GB (FIXED with the patch above)
http://sourceforge.n...;group_id=84101
Logged

chronniff

  • Archived User
  • Newbie
  • *
  • Posts: 1
Mkv (h264) To Mp4
« Reply #3 on: February 26, 2008, 08:43:00 AM »

Seriously this is the first approach that I have found online that has actually worked....and trust me I searched....have you tried using ffmpeg like I see everyone else saying they do? I haven't been able to get it to work, but everyone seems to say that it does
Logged

tangwrangler

  • Archived User
  • Newbie
  • *
  • Posts: 2
Mkv (h264) To Mp4
« Reply #4 on: March 09, 2008, 11:13:00 AM »

CODE
MPlayer 1.0rc2-4.1.3 (C) 2000-2007 MPlayer Team
CPU: AMD Athlon(tm) 64 Processor 3000+ (Family: 15, Model: 31, Stepping: 0)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing audio.ac3.
libavformat file format detected.
LAVF_header: av_find_stream_info() failed
libavformat file format detected.
LAVF_header: av_find_stream_info() failed
Logged

tangwrangler

  • Archived User
  • Newbie
  • *
  • Posts: 2
Mkv (h264) To Mp4
« Reply #5 on: March 09, 2008, 11:54:00 AM »

I also wanted to ask, are files larger than 4GB playing on your xbox? I am streaming movies over my network, so I didn't think the NTFS 4gb limit would be a problem; however I can encode small movie samples that play brilliantly, but when I encode the entire movie with the exact same settings, the xbox will not play it.
Logged

xpander

  • Archived User
  • Newbie
  • *
  • Posts: 2
Mkv (h264) To Mp4
« Reply #6 on: April 16, 2008, 03:25:00 PM »

Microsoft imposed a 4gb file size limit on any format other than (drum roll) WMV! Damn inferior proprietary *&^*&%$%....
Logged

gonkle

  • Archived User
  • Full Member
  • *
  • Posts: 179
Mkv (h264) To Mp4
« Reply #7 on: December 15, 2008, 12:48:00 AM »

Hello,

is there a better way to convert the mkv to 360 compatible formats, maybe a one step solution?
I woul like to keep 5.1 Support, too.

Talking about linux of course.

greetings

gonkle
Logged

echto

  • Archived User
  • Sr. Member
  • *
  • Posts: 498
Mkv (h264) To Mp4
« Reply #8 on: December 28, 2008, 11:09:00 AM »

QUOTE(gonkle @ Dec 15 2008, 12:24 AM) View Post

Hello,

is there a better way to convert the mkv to 360 compatible formats, maybe a one step solution?
I woul like to keep 5.1 Support, too.

Talking about linux of course.

greetings

gonkle



Yeah, write a script.

beerchug.gif
Logged

M3_DeL

  • Archived User
  • Hero Member
  • *
  • Posts: 1190
Mkv (h264) To Mp4
« Reply #9 on: January 19, 2009, 06:29:00 PM »

QUOTE(gonkle @ Dec 15 2008, 01:24 AM) View Post

Hello,

is there a better way to convert the mkv to 360 compatible formats, maybe a one step solution?
I woul like to keep 5.1 Support, too.

Talking about linux of course.

greetings

gonkle



Unless you re-encode, you will lose 5.1 support. That is all there is to it..
Logged