MKV extract

This forum is for questions and discussion of all the aspects of handling your footage. If you have questions about capturing/ripping footage, AviSynth, or compression/encoding/converting, look here.

MKV extract

Postby Faltzer » Fri Oct 31, 2008 11:29 am

Ok so I 've always had problems with the mkv container in terms of extracting footage from them.

Let's say as an example I have an anime episode that I want to use (take a scene from there for a AMV), the episode is mkv format. Now I'd have to use mkvextract to extract the raw file from the container, this raw file is a raw h.264 file that nothing supports. So then because of this problem I use an application called avc2avi to convert the raw file to h.264 avi which gives me 'problems'. If I try to extract a scene from this now converted avi file (using lets say, VirtualDub/VirtualDub MOD) the application always complains about the file (bframe reference problems, etc.) If I try to extract a scene with VDub, the output file contains either nothing(black all the way) or just the first frame. The only application that seem to work with the converted avi is Total Video Converter, but as you know (if you didn't already know), TVC gives absolutly crap video quality.

Now is there a way to '"properly" extract a scene from a mkv file? I've tried using VDub MOD directly on the mkv file, but it always complains about the file having a frame it dosen't like,etc (dosen't make a difference what video it is, as long as it's mkv, it gives the problem).

I've also tried using the program Avidemux to capture directly from the mkv file but it also gives problems like "bframe problem" and "h264 detected - can lead to crashes" and it's almost impossible to get a scene from the mkv file...

Any help??? :cry: :cry: :cry:
User avatar
Faltzer
 
Joined: 26 May 2008
Location: In your underpants!! PANTSU PANTSU!!!
Status: There's no such thing as no such thing.

Postby Kariudo » Fri Oct 31, 2008 1:04 pm

avisynth + ffmpegsource() should do it
ImageImage
Image
User avatar
Kariudo
Twilight prince
 
Joined: 15 Jul 2005
Location: Los taquitos unidos
Status: 1924 bots banned and counting!

Postby Qyot27 » Fri Oct 31, 2008 1:05 pm

As one of the local MKV supporters, I feel somewhat obligated to respond.

There are two big reasons why these steps are giving you trouble:
A) Matroska can handle two main types of video - Native video, and VFW. Yes, this is a gross simplification, but it helps explain this. VFW is the same type of video (the only type) that AVI supports. Native video is the type that you'd find in MPEG-1, MPEG-2, or MP4 files. Historically, MKVs that house XviD-encoded video streams use VFW. Because of the inherent problems with using H.264 in AVI, however, most H.264 MKVs use Native - which, by the way, is the proper way to store such streams in MKV.

B) VirtualDubMod can handle MKVs just fine, as long as the video streams use VFW. The H.264 AVI files produced by avc2avi will only work if you have a VFW decoder that is capable of decoding H.264 (ffdshow's VFW interface can do this, for example). The kinds of warnings that can occur in the event of trying to open one of these files without the proper decoder can be as long as my arm. In short, it's generally a bad idea.

Now, there is a proper way to open any MKV file in VDubMod (or VDub itself). It requires a very simple AviSynth script. First, make sure that AviSynth is installed. Second, make sure you have the FFmpegSource plugin and put that plugin in AviSynth's plugins directory (usually C:\Program Files\AviSynth 2.5\plugins). Then use a script like this:
Code: Select all
FFmpegSource("video.mkv",atrack=-1)

It'll take a little bit to open the first time because the plugin indexes the MKV, much like DGIndex does for MPEG-2 files. The ,atrack=-1 parameter is optional, but necessary if you want audio as well - by default, the plugin doesn't load audio.

If you don't want to necessarily remember to write scripts and all, you can make a template for VDubMod to use that will generate one for you. Just copy and paste this into Notepad and then save as ffmpegsource.avst in VDubMod's template directory:
Code: Select all
#ASYNTHER FFmpegSource
[FFmpegSource("%f",atrack=-1)]


After that, you can access FFmpegSource with the drop-down menu in the Open via AviSynth* dialog (for VDubMod 1.5.10.1), or again in the drop-down menu for AviSynth templates in the standard Open video dialog (for VDubMod 1.5.10.2 and 1.5.10.3).

*Open via AviSynth, despite it's name, is not for opening .avs files. You select a real video file and AviSynth will generate an .avs and then open it based on which source filter you've chosen. Thankfully later versions of VDubMod merged this with the main Open dialog so there's less confusion about it.
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Postby Faltzer » Sat Nov 01, 2008 8:41 am

Dosen't seem to work, it says there's no function called FFmpegSource, etc. BTw, I just want to know, the downloaded plugin is a zip file, do you place the zip file itself in the avisynth plugin folder or the contents of the zip file (FFmpegSource.dll) ???
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination!
User avatar
Faltzer
 
Joined: 26 May 2008
Location: In your underpants!! PANTSU PANTSU!!!
Status: There's no such thing as no such thing.

Postby Kariudo » Sat Nov 01, 2008 11:59 am

you unzip the file and put the .dll in the plugins folder
ImageImage
Image
User avatar
Kariudo
Twilight prince
 
Joined: 15 Jul 2005
Location: Los taquitos unidos
Status: 1924 bots banned and counting!

Postby Qyot27 » Sat Nov 01, 2008 12:02 pm

Faltzer wrote:Dosen't seem to work, it says there's no function called FFmpegSource, etc. BTw, I just want to know, the downloaded plugin is a zip file, do you place the zip file itself in the avisynth plugin folder or the contents of the zip file (FFmpegSource.dll) ???

You put the .dll in there. If it still doesn't load (which it should, but maybe there's something wrong elsewhere), then using
Code: Select all
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FFmpegSource.dll")

on the first line of the script, before calling FFmpegSource itself, should work. Actually, using LoadPlugin you can have the plugin anywhere on the computer, but it's easier if it just autoloads - the reason for putting it in the plugins directory.
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Postby Vivaldi » Sat Nov 01, 2008 1:26 pm

I should point out that if FFmpegSource is giving you more trouble than it's worth, just use:
Directshowsource ("blah") instead. FFmpegsource is superior, but directshowsource will get the job done well enough.
Image
Image
<Kenzichu> HAHAHA!!
<Kenzichu> everyone died!
User avatar
Vivaldi
Polemic Apologist
 
Joined: 29 Sep 2007
Location: Petting mah cat..

Postby Faltzer » Sun Nov 02, 2008 5:25 am

Still doesn't seem to work :cry:

Ok this is what I do:

- Install Avisynth 2.57
- Copy the plugin (FFMpegSource.dll) to the plugin dir. of Avisynth
- Open up Notepad and enter the code:
Code: Select all
FFmpegSource("video.mkv",atrack=-1)

- Save as a .avs file
- Open then .avs file with VDub MOD 1.5.10 (Am I meant to do this?)
- Complains: '"cannot open mkv file"

I think it has something to do with the second last line up there? I never used AviSynth before so I'm not too sure. :?
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination!
User avatar
Faltzer
 
Joined: 26 May 2008
Location: In your underpants!! PANTSU PANTSU!!!
Status: There's no such thing as no such thing.

Postby Qyot27 » Mon Nov 03, 2008 12:29 am

Faltzer wrote:Still doesn't seem to work :cry:

Ok this is what I do:

- Install Avisynth 2.57
- Copy the plugin (FFMpegSource.dll) to the plugin dir. of Avisynth
- Open up Notepad and enter the code:
Code: Select all
FFmpegSource("video.mkv",atrack=-1)

- Save as a .avs file
- Open then .avs file with VDub MOD 1.5.10 (Am I meant to do this?)
- Complains: '"cannot open mkv file"

I think it has something to do with the second last line up there? I never used AviSynth before so I'm not too sure. :?

You need to replace "video.mkv" with the actual filename of the MKV - but remember to keep the quotes around it. Also, make sure the script is in the same directory as the MKV - if it's not, you need to specify the full path.
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Postby Faltzer » Mon Nov 03, 2008 2:36 pm

Ok, it seems to work, but it still complains about opening the mkv file if I don't specify the full path, otherwise, everything seems to work!!! THANK YOU!!!! :D :D :D
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination!
User avatar
Faltzer
 
Joined: 26 May 2008
Location: In your underpants!! PANTSU PANTSU!!!
Status: There's no such thing as no such thing.

Re: MKV extract

Postby Faltzer » Tue Nov 25, 2008 4:35 pm

Anthor question, I've noticed that the extracted AVI file is now fairly large, it's about 2GB for only 1.5 minutes of footage (uncompressed) and about 300~400MB when extracted using a lossless codec (h264) yet the actual episode is 350MB for 25 minutes? :?
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination!
User avatar
Faltzer
 
Joined: 26 May 2008
Location: In your underpants!! PANTSU PANTSU!!!
Status: There's no such thing as no such thing.

Re: MKV extract

Postby Qyot27 » Tue Nov 25, 2008 5:37 pm

That's because lossless coding = huge files (most of the time, anyway - there are some tricks, but they only apply in special circumstances). This is why cutting short clips - 20 secs or less, usually - is the recommended method. By running the file through AviSynth, you're decoding the video, not extracting it. Hence, it's going to be at the mercy of whatever compressor you're using.

The best option is to make sure VDubMod is set on Fast Recompress mode, and use either Lagarith or the YV12 version of HuffYUV (which is only available in ffdshow's VFW encoder). Of course, if the video editor you plan on using doesn't support YV12 or doesn't support it correctly, then you're better off leaving it on Full Recompress and saving the files in RGB - in which case use either Lagarith or regular HuffYUV.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Re: MKV extract

Postby skysky » Wed Feb 11, 2009 8:26 pm

I am having a hard time extract MKV files too.
I tried to FFMpegSource.dll as suggested above but I was not able to fine the dll.
I extracted ffmpegsource() extraction but it had only included 4 files in it.
Copying.GPL
FFMS2.dll
ffm2.html
ffmsindex.exe

I am completely lost on how to use VirtualDub to get my files.
I am able to open the mkv files in VirtualDub but it always seem to crash whenever I attempt to save.
It crashes no matter what type I try to save it as. either the HuffYuv clips, setting = "predict gradient(best)", etc...
I am trying to make an important music video and would really appreciate any help anyone have.
I got Adobe premium pro and Windows Movie Maker, that are to edit the files the way I want them to.

Any help would be appreciated, Thanks.
skysky
 
Joined: 11 Feb 2009

Re: MKV extract

Postby Qyot27 » Thu Feb 12, 2009 9:57 am

skysky wrote:I am having a hard time extract MKV files too.
I tried to FFMpegSource.dll as suggested above but I was not able to fine the dll.
I extracted ffmpegsource() extraction but it had only included 4 files in it.
Copying.GPL
FFMS2.dll
ffm2.html
ffmsindex.exe

That's because the FFmpegSource being referred to back in November when this thread was started was version 1.21, you downloaded one of the 2.00 beta versions. If you check the last page in the FFmpegSource thread, however, there's a wrapper function that will force the betas to behave like the older 1.x versions did, more or less. Just copy and paste those instructions into a file named ffmpegsource2.avsi and then use FFmpegSource2("video.mkv",atrack=-1) to call the filter. Or download the 1.21 version and use that.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog
User avatar
Qyot27
Surreptitious fluffy bunny
 
Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs


Return to Footage Help

Who is online

Users browsing this forum: No registered users and 1 guest