Home
RecentChanges

Search:

» AviSynth is a powerful video FrameServer for Win32.

AviSynth Links:
»Download
»Learn to script
»FAQ
»Manual
»Discussion fora
»Project page
»External filters
»FeedBack

» You can add pages to this website immediately. No login required.
Edit this document

» AboutAviSynth

 

Avisynth 
Logo

DirectShowSource

( Diese Seite in flag-germany.gif Deutsch )

DirectShowSource(string filename [, float fps, bool seek, bool audio, bool video, convertfps])

DirectShowSource reads filename using MS DirectShow, the same multimedia playback system which Windows Media Player uses. It can read most formats which Media Player can play, including MPEG, MP3, and some QuickTime files, as well as AVI files that AVISource doesn't support (like DV type 1, or files using DirectShow-only codecs). Try reading AVI files with AVISource first, and if that doesn't work then try this filter instead.

There are some caveats:

  1. Some decoders (notably MS MPEG-4) will produce upside-down video. You'll have to use FlipVertical.
  2. DirectShow video decoders are not required to support frame-accurate seeking. In most cases seeking will work, but on some it might not.
  3. DirectShow video decoders are not even required to tell you the frame rate of the incoming video. Most do, but the ASF decoder doesn't. You have to specify the frame rate using the fps parameter, like this: DirectShowSource("video.asf", fps=15).
  4. This version automatically detects the Microsoft DV codec and sets it to decode at full (instead of half) resolution. I guess this isn't a caveat. :-)

Starting from v2.53 several things are added:

  • There is audio support in DirectShowSource. DirectShowSource is able to open formats like WAV/DTS/AC3/MP3, provided you can play them in WMP for example (more exact: provided they are rendered correctly in graphedit). The channel ordening is the same as in the [wave-format-extensible format], because the input is always decompressed to WAV. For more information, see also GetChannel. AviSynth loads 8, 16, 24 and 32 bit int PCM samples, and float PCM format, and any number of channels.
  • There is full seeking support (available on most fileformats).
  • There is support for GraphEdit (grf) files.

In v2.56, convertfps = true/false (default false) is added. It turns variable framerate video (vfr) into constant framerate video (cfr) by adding frames. This is useful when you want to open vfr video (for example mkv or wmv with hybrid video) in AviSynth.

Example

DirectShowSource("F:\Guides\Hybrid\vfr_startrek.mkv", fps=119.88, convertfps=true)

Troubleshooting video and audio problems

AviSynth will by default try to open only the media it can open without any problems. If one component cannot be opened it will simply not be added to the output. This will also mean that if there is a problem, you will not see the error. To get the error message to the missing component, use audio=false or video=false and disable the component that is actually working. This way AviSynth will print out the error message of the component that doesn't work.

"The Filter Graph won't talk to me" !!!

This is a common error that occurs when DirectShow isn't able to deliver any format that is readable to AviSynth. Try creating a filter graph manually and see if you are able to construct a filter graph that delivers any output AviSynth can open. If not, you might need to download additional DirectShow filters that can deliver correct material.

The samplerate is wrong!

Some filters might have problems reporting the right samplerate, and then correct this when the file is actually playing. Unfortunately there is not way for AviSynth to correct this once the file has been opened. Use "AssumeSampleRate" and set the correct samplerate to fix this problem.

My sound is choppy

Unfortunately it is not possible seek 100% accurately in DirectShow. The precision usually depends on the container format. Open the sound another way, or demux your video file and serve it to AviSynth another way. Otherwise you can specify "seek = false" as a parameter.

Common tasks

This section will describe various tasks that might not be 100% obvious. :)

Opening GRF files

GraphEdit GRF-files are automatically detected and loaded by DirectShowSource. For AviSynth to be able to connect to it, you must leave pins open in GraphEdit of media types that AviSynth is able to connect to. AviSynth will not attempt to disconnect any filters, so it is important that the output type is correct.

Downmixing AC3 to stereo

There are essentially two ways to do this. The first is to set the downmixing in the configuration of your AC3 decoder itself, and the second one is to use the external downmixer of "Trombettworks":

1) Install AC3filter. Open the AC3 file in WMP6.4 and select the file properties. Set the output of AC3Filter on 2/0 - stereo. If you want the best possible quality, select PCM Float as Sample format.

ac3downmix1a.jpg ac3downmix1b.jpg

Make the following script:

v = Mpeg2Source("e:\movie.d2v")
a = DirectShowSource("e:\Temp\Test2\test.ac3")
AudioDub(v,a)

Finally, open the script in vdub and convert the audio stream to MP3 (of course you can also demux the downmixed WAV stream if needed).

2) Register the directshow filter [Channel Downmixer by Trombettworks] (under start -> run):

regsvr32 ChannelDownmixer.ax

Open the AC3 file in WMP6.4 and select the file properties. Set the output of AC3Filter on 3/2+SW 5.1 channels (this downmixer can't handle PCM Float, thus PCM 16 bit is selected here). In the properties of the downmixer, the number of input and output channels should be detected automatically. Check whether this is indeed correct.

ac3downmix2a.jpg ac3downmix2b.jpg
ac3downmix2c.jpg

Make the following script:

v = Mpeg2Source("e:\movie.d2v")
a = DirectShowSource("e:\Temp\Test2\test.ac3")
AudioDub(v,a)

Finally, open the script in vdub and convert the audio stream to MP3 (of course you can also demux the downmixed WAV stream if needed).

For some reason, I can't get this to work with DTS streams :(

Changes

v2.56 convertfps turns vfr into constant cfr by adding frames

SourceForge Logo

 


Edit this document | View document history
Document last modified Thu, 24 Mar 2005 16:56:34