View Full Version : x264 in mkv||mp4||avi
sarpanch
24th November 2005, 22:01
Hi everyone,
I recently shifted from DVD->XviD mode to the DVD->x264 mode & am really confused as to which container should I use.
The source has 5.1 AC3 sound and I want to keep it untouched at any cost.
Sifting through some pages at the forum, I learnt that x264 encoding can be realised in three containers,
-> avi (supports AC3)
-> mp4 (no support for AC3......as of now)
-> mkv (supports AC3)
Case 1
mkv file made using MeGUI solves the AC3 purpose but creates a new problem. The file cannot be edited. :( . On opening with VirtualDubMod, I get the following error.
Edit: I do have the latest ffdshow build with H.264 enabled in the VFW settings.
Couldn't locate decompressor for format 'ÿÿÿÿ' (unknown).
VirtualDub requires a Video for Windows (VFW) compatible codec to decompress video. DirectShow codecs, such as those used by Windows Media Player, are not suitable. Only 'Direct stream copy' is available for this video.
Case 2
For making an avi file (x264 + GKnot), I am forced to use the vfw interface of x264 which again I have read at the forum is not the best thing to do.
Which method should be followed?
Is going with the avi format too big a "sacrifice" to keep the file editable.
charleski
24th November 2005, 23:14
What we call 'avi' is really a pile of kludges that have been shoehorned in over the past decade. Witness the massive buggy 'codec packs' that float around and all the problems newbies have playing files because they don't have the right filter installed. A lot of this happened because there were no clear standards at the time for mpeg-4.
With the move to h.264 it's good to make a clean break with that. There are definite clear standards, and if we want to produce material that will be worth archiving and be playable 5-10 years from now without having to hunt out some obscure fix, it's best to stick to those standards.
That's why people frown on putting h.264 in avis :).
Personally, I wouldn't be too concerned over recompressing ac3 to LC AAC, if you use one of the higher bitrates it's unlikely you'd be able to detect any difference.
Doom9
24th November 2005, 23:18
-> mp4 (no support for AC3......as of now)That will never change.. you can put anything in an mp4 via private data but that means proprietary, and thus shouldn't be an option. You can always edit files with mkvtoolnix. Matroska can natively store AVC and ASP and VirtualDubMod can only handle the VfW compatibility mode and that may never change. Likewise you can edit mp4 with mp4box.. it's not as nice as VDub but doable.
sarpanch
25th November 2005, 11:34
Thanks for sharing the info, guys.
That will never change.. you can put anything in an mp4 via private data but that means proprietary, and thus shouldn't be an option.
Thats why Case 3 was never opened. ;)
Coming to the editability of mkv files, I have searched extensively & still haven't found a tool that can handle the format in my desired way. I want to delete out frame no 600-700 & keep the rest of the clip as such (direct stream copy). With avi's, this was a piece of cake using VDM but it simply refuses to open mkv.
(Arrgh.. why did TCME die!!)
If I encode in the avi container now, compatibility with the standard format is lost.
Now the most important question, does the quality of the encode suffers too?
If not, then I may use avi for the time being, because given the potential & progress of Matroska, am sure a VDM alternative is not far.
stephanV
25th November 2005, 11:59
You can never be guaranteed that you can remove frame 600-700 after compressing to h264 (or any delta-predicted format). You should edit before you compress.
As for your question, using AVI doesn't hurt the quality of your file and it is still always possible to go from AVI to native h264 MKV. (being it somewhat awkward)
bond
25th November 2005, 14:11
first of all encode with megui to .mp4 and not with gknot
now either
1) keep the .mp4 and reencode the ac3 to aac which you can place in mp4. you can cut, append aso with mp4box
2) remux the .mp4 to .mkv with mkvmerge together with the ac3
do not remux from avi to mkv! that will not give you a native avc stream in mkv
sarpanch
25th November 2005, 14:46
As for your question, using AVI doesn't hurt the quality of your file
Thats good to hear. :)
@bond
The method you posted is the way it should be.
For normal encodes, I follow the " d2v->avs->MeGUI->mkv+ac3 " route
But in this case, I have to leave out some frames which isn't possible with mkv.
I even tried the mp4 output with MeGUI to make it open in mp4box. But I guess its still in early stages (mp4box) as it could not split the file in the given range.
(For some reason, it outputs 0-y seconds even if you feed a value of x-y seconds)
So I guess avi is the best option to maintain editability.
bond
25th November 2005, 17:16
you can only split at keyframes! mp4box or any other tool, like virtualdub, cant do it differently
thats why stephanv wrote that you should cut the input (eg via avisynth's trim() function), as you cant be sure that you are able to cut the output where you want
Hellworm
25th November 2005, 17:17
To leave out frames you can of course edit the avs and use the trim function.
The Problem is, that you'd have to edit the ac3 with some extra program.
SeeMoreDigital
25th November 2005, 17:39
-> mp4 (no support for AC3......as of now) I think it's a real shame more people don't encode to 6Ch AAC.
I guess the issue of not having external DSS amplifiers fitted with AAC decoders hasn't helped the situation :(
Cheers
sarpanch
25th November 2005, 19:33
@bond
By dropping frames, I meant
/Loading the clip in VD
/Direct Stream Copy
/Selecting a frame range
/Hitting the delete button.
Trust me, it works for x264-GKnot generated avi's with non keyframes too. :|
(I deleted arbitrary no. of frames, saved the rest of the clip & it plays perfectly)
This way, I don't have to deal with avisynth trim, audio editing, audio sync issues etc :)
Considering the AAC option, being an audiophile, I cannot even imagine destroying the AC3 source to a 250-256 kbps AAC. Never!
Coming to the issue of avc in avi, some people say that it supports less features.
Agreed.
But if we use the same settings, does it effects the quality of the encode too. As doom9 would say, trust your own eyes, yes.. I have checked around 7-8 clips in both mkv & avi container & frankly speaking, I personally couldn't pick any difference.
But if someone has found appreciable degradation of quality, then please correct me.
bond
25th November 2005, 20:56
you cant cut at non-keyframes, especially not with avi
(with mp4 you can, but its nowhere supported, and its also not really different than cutting at keyframes)
SeeMoreDigital
25th November 2005, 21:02
you cant cut at non-keyframes, especially not with avi
(with mp4 you can, but its nowhere supported, and its also not really different than cutting at keyframes)But at least you can assign chapter points to the "exact" frame you require (instead of just a key-frame) in .MP4 - right now :)
Cheers
Doom9
26th November 2005, 13:26
I'm pretty sure that if your cut ends at an IDR frame, you'll have serious problems.. the frames immediately thereafter refer to that frame deleted and you can't decode a B/P frame without the frame(s) it/they reference.
Elias
26th November 2005, 14:14
I recommend Matroska if you want to keep the AC3 track. If you're encoding to XviD and AAC, then mp4 is the best choice imho. Otherwise, Matroska is really the best choice.
Caroliano
26th November 2005, 20:42
I think there is one more problem with avi: AFAIK you will lose a number of frames equal to the number of references you used, isn't?
What is wrong with Trim + Matroska?
bond
27th November 2005, 04:38
I think there is one more problem with avi: AFAIK you will lose a number of frames equal to the number of references you used, isn't?iirc you will loose 1 frame when using b-frames and 2 frames when using b-references/pyramid
stephanV
27th November 2005, 16:21
Why do people talk about stuff they don't know one thing about...?
With encoding with x264vfw you'll lose the amount frames equal to the maximum number of consecutive b-frames you use. It are always the last few frames that are lost, but using x264vfw will result in drop frames being put at the start of the AVI.
With decoding an h264 AVI you get 1 frame DELAY for when b-frames are used and an additional frame delay for when b-pyramid is used.
bond
27th November 2005, 16:28
cool down, no need to offend someone for mixing up things :rolleyes:
stephanV
27th November 2005, 16:43
I am cooled down... :(
Just don't tell people not to do/use things if you don't understand the disadvantages (and advantages!) of it.
bond
27th November 2005, 16:53
Just don't tell people not to do/use things if you don't understand the disadvantages (and advantages!) of it.where did i tell anyone what to do here?
the question was what causes how many frames to be lost with x264vfw and obviously i mixed the frameloss up with the delay
yeah i am sorry i wrote something wrong and its good you corrected me, but there is no point in flaming me for that glitch as if i dont understand whats going on (after all i wrote the "afaik" only public doc explaining the avi hacks with b-frames (with asp) available...)
Caroliano
27th November 2005, 17:58
Maybe this flame was for me.
Sorry for the trouble I caused. I also mixed the number of b-frames with the number of references. I already read it in somewere but I couldn't recall correctly now. And I put the AFAIK (shoud be IIRC but I forgot this in that moment).
stephanV
28th November 2005, 09:59
Again it's not a flame, but I'll apologize for it anyway.
videomixer9
28th November 2005, 10:33
VirtualDubMod can well at least show your video, the problem is it opens files via VFW and ffdshow VFW interface has no codecs select by default, goto the VFW config dialog in ffdshow and in the codec selection select libavcodec for h264, no ffdshow decodes the video for VFW too and shows the video in vdubmod, however it's no real good option to do so, vdubmods mkv support etc. is very limited.
Just to clear up the original question why that error is thrown.
stephanV
28th November 2005, 10:49
No thats not why.
VirtualDubMod can only open MKV files which use VFW compatibility mode, but MKV's produced by MeGUI use native h.264 mode. If VFW mode were used an appropriate fourcc (e.g. h264) would be shown.
darkavatar1470
29th November 2005, 13:49
I thought one could "skip" a few frames/sections in a MKV file by using a timecode/chapter/segment ordering file?
multicone
29th November 2005, 21:44
(Arrgh.. why did TCME die!!)
It's not dead, but delayed for an unknown period of time :)
sarpanch
3rd December 2005, 19:07
With encoding with x264vfw you'll lose the amount frames equal to the maximum number of consecutive b-frames you use. It are always the last few frames that are lost, but using x264vfw will result in drop frames being put at the start of the AVI.
With decoding an h264 AVI you get 1 frame DELAY for when b-frames are used and an additional frame delay for when b-pyramid is used.
Thanks for sharing the information.
I would really like to know its meaning in non-technical terms.
Does this frame loss occurs
1/ At start of the video
2/ During the entire video
3/ or only if I delete some frames
And as you said that using avi doesn't hurt the quality, I find it a little contradicting to the above quote. So it would be great if you could enlighten me on that issue as well. :)
Thanks
stephanV
3rd December 2005, 19:35
Thanks for sharing the information.
Does this frame loss occurs
1/ At start of the video
2/ During the entire video
3/ or only if I delete some frames
You'll lose the last few frames. For example, if you use 3 b-frames, the last 3 frames of the video will be dropped.
And as you said that using avi doesn't hurt the quality, I find it a little contradicting to the above quote. So it would be great if you could enlighten me on that issue as well. :)
If you consider losing the last 3 frames (which are usually credits or whatever) as having a severe impact on quality, ok, then using VFW (not AVI) is really hurting quality yes.
sarpanch
3rd December 2005, 19:42
Thanks for your prompt reply stephan.
Appreciate it. :)
ron.v.f
31st December 2005, 20:01
No thats not why.
VirtualDubMod can only open MKV files which use VFW compatibility mode, but MKV's produced by MeGUI use native h.264 mode. If VFW mode were used an appropriate fourcc (e.g. h264) would be shown.
So there isnt any way to open such a MKV file with VDM in a proper way?
Isnt there any way to recode the RAW .264 file (extracted with mkvextract) to an proper VFW h.264 mode or recode the RAW file to XVID, either?
I've searching for a long time for something to convert a RAW h.264 file to XVID but found nothing. Eventually the trouble making file has a variable bitrate (if this kind of thing really exists).
Caroliano
31st December 2005, 21:10
You can use avisynth's DirectShowSource() to load the video in Vdub. If it play in your directshow players then it shoud open with that. You may need to set the fps value also.
foxyshadis
31st December 2005, 22:20
Normal mkv files can be re-encoded with avisynth or several all-in-one programs.
If you mean variable framerate, it exists and the above method won't work, you must use DirectShowSource and avisynth, with a 120fps framerate. See the VFR pagr on avisynth.org as soon as it comes back up.
ron.v.f
1st January 2006, 06:55
I used avisynth with DirectShow and it worked with some h.264 files (I did this before I wrote the post above). No problem so far. But another h.264 file give me the information of 7.992 fps if I don't set Haali-Splitter to force 25 fps and the encoding with this file and a proper timescale fails (no player show it). Exspecially muxing with the audio stream isn't synchro after encoding (simple things won't work, the videosource is corrupt: false timescale/dropped frames etc.).
This is a really special problem because other h.264 MKV files work without any problems but this one doesn't (the others show 23.976 fps, no problem). I wanna know why. Only for interest (and the possibility other files has this problem too;)).
I guess the only problem is to set the fps-settings right, because 7.992 ist a third of 23.976.
foxyshadis
1st January 2006, 17:07
Yeah, that sounds like VFR, and it might use the first frame's duration (3 frames worth) as the timescale for the whole movie. You can get a timecodes file with haali's mkv2vfr tool, and also a constant avi that you can open into avisynth, edit, encode & whatever, then mux back with the original timecodes file.
Otherwise you can use directshowsource with a high fps value (try 23.976, if that stutters it might have 30p sections so try 119.88). That'll insert lots of dummy frames to create cfr, which you can chop out with TIVTC or dedup.
ron.v.f
11th January 2006, 03:03
It seems that mkv2vfr doesn't work with x264. Up to now I didn't try the other way you suggest, but I will do and report if that works.
Thanks for your help.
vanger
11th January 2006, 06:49
So there is no way to edit mkv (or other files with x264 stream) files?
ron.v.f
9th February 2007, 16:49
After a very long time I want to report that mkv2vfr worked very well (eventually because I used a new version). The timecodes told me 1:30min are 23.076 rest 29.97. I cut off 1:30 processed the rest through avisynth:
Telecide(order=0,guide=1)
Decimate(mode=3, threshold=2.0)
So I gained another 23.976 videostream, merged both streams via projectdivx, muxed with AC3. Everythings fine. My DVD-Player will be happy.
Thanks for your help again.:thanks:
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.