Log in

View Full Version : Mkv to Mp4


Eretria-chan
24th December 2007, 17:30
I have a little problem that I'd like a little help with.
So I have lots of mkv files, and of course, I need to play these videos on my handheld media player which requires me to change container to mp4.
But the problem is that I don't know how.
I've tried gdsmux from Haali, but it produces a 750 MB file from a 75 MB file with no sound. In other words, failure.
I tried Yamb, but got mixed results. Once it complains that the conversion was not supported and then it complains about incorrect syntax (mp4box just showed a help list).

I have a H264 video (23.976 FPS according to mkvinfo) and a AAC sound file that I want to remux into mp4.
I tried to enter "23.976" into yamb when muxing, but still... the results I already explained.

Can anyone help with this little dilemma?

[P]ako
25th December 2007, 16:34
It wouldn't hurt to try to mux to mp4 from a command line window. I know, YAMB is a GUI to mp4box, but I have had some problems muxing video with it. However, I have yet to have a problem muxing video with MP4BOX from a command line.

Eretria-chan
25th December 2007, 16:59
I'm pretty sure MP4BOX is fine, but I don't know how to use it from the command prompt. CLI is not my specialty and last time I checked, the documentation confused me.

foxyshadis
28th December 2007, 03:31
If gdsmux doesn't work, you need to use mkvextract (gui) to split the streams first. Since mp4box ignores framerate of raw streams, you have to make sure you set that too, when you remux. It should work fine in yamb once they're apart.

Eretria-chan
29th December 2007, 00:43
I tried that too, and I actually mentioned that in the first post. When I did that with the raw streams, either I got an error of unsupported operation or the command line to mp4box was wrong (generated by yamb).

Kurtnoise
29th December 2007, 09:10
which yamb version did you use btw ?

Anyway, if it failed with gdsmux then your mkv files are probably b0rked.

Eretria-chan
29th December 2007, 23:45
Yamb 2.008. Dunno about borked files, they all play fine and was created using mkvmerge GUI. Though admittedly, I split the original file into smaller parts, 10 minutes each.

Kurtnoise
30th December 2007, 10:57
upload a sample please...

Eretria-chan
30th December 2007, 13:44
http://www.eluni.net/temp/Sample.mkv
FPS=60.000
I open Yamb. Select to create a new mp4 file. Use mkvextract to extract all tracks (chapters, video & audio). Drop them all into yamb.
Double-click video and enter 60.000 as FPS. Click next. Yamb completes directly and no output file is created.
If I check the log, I'll see that it passes incorrect parameters to mp4box.

Source file plays fine, of course.
Does mp4box not support muxing mkv or is it just yamb?

Kurtnoise
30th December 2007, 15:08
There is indeed a problem with Yamb...I'm going to fix it right now.

and no, MP4Box doesn't support mkv files.


btw, your sample is also VFR. So, it's not tricky.

Eretria-chan
31st December 2007, 00:20
Here's another one for the log:

[00:17:47] : Yamb 2.0.0.8 started !!!
[00:17:47] : OS type detection...Windows XP Professional (version 5.1, Build 2600 : Service Pack 2)
[00:17:47] : MP4Box found... h:\apps\yamb\mp4box.exe
[00:17:47] : Tagger is missing...
[00:18:27] : x_Track1.h264 loaded.
[00:18:28] : x_Track2.aac loaded.
[00:18:30] : x_Chapters.txt loaded.
[00:18:41] : Creation of x_Track1.mp4...
[00:18:41] : Command Line used for Creation : "h:\apps\yamb\mp4box.exe" -flat -add "I:\Video\x_Track1.h264:fps=23.976" -add "I:\Video\x_Track2.aac" -chap "I:\Video\x_Chapters.txt" -tmp "H:\Temp\" -v -new "I:\Video\x_Track1.mp4"
[00:18:41] : File saved in I:\Video\
[00:18:42] : MP4Box [option] input [option]
[00:18:42] : -h general: general options help
[00:18:42] : -h hint: hinting options help
[00:18:42] : -h import: import options help
[00:18:42] : -h encode: encode options help
[00:18:42] : -h meta: meta handling options help
[00:18:42] : -h extract: extraction options help
[00:18:42] : -h dump: dump options help
[00:18:42] : -h swf: Flash (SWF) options help
[00:18:42] : -h crypt: ISMA E&A options help
[00:18:42] : -h format: supported formats help
[00:18:42] :
[00:18:42] : -nodes: lists supported MPEG4 nodes
[00:18:42] : -node NodeName: gets MPEG4 node syntax and QP info
[00:18:42] : -xnodes: lists supported X3D nodes
[00:18:42] : -xnode NodeName: gets X3D node syntax
[00:18:42] : -snodes: lists supported SVG nodes
[00:18:42] : -snode NodeName: gets SVG node syntax
[00:18:42] : -languages: lists supported ISO 639 languages
[00:18:42] :
[00:18:42] : -quiet: quiet mode
[00:18:42] : -v: verbose mode
[00:18:42] : -version: gets build version
[00:18:42] : Creation complete.
[00:18:48] : Yamb 2.0.0.8 closed.

pc_speak
31st December 2007, 04:54
Hi.
I have these programs installed.
mkvtoolnix-unicode-2.1.0-setup.exe
MP4Box-0.4.3_20070320.zip

The following 2 command lines seemed to work.

"C:\VidAud\MKVtoolnix\mkvextract" tracks "Sample.mkv" 1:"Sample.h264" 2:"Sample.mp3"
"C:\VidAud\MP4Box.exe" -fps 60 -add "sample.h264" -add "sample.mp3" "sample.mp4"

I got a playable MP4. Looks and sounds a little strange to me, but I know nothing of the clip I'm looking at.

Funny - According tp Avisynth info() your sample.mkv fps=60
And - According to Vdub File Info your sample.mkv fps=60

Something needs tweaking. Ideas? :helpful:

Kurtnoise
31st December 2007, 09:40
it's not exactly 60fps for all frames...create a timecode file from mkvextract, you'll see.

Otherwise, play the mkv and the remuxed mp4 samples with MPC and check the duration for both files. It's not the same...

Eretria-chan
31st December 2007, 20:31
I'm assuming that due to the variable frame rate, it's not just as easy as to specify a constant fps value in yamb.
I'm not sure if there's another solution to fix this? Converting mp4 to mkv is piece of cake (almost all samples was mp4 first and then converted to mkv), but the other way around...

pc_speak
1st January 2008, 12:19
A happy new year. ;);)

@Kurtnoise. Yes. You're right. Thought it was a little odd.

Added to my mix has been:
Avisynth_257.exe
MatroskaSplitter.exe
tc2mp4_20070124.rar from doom9 (password: doom9.org)
x264-563-install.exe

:p Is this closer?

p.s. I found that MP4Box.exe has to be in the same folder as the batch file for tc2mp4 to work. So I copied it there. :)



My batch file - CONVERT.CMD
-------------------------------------------------------------------------------------------
:: extract the audio from the MKV file
"C:\VidAud\MKVtoolnix\mkvextract" tracks "sample.mkv" 2:"Sample.mp3"

:: Extract the timecodes of all blocks
"C:\VidAud\MKVtoolnix\mkvextract" timecodes_v2 "sample.mkv" 1:"sample_timecodes.txt"

:: Extract all video frames from the MKV to a CFR AVI file
"C:\VidAud\MatroskaSplitter\mkv2vfr" "sample.mkv" "sample.avi"

:: Create an Avisynth script file
echo DirectShowSource("sample.avi", audio=false) >sample.avs
echo converttoyv12() >>sample.avs

:: Create an MP4 file using the AVI file and the AVS script.
"C:\VidAud\x264\x264" --progress --output sample_CFR.mp4 sample.avs

:: Merge the timecode file into the newly created mp4 file
"C:\VidAud\tc2mp4" -i sample_CFR.mp4 -t sample_timecodes.txt -o sample_VFR.mp4

:: Put back the audio file
"C:\VidAud\MP4Box.exe" -add "sample_VFR.mp4" -add "sample.mp3" "sample_VFR_Final.mp4"
-------------------------------------------------------------------------------------------

Kurtnoise
1st January 2008, 14:58
1/ Use AVISource(...) with AVI files instead of DirectShowSource(...)

2/ Are you aware that you reencode the sample this way ?

3/ yeah HaPpY NeW YeAr to you...

[P]ako
1st January 2008, 15:26
@Eretria-chan, because the video is VFR, what you need to do it is to reencode it to CFR first.

bond
1st January 2008, 15:35
you can also create a vfr mp4, but i am not sure if your player supports it:

http://forum.doom9.org/showthread.php?t=112199

pc_speak
1st January 2008, 23:47
@Kurtnoise
Are you aware that you re encode the sample this way ?
No, I wasn't. Thanks. :)

So, I changed the batch file. Crashed. Ran the resultant AVS script through vdub.

AVISOURCE: Couldn't locate a decompressor.....

Rats!

Now I remember. I was getting some quirky results with ffdshow on another project and un-installed it.
I live, a lot, at the command prompt. Guess I'll have to install a decompressor.

@Eretria-chan. I'd definitely use AVISource(....)

Eretria-chan
2nd January 2008, 09:18
Sources aren't AVI. Non-mp4 sources are ogm and mkv (most anyway, there are a few avi), so AVISource won't work.

pc_speak
2nd January 2008, 20:40
After MatroskaSplitter gives you an AVI file, AVISource(...) will work on it. That will/should allow for converting all the MKV files.
Don't know about the OGM files though.

Eretria-chan
11th January 2008, 18:30
Alright, so let's take this a step further.
Obviously their support SUCKS since they can't even reply to support questions about helping getting video files to play. Their manual is worthless since it doesn't mention specs or profiles of what's supported or not nor can provide information of a software or any type of hints on how to make incompatible videos play.
So I'm turning to the helpful Doom9.org community. If anyone can guess what typical features a handheld device does not support and how to re-encode the video to the right format, using any given tool, such as MeGUI to do the job. I know how to encode videos, but I don't know what profile or settings should be used to make compatible videos. Any ideas?

EDIT: Nevermind. It seems there are threads about the profiles to use out there. I'm going to experiment.