PDA

View Full Version : convert h.264 for xbox 360


admadm
5th January 2008, 23:57
hi all

im new to encoding etc.have many x264 files which i would like to know if it is possible to convert extract h264 to play on media centre streamed to xbox 360.ive tried a few things with no results i:e mkvextract jamb and then merge but never had any that would play i use ccc pack and all play fine on pc with classic media player.any help or a point the correct direction would be very much appreciated.

thankyou

neuron2
6th January 2008, 18:41
@admadm

Please read our forum rules. You should open a new thread for your problem and not tack on to an existing unrelated thread (forum rule 3). And you should not crosspost the same message to different forums (forum rule 8).

phoenixdigital
23rd January 2008, 04:18
Here is a good guide I wrote that works in windows... to work in linux it would require only a few modifications.

http://www.phoenixdigital.com/mp4_creation_with_mencoder/

BoNeCrUsHeR
23rd January 2008, 17:44
Files used:

MKVMerge (http://www.bunkus.org/videotools/mkvtoolnix/downloads.html) (to split original file)
MKVExtract (http://www.bunkus.org/videotools/mkvtoolnix/downloads.html) (extract raw h264+audio)
Binreplace.exe (http://forum.doom9.org/attachment.php?attachmentid=7842&d=1196710535)
(see this thread (http://forum.doom9.org/showthread.php?p=1072312#post1072312) for more info on IDC Level. - Assumes HighProfile@L51 )
Nero AVC Encoder (http://www.nero.com/eng/down-ndaudio.php)
Belight (http://coreforge.org/projects/belight/) (and of course Besweet (http://besweet.notrace.dk/BeSweetv1.5b31.zip)). I have used MeGui (http://sourceforge.net/project/showfiles.php?group_id=156112) to transcode audio with success, also.
mp4box (http://kurtnoise.free.fr/mp4tools/) (Link below for newest.)

Optional: MKVExtractGUI (http://coreforge.org/frs/?group_id=33&release_id=17)
Optional: HEdit (http://www.yurisw.com/HEdit30.zip) hexeditor works well for this.
Optional: MediaInfo CLI (http://sourceforge.net/project/showfiles.php?group_id=86862&package_id=90612)


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

I get best results doing these steps:


Splitting
Split 4GB or greater movie in half. (If MKV use MKVMErge --split timecode option. Use MPC to find a halfway point...) (Xbox360 won't play >4GB)

Extracting
Extract Raw h264 + audio (ac3/mp3/etc) using something like MKVExtract/etc. MKVExtractGUI or CLI.

Level
If h264 idc level is >41 (51) then must be set back to 41.
(Xbox/PS won't play profiles above 41) (Use a hex search/replace tool like binreplace.) eg:
"binreplace (filename.h264) 0167640033 0167640029" (On both h264 raw files you have extracted.)
Or some say you can use h264info app, but it screws it up for me when trying to change idc profile. Also takes lot longer. Edit 05/2008: Just tested a newer version. Still screws up file.. or simply doesn't change anything at all! Don't Use!

------------------------
NOTE: (05/2008)
Some h264 files have different headers. (http://forum.doom9.org/showthread.php?p=1073955#post1073955) Binreplace as stated above is searching for "high profile + 51". The only way to know for sure (if binreplace tells you it found nothing), is to either change search/replace string in binreplace or simply hexedit it. You can also do a quick test with MediaInfo tool, and see what IDC/MP-4 Level it shows. MediaInfo CL works well for this:
mediainfo <filename.h264>

or even:
mediainfo <filename.mkv>


You should see something similar to:

Codec profile : Main@L5.1
or
Codec profile : High@L5.1
Fixed:
Codec profile : Main@L4.1
Codec profile : High@L4.1

5.1 is all we are worried about, though. If it says 5.1 then you will have to manually change the 8th byte in the raw .h264 file using a hexeditor from "33" to "29". (This is basically all binreplace is doing, anyway!) It is probably easier and more direct to just open the raw file with a hex editor, and check it, but hopefully you get the idea. I have CLI/CMD open anyway, and just run it through that first before opening in hexeditor (if needed.)

Apparently, the 360 and PlayStation only check the first occurrence of IDC/MPEG-4 Level.

Example of hexedit OF 8th byte:
http://img.photobucket.com/albums/v475/bncrusher/hex1-1.jpg
------------------------

Transcode Audio
Update to newest version of belight/besweet, btw.
Transcode audio from ac3/mp3/dts/ogg to Stereo LC-AAC.
I get best results from simply using belight/besweet.
Choose neroaacenc/ND/nero for best results.
USE LC PROFILE + STEREO!! bitrate vs. quality setting shouldn't matter...For HQ just use 256.
(Xbox won't play HE-profiles or 5.1 audio in h264/mp4 containers).
You should now have your two audio files.


MP4Box
Now you should have 2 raw hexedited .h264's and 2 aac audio files to go with them.
Grab yourself "mp4box" app if you don't have it:
MP4Box (newest version as of 5/2008 = 13-Apr-2008 10:49) (http://kurtnoise.free.fr/mp4tools/MP4Box-0.4.5-dev.zip)

Final MUX:
mp4box -add "x:\filename-001.h264:fps=23.976" -add "x:\filename-001.m4a:lang=en" "x:\newfile-001.mp4"
(let run, then do 2nd file mux: )
mp4box -add "x:\filename-002.h264:fps=23.976" -add "x:\filename-002.m4a:lang=en" "x:\newfile-002.mp4"
(do both of course!)

FPS is important as mp4box defaults to 25fps. If you have progressive/film you need this option on command line!
Also, your audio file may have different extension: (aac/mp4/m4a).
You now have a h264 compressed HD movie split under 4gb which will play on Xbox 360! (Streamed or burned or thumbdrived.) :)
You retain original video quality because no transcoding (other then audio) is involved.
BTW I get best results by cutting/splitting movie in half before any other steps. In other words use MKVMerge before everything else!


If you use these steps, it takes me < then an hour to process a >4GB movie.
EDIT (5/2008):
Now 10 minutes on my E8400 CPU (4GB helps, too).

Good luck.
-bC

Amir
30th January 2008, 13:51
I just use automkv and make an mp4, use nero_enc for the audio, VERY simple and works great.

BoNeCrUsHeR
30th January 2008, 22:30
I just use automkv and make an mp4, use nero_enc for the audio, VERY simple and works great.

I just got it and looked at it. "Frontend" basically for above. So does this like "transcode" the entire movie from h264 <> h264?? Why do that? Also, I have seen many movies/videos encoded for "IDC 51". Does this frontend change IDC level so it can be played on xbox? I see it does have an 'xbox' profile for x264 encoder. As I mentioned, I DO use (besweet/belight/neroaacenc). Which you can also do with this. If you want to "re" encode >4gb movies split in half/thirds, be my guest :) (If I am wrong let me know as I haven't tried playing with it yet..)

bC

hfmls
31st January 2008, 11:39
that's really fast, now what is the best way, faster to hardsub those mp4?

Ranguvar
31st January 2008, 12:27
that's really fast, now what is the best way, faster to hardsub those mp4?
TextSub() AviSynth... and re-encode...

ZeroColl
8th February 2008, 18:13
A while ago I used GOTSent for this "conversion", but I switched to vista x64, where it doesn't work. So I made myself a tool that uses other existing tools to do this.

It uses MKVextract to get both streams.
Then it changes the h264level to 4.1 (really fast, just rewrites some bytes)
After that I convert the audio to stereo acc, using a tool that makes a wav and then the nero encoder to encode to ACC.
And at the end it is all merged together in a MP4 container with MP4Box.

if the file is larger than 4GB it is split and two (or more) output files are created.

It is as simple as it gets, choose input file, output folder and click convert.

If someone wants to try it out: http://rapidshare.com/files/87075009/MKVBoxer-0.1b.zip.html

But keep in mind, that is really a early stage build.

dwallersv
24th May 2008, 16:02
Okay, all this sounds great (and works), except I can't seem to get WMP11 on XP to see MP4s so I can stream them via media sharing to my 360.

Any insights/clues?

Thanks!

BoNeCrUsHeR
24th May 2008, 17:56
Okay, all this sounds great (and works), except I can't seem to get WMP11 on XP to see MP4s so I can stream them via media sharing to my 360.

Any insights/clues?

Thanks!

For me the only reason I want WMP to 'see' MP4 is to allow 360 playback. Unfortunately, it has to be able to play them to be able to 'see' them. Once it see's them it can put them in the Library for 360 to 'see' them. I use Media Player Classic (http://sourceforge.net/project/showfiles.php?group_id=205650&package_id=245753) for playing vid's on computer, personally.

First download and install CCCP (http://www.cccp-project.net/download.php?type=cccp).
When installing make sure you install Haali Splitter and set it up for at least MP4/OGM support.

After installing CCCP/FFDshow, try and play an MP4 file under WMP. If that works, add the path/folder for MP4 files to your library and allow connection from Xbox360. (WMP11 - under Options/Library).

At this point you should see WMP populate it's library with video files of desired type.

Under 360 make sure 'Media'/'Videos' is seeing your(correct) computer.
Find folder where video's are, and load 'em up!

Reference: (See MP4 section): MS article on supported formats for WMP (http://support.microsoft.com/kb/316992)

EDIT (05/2008):
I own Vista 64bit. You may have problems sharing with 360 using .mp4 extensions. Make sure you install above-CCCP (Vista Codec Pack x64 may not help), and make sure you are seeing .mp4's coming up in 32-Bit WMP11. Then check on 360...
-

kwanbis
26th May 2008, 19:28
I have been trying to make this work for me. So here is what i do:

mkvmerge -i a.mkv
File 'a.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AC3)

mkvextract tracks a.mkv 1:video.h264 2:audio.ac3
Extracting track 1 with the CodecID 'V_MPEG4/ISO/AVC' to the file 'video.h264'.
Container format: AVC/h.264 elementary stream
Extracting track 2 with the CodecID 'A_AC3' to the file 'audio.ac3'. Container f
ormat: Dolby Digital (AC3)

profile41 video.h264 (you can download profile41 with sources here (http://forum.doom9.org/attachment.php?attachmentid=8444&d=1211851534))
H.264 Raw Video Profile Modifier. It modifies byte 8 to be version 4.1 (41)
00 00 00 01 67 64 00
Starting bytes DO match expected ones...
H.264 Level is 5.1 (51)
Changing H.264 Level to 4.1 ...
Press ENTER to end ...

eac3to.exe audio.ac3 audio.wav
AC3, 2.0 channels, 0:00:58, 384kbit/s, 48khz, dialnorm: -24dB
The Nero decoder doesn't seem to work, will use libav instead.
Removing dialog normalization...
Loading white noise (needed for dithering)...
Writing WAV...
Creating file "audio.wav"...
eac3to processing took 1 second.
Done.

neroaacenc.exe -q 1 -lc -if audio.wav -of audio.aac
udio.aac
Processed 57 seconds...

mp4box -add "video.h264:fps=23.976" -add "audio.aac:lang=en" "newfile.mp4"
Saving to newfile.mp4: 0.500 secs Interleaving

NOTE: QuitckTime can not play the file, but, for example Media Player Classic is perfect. Thanks BoNeCrUsHer.

NOTE: There is this XenonMKV (http://mkv.jakebillo.com/) application that does all automatically. I just had to replace the mp4box with the 4.5-dev.

BoNeCrUsHeR
26th May 2008, 21:21
I have been trying to make this work for me. So here is what i do:
...

Quick answer?:
Use besweet or belight to change audio fps? And mkvinfo says "Interlaced: 0" but this might be something to look at. Also, examine the audio aac produced.
I don't see any problems other then fps? And I use belight to convert ac3 > aac.

This definitely sounds like a frame rate issue, though.

kwanbis
26th May 2008, 21:58
Quick answer?:
Use besweet or belight to change audio fps? And mkvinfo says "Interlaced: 0" but this might be something to look at. Also, examine the audio aac produced.
I don't see any problems other then fps? And I use belight to convert ac3 > aac.

This definitely sounds like a frame rate issue, though.
Sorry, i more or less get the idea of what you are talking about, but no so much as to try something.

Also, it looks like it only shows each 7/7.5 frame, like at 1 sec, at 7/8 secs, at 15/16 secs, etc.

Last, if the problem is on the sound, how comes i can heard well but no see?

BoNeCrUsHeR
26th May 2008, 22:25
Sorry, i more or less get the idea of what you are talking about, but no so much as to try something.

Also, it looks like it only shows each 7/7.5 frame, like at 1 sec, at 7/8 secs, at 15/16 secs, etc.

Last, if the problem is on the sound, how comes i can heard well but no see?

Again, I think you are muxing two different frame rates together.

Maybe try this:
eac3to.exe -24p audio.ac3 audio.wav
See:
EAC3TO Post/Command Line usage. (http://forum.doom9.org/showthread.php?p=1004685#post1004685)

I just did some snooping and saw the -24p (your video is 23.976 fps - Progressive - or so it says.) option. I have never used this tool before, though. I also said to try Belight (http://coreforge.org/projects/belight/), with Besweet (http://besweet.notrace.dk/BeSweetv1.5b31.zip) installed. <- Use those to convert your audio from AC3 to AAC in Belight. Of course neroaacenc.exe (http://www.nero.com/eng/down-ndaudio.php) needs to be used - but it looks like you used that. There is also a newer version of mkvtoolnix/mkmerge (http://www.bunkus.org/videotools/mkvtoolnix/downloads.html) out.

In response to your question, you hear sound because there is nothing wrong with your audio file. It plays fine, I'm sure. Just isn't "synced" up to slower video speed... (?)

kwanbis
27th May 2008, 00:47
Again, I think you are muxing two different frame rates together... In response to your question, you hear sound because there is nothing wrong with your audio file. It plays fine, I'm sure. Just isn't "synced" up to slower video speed... (?)
You mean that even if the MKV file plays perfectly, the individual parts could be wrong?

Maybe try this:
eac3to.exe -24p audio.ac3 audio.wav
Do you know how to use besweet (CLI no GUI), to do what you tell me to?

kwanbis
27th May 2008, 01:07
Maybe try this:
eac3to.exe -24p audio.ac3 audio.wav
See:
EAC3TO Post/Command Line usage. (http://forum.doom9.org/showthread.php?p=1004685#post1004685)
I just tried that, and it is worst.

The file goes from 1.5 GB to 2GB (?), and the video is still there, but it shows from time to time.

dwallersv
27th May 2008, 01:36
Maybe this will help...

I solved my problem by abandoning sharing via WMP11, and am now using TVersity (www.tversity.com).

It's in beta, and has some annoying usability issues, but it works well for what I needed -- sharing/streaming to my Xbox. A bonus with this app is that it will transcode on the fly, so you can share mkv's and just about any format with your xbox if it isn't directly supported.

Pros:

Media sharing with many devices, including xbox360 and PS3. Cell phones, etc. Similar to Orb in this regard.
On the fly transcoding enables support for formats/containers not supported by target device.
Streams native High profile x264... Zune won't
Remote management interface

Cons:

UI is not very well designed at this point, a bit of a learning ramp to get smooth using this app.
Transcoding is very CPU intensive at this release; my 3GHz quad extreme goes 100% transcoding 720p material in realtime. I get roughly 3x realtime when transcoding with x264 in Megui. Needs work. No matter -- don't be lazy, just use something like GOTSent to remux mkv's to mp4's and your fine.
Library management bugs... don't delete anything from your library, you won't be able to put it back without uninstalling and reinstalling the app! (I'm sure this will be fixed pretty soon... seems like a major problem)

dwallersv
27th May 2008, 01:56
I have been trying to make this work for me. So here is what i do:

[elided]Your procedure looks right, although I suspect the binreplace step may be where your problem is.

Unless you have some reason to stick to WMP for building and sharing your library, you can solve all of this by just using Zune or TVersity. The latter solution is the best I've found so far, as it doesn't barf on AVC High profile video (Zune doesn't like it), and GOTSent will do the job for automated container conversion from mkv to mp4.

BoNeCrUsHeR
27th May 2008, 02:01
Maybe this will help...

Cons:


It's a transcoder.
Not everyone has a super fast cpu, and to me it never looks as good as the real thing. I have an e8400 w/ 4gig but again the vid qual goes down. imo. Since we are presumably talking about .mkv (one of the formats that the 360/wmp11 can't stream), we are simply talking about transcoding. I believe even GotSent will only transcode to another 'acceptable' format. Correct me if I am wrong.

In this thread I am talking about preserving original video quality. We are not touching original 264 file. Just putting into different container format. (mp4).

kwanbis
27th May 2008, 02:03
I just happen to have MKV files i want to watch on my Xbox 360.

I'm not sharing anything. I just want to put the MP4 to a pen drive and watch the video.

Also, i have manually done the binereplace part (with an hex editor), so it SHOULD be fine.

kwanbis
27th May 2008, 02:33
I have uploaded a 50 secs sample of the MKV, made the same way as the full file.

Its a 50 secs sample of a TV show.

I don't know if it is ok to post the link here.

Before somebody asks i have bought the original episodes on iTunes.

BoNeCrUsHeR
27th May 2008, 02:36
I just tried that, and it is worst.

The file goes from 1.5 GB to 2GB (?), and the video is still there, but it shows from time to time.

Then maybe we had it reversed and video is faster then audio?
You should probably run the original .mkv through some media info tool and see what kind of info it gives you. (See if the framerate is diff then what mkvextract said). Maybe it's 25fps? Try mp4box without the fps= option. (Defaults to 25fps). Use the original version of audio file. (without -24p option). See what happens....

BoNeCrUsHeR
27th May 2008, 02:38
I have uploaded a 50 secs sample of the MKV, made the same way as the full file.

Its a 50 secs sample of a TV show.

I don't know if it is ok to post the link here.

Before somebody asks i have bought the original episodes on iTunes.

Simple answer: If it's copyrighted (C) material then don't.
You uploaded.. where?

kwanbis
27th May 2008, 02:42
I uploaded to rapidshare, so nobody knows if i don't give the link, and i can delete as soon as i want.

I thought 50 secs samples where harmless.

Anyway. What other app can give me info on the mkv?

kwanbis
27th May 2008, 02:46
Then maybe we had it reversed and video is faster then audio?
You should probably run the original .mkv through some media info tool and see what kind of info it gives you. (See if the framerate is diff then what mkvextract said). Maybe it's 25fps? Try mp4box without the fps= option. (Defaults to 25fps). Use the original version of audio file. (without -24p option). See what happens....
No, new version shows first image at 21 secs, then at 24, and then it hangs quicktime.

Also, on my wife's MacBook, same thing.

kwanbis
27th May 2008, 03:25
3. If h264 idc profile is >41 (51) then must be set back to 41.
(Xbox won't play profiles above 41) (Use a hexediter like binreplace.) eg:
"binreplace (filename.h264) 0167640033 0167640029" (On both h264 raw files you have extracted.)
Or some say you can use h264info app, but it screws it up for me when trying to change idc profile.
Also takes lot longer.
I have created this very simple program that given a RAW H.264 file, it checks the first 8th bytes to see if it is version 41, and if not, it updates it.

I assumed that the profile version would be always on the 8th byte, right?

I have included the sources (borland delphi).

BoNeCrUsHeR
27th May 2008, 17:10
I have created this very simple program that given a RAW H.264 file, it checks the first 8th bytes to see if it is version 41, and if not, it updates it.

I assumed that the profile version would be always on the 8th byte, right?

I have included the sources (borland delphi).

Yes your only changing hex 33 to 29 at beginning of file. I believe binreplace searches the whole file for matches of hex string. So if nothing else, yours is precise. :)

kwanbis
27th May 2008, 17:25
And faster ;)

BoNeCrUsHeR
27th May 2008, 20:19
And faster ;)

NOTE:

And you mentioned the 8th hex byte. Yes, and a note to everyone that some vid's are out which have a different header then what binreplace looks for. So use a (hexeditor or above tool) if media info tool still is saying 5.1. (8th Byte - change 33 to 29 hex). This fools the Playstation/Xbox into thinking the whole file is Profile 4.1. I think every frame is coded this way, but consoles are only looking at beginning (8th Byte) for profile info. (Luckily)

kwanbis
28th May 2008, 16:18
OK, so it works fine.

Now, i would have to see how to hardcode the subtitles to the H264 file before muxing to MP4....

BoNeCrUsHeR
28th May 2008, 18:41
OK, so it works fine.

Now, i would have to see how to hardcode the subtitles to the H264 file before muxing to MP4....

Hardcode? By definition you have to re-encode/transcode to get permenent subtitles. You can use avisynth script for this. (try Megui maybe if you don't like setting it up yourself?) If you have a player that can read 'soft' enbedded subs you do it this way:

mp4box -add "sample_Track1.h264:fps=23.976" -add "sample_Track2.mp4:lang=en" -add "sample_Track8-eng.srt:lang=en" "test-subs1.mp4"


Text formats and extensions:

* SRT Subtitles (.srt)
* SUB Subtitles (.sub)
* QuickTime TeXML (.xml) - cf QT documentation
* GPAC Timed Text (.ttxt)

Reference:
GPAC/MP4Box Sourceforge site. (http://gpac.sourceforge.net/doc_mp4box.php)

If you have other format subtitles, you can convert them with newest Subtitle Workshop. (http://www.urusoft.net/downloads.php?lang=1) Get the newest Beta at top. Save your converted subs as "SubRip / SRT".
This will make it easier to import with other programs...
mp4box can also convert VobSub (.idx/.sub) formats as per documentation link above.

cheer
1st June 2008, 18:13
FYI, I tried BoNeCrUsHeR's workflow as listed back in message #4 (http://forum.doom9.org/showthread.php?p=1091055#post1091055) of this thread, and it worked flawlessly. Edit: note that I'm not messing with subtitles at this point.

I've long used an X-Box (classic) as a media player with XBMC, but it doesn't really have the horsepower for HD vids. I have a large stockpile of things I'd been encoding as MKV/AVC/DD (from OTA recordings and whatnot) for the day I replace it with a media PC, but thanks to this I can just use my X-Box 360.

It's a shame about losing the 5.1 audio, but I think that's a small sacrifice to pay to avoid re-encoding the video. Combined with TVersity, I may not need my old X-Box for anything anymore.

Thanks, BoNeCrUsHeR!

--chris

BoNeCrUsHeR
3rd June 2008, 02:35
...
I've long used an X-Box (classic) as a media player with XBMC, but it doesn't really have the horsepower for HD vids. I have a large stockpile of things I'd been encoding as MKV/AVC/DD (from OTA recordings and whatnot) for the day I replace it with a media PC, but thanks to this I can just use my X-Box 360.

It's a shame about losing the 5.1 audio, but I think that's a small sacrifice to pay to avoid re-encoding the video. Combined with
TVersity, I may not need my old X-Box for anything anymore.
...


Thanks, and I am glad it is working for you. Keep in mind that XBMC will do .srt/etc subs (and most anything else), while the 360 (at present) will not.

cheer
9th June 2008, 01:20
Thanks, and I am glad it is working for you. Keep in mind that XBMC will do .srt/etc subs (and most anything else), while the 360 (at present) will not.

Good point. XBMC has a superior interface (IMHO) as well, but the hardware limitations of the classic X-Box are rearing their collective head. As it were.

Still, I suppose eventually I just need to pop for a linux-based media center and avoid all of this. I really miss the Dolby 5.1 and DTS support.

BoNeCrUsHeR
9th June 2008, 06:05
Good point. XBMC has a superior interface (IMHO) as well, but the hardware limitations of the classic X-Box are rearing their collective head. As it were.

Still, I suppose eventually I just need to pop for a linux-based media center and avoid all of this. I really miss the Dolby 5.1 and DTS support.

Yes. I am surprised that companies as whole haven't exploited that market niche, yet. (Not quite a niche anymore-especially with HD/digital getting more popular.) But a few companies have some decent stuff out. Oppo, KiSS, and of course xbox360 come to mind. It's looking grim (last time I checked) for a "XBMC-360" ever coming out. Just cross your fingers that MS will include srt/subs and improve the interface a bit. (Of course I would have bet money that they never would have put mpeg-4 compatibility on it either!) I was so happy the day they did that!

I haven't researched media players in awhile, so if you know of something better (from above) let me know...

See this:
Media Player Buying Guide (http://forum.doom9.org/showthread.php?t=98228) (doom9-see last few pages of thread as it was post a long time ago).

(BTW- Ziova's (http://www.ziova.com/cs615_specs.php) are due out in week according to their website...can play just about everything including .srt subs, h264 and HD)... and does MS networking!