Graphedit, DirectShow, MKVs, and Mass Confusion [Help]

User avatar
Kira_Douji
Joined: Sun Feb 20, 2005 1:38 pm
Org Profile

Graphedit, DirectShow, MKVs, and Mass Confusion [Help]

Post by Kira_Douji » Fri Apr 14, 2006 1:04 pm

So I went through the forums to read up on how one might take an mkv and extract the video file from it. Here's the rundown of what I've tried so far:

Openned The MKV In VDM
VirtualDubMod "parsed" the file, pretended to throw it into the viewer and then told me it had an "error code 2" at frame 0 and didn't even show a blank (black) screen, just the normal VDM background for when there's no video open.

Downloaded MKVExtractGUI
I told it to extract the video file, and it did - converted it to an avi and plopped it on my desktop. I ran the file in VLC and it worked fine. Then I tried to open it in VDM and got "Error decompressing video frame 0: A codec-specific error occured. (error code 1)".

Upgraded my VDM
I went back to the forums to see that VDM, in fact, might have issues with MKV containers and x264 codecs if a) it's an older version or b) your FFD Show VFW x264 isn't set to decode. So... when I merely updated my VDM and opened the extracted file I received "VideoSourceAVI error: The source image format is not acceptable. (error code -2)"

Then I went into the FFDShow VFW Config, decoder section and changed H.264 from "disabled" to the only other option "libavcodec". Reopened the same extracted avi in VDM and was told "Error decompressing video frame 0: A codec-specific error occured. (error code 1)"

So then I tried to simply open the MKV and was rewarded with what looked like a properly opened file, EXCEPT that when I move the slider from anywhere other than 0 I got "VideoSourceAVI error: bad parameters (8004406a)" followed by "Error decompressing video frame n: A codec-specific error occured. (error code 1)" where n is any number greater than 1. VDM also considered every frame here "dropped".

VDM doesn't work with AVC so use Graphedit
Downloaded Graphedit. Cannot for the life of me find instructions on how one takes the mkv and, via Graphedit, and I believe Qyot27 said DirectShow? convert it out of the mkv container. Cannot even find an "Graphedit for dummies" type introduction to the program.

For the love of AMVs, someone explain this to me, PLEASE.

- Kira
ImageImage

User avatar
Sir_Lagsalot
Joined: Mon Jun 23, 2003 6:42 pm
Org Profile

Post by Sir_Lagsalot » Fri Apr 14, 2006 1:54 pm

To convert a simple MKV file to avi:
Open the MKV file in graphedit
Delete all blocks except the first one with the file name
Graph->Insert Filter->DirectShow Filters, select 'avi mux' and click insert filter (screen shouldn't change)
Select file writer from DirectShow Filters and click insert, then enter the file name for you output avi and press ok
Close filter window
Click on the video nub on the MKV block, and drag a line to the input 01 nub on the avi mux (other filter blocks may be inserted)
Click on the audio nub on the MKV block, and drag a line to the input 02 nub on the avi mux if you want audio too
Click on the AVI out nub on the avi mux block and drag a line to the file writer in nub
Click the play button at the top of Graphedit, the progress bar underneath will slowly fill up with blue as the file is converted and saved to your avi file

Depending on the codecs used, the generated avi may be uncompressed, in which case you'll either need to have lots of free disk space, or add a video codec filter to the video stream before the avi mux block
Lagarith: Best lossless codec ever in my completely objective opinion.

User avatar
Kira_Douji
Joined: Sun Feb 20, 2005 1:38 pm
Org Profile

Post by Kira_Douji » Fri Apr 14, 2006 2:02 pm

I can't try that right away, but certainly will, however I have a quick aside before I do. I've heard it said by many, many people that x264 shouldn't be in an avi container. If this is true, does Graphedit simply take what's there, sans codec, and chug it out for me? I do have the diskspace for a raw video file, so if it does, in fact, essentially eliminate the "x264 in an avi container" issue, then this would be the solution I'm looking for.

Thank you,
Kira
ImageImage

User avatar
Sir_Lagsalot
Joined: Mon Jun 23, 2003 6:42 pm
Org Profile

Post by Sir_Lagsalot » Fri Apr 14, 2006 2:16 pm

depending on your setup, it may or may not decode x264 video before piping it into the avi. To ensure that it is decoded first, don't delete the video decoder after you open the MKV file in graphedit, then use the output from the video decoder as the input into the avi mux instead of the MKV block's video out.
Lagarith: Best lossless codec ever in my completely objective opinion.

User avatar
Qyot27
Surreptitious fluffy bunny
Joined: Fri Aug 30, 2002 12:08 pm
Status: Creepin' between the bullfrogs
Location: St. Pete, FL
Contact:
Org Profile

Post by Qyot27 » Fri Apr 14, 2006 2:29 pm

Kira_Douji wrote:I can't try that right away, but certainly will, however I have a quick aside before I do. I've heard it said by many, many people that x264 shouldn't be in an avi container. If this is true, does Graphedit simply take what's there, sans codec, and chug it out for me? I do have the diskspace for a raw video file, so if it does, in fact, essentially eliminate the "x264 in an avi container" issue, then this would be the solution I'm looking for.

Thank you,
Kira
Not to my knowledge, no. MKVExtract GUI outputs bad H.264 files if you try. You need to use the MKVExtract command-line interface to properly pull it out. From there you could use MP4Box/YAMB to put it in MP4 - which still requires Graphedit-AviSynth to edit with, or (not recommended) avc2avi to remux it into AVI.

The reason it's not a good idea to put H.264 in AVI is because of the reference frames, b-frame pyramid, mixed references, and/or the sheer volume (up to 13, I believe) of consecutive b-frames it allows. XviD and DivX already need nasty hacks to get them into AVI and they don't have nearly the amount of stuff that could screw up (I think it's just the b-frames, IIRC, and those are limited to only about 2 or 3 consecutively, again IIRC). With H.264's advanced features, you're increasing the nasty hacks by orders of magnitude and they aren't very well-implemented hacks either. It will cause a noticable audio lag. I'm not sure how exactly it treats them so I can't say what simply putting it in AVI to edit with sans audio would do, but when I still did it that way it didn't seem severe (part of that could be that they were trailers from the Quicktime site, which don't use a lot of the advanced features).

Theoretically, you could make an H.264-in-AVI file that plays back the way it's supposed to (without hacks or lag), but that would require not enabling those advanced features, which makes the encoding horribly inefficient.

If it's simply wanting to edit from the MKV rather than transmuxing, it would be:

Open Graphedit->Render Media File...
Delete all boxes but the splitter and ffdshow (or CoreAVC/your DirectShow-based H.264 decoder of choice). The splitter is the one with the filename.
Save the file
Use DirectShowSource to open the .grf file through AviSynth.
Edit as usual.

This also works for converting the files from one format to another (e.g. for Video CD or DVD), in which case putting it through Graphedit ensures that the audio doesn't desync as long as the file isn't variable frame rate - but VFR isn't too common; it's more common in something like WMV or RM than MKV, at least at the moment. Taking a wild guess, uses in MKV generally tend to be for joining 23.976fps segments to 29.97fps segments, like for anime openings in 29.97 and the core of the show itself in 23.976, although I've never actually seen an example of this (I have created such files, though, with some old 120fps Negima RAWs). WMV and RM, when they have VFR, tend to fluxuate wildly within three or four frames of the target rate - like if the target rate is 29.97, it'll fluxuate between 26 and 34 fps.

Having H.264 enabled in ffdshow video decoder is required for playback in Windows Media Player, etc. Having H.264 enabled in ffdshow's VFW interface allows VFW-mode AVC to be opened in VDM. However, most AVC encodes online use ISO-AVC, so it's only possible to do it if you A) use the via AviSynth method, or B) avc2avi.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog

User avatar
Qyot27
Surreptitious fluffy bunny
Joined: Fri Aug 30, 2002 12:08 pm
Status: Creepin' between the bullfrogs
Location: St. Pete, FL
Contact:
Org Profile

Post by Qyot27 » Fri Apr 14, 2006 2:31 pm

Qyot27 wrote:Not to my knowledge, no. MKVExtract GUI outputs bad H.264 files if you try. You need to use the MKVExtract command-line interface to properly pull it out.
Note: I meant those as two separate streams of thought.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog

User avatar
Kira_Douji
Joined: Sun Feb 20, 2005 1:38 pm
Org Profile

Post by Kira_Douji » Fri Apr 14, 2006 2:50 pm

Qyot27 wrote:...
You are SO VERY VERY HELPFUL. THANK YOU. *bow*

- Kira
ImageImage

User avatar
Kira_Douji
Joined: Sun Feb 20, 2005 1:38 pm
Org Profile

Post by Kira_Douji » Sat Apr 15, 2006 1:15 am

Hrm, okay... well, I told GraphEdit to "Render File" and was given an error.

Code: Select all

Could not construct a graph from this file.

- Have you installed all the necessary files?
- Note that the 'Render File' menu option cannot render *.GRF files.

Cannot play back the file. The format is not supported. (Return code: 0x80040265)
I understand the basics of the error, but I don't understand how it's occuring. Why can I play the mkv file in VLC but GraphEdit can't open it? I checked WMP and it has no idea what an mkv is, but I thought that was normal. What am I missing that GraphEdit needs? Does it not like my FFDShow codec for H264?

- Kira
ImageImage

User avatar
DJ_Izumi
Joined: Wed Oct 03, 2001 8:29 am
Location: Canada
Contact:
Org Profile

Post by DJ_Izumi » Sat Apr 15, 2006 11:05 am

I've seen pirated anime that used h264 in an AVI. Actually, it was a long series and the group adapted during the project. So initially they used WMV9 in an AVI, later h264 in an AVI and finally h264 in an MKV.

If you compare the AVI and MKV h264 encodes it's clear that the MKV one is actually cleaner and more efficent. You can tell that a lot of the features of h264 had to be dropped in order to fit it into the AVI for regular playback.
Image

User avatar
Sir_Lagsalot
Joined: Mon Jun 23, 2003 6:42 pm
Org Profile

Post by Sir_Lagsalot » Sat Apr 15, 2006 11:08 am

Sounds like your missing some filters, check out http://www.matroska.org/downloads/windows.html
I'd try installing the Haali Media Splitter first, then if that doesn't work try the Matroska Pack.
Lagarith: Best lossless codec ever in my completely objective opinion.

Locked

Return to “Video & Audio Help”