DirectShowSource
(string filename, float "fps", bool "seek", bool "audio", bool "video", bool "convertfps", bool "seekzero", int "timeout", string "pixel_type", int "framecount", string "logfile", int "logmask")
DirectShowSource
reads filename using 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 QuickTime, 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:
FlipVertical
.DirectShowSource
("video.asf", fps=15).fps: This is sometimes needed to specify the framerate of the video. If the framerate or the number of frames is incorrect (this can happen with asf or mov clips), use this option to force the correct framerate.
seek = true (in v2.53): There is full seeking support (available on most file formats). If problems occur try enabling the seekzero option first, if seeking still cause problems completely disable seeking. With seeking disabled the audio stream returns silence and the video stream the last rendered frame when trying to seek backwards. Note the Avisynth cache may provide limited access to the previous few frames, beyond that the last frame rendered will be returned.
audio = true (in v2.53): 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 ordering 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.
video = true (in v2.52): When setting it to false, it lets you open the audio only.
convertfps = false (in v2.56): When setting it to true, it turns variable framerate video (vfr) into constant framerate video (cfr) by duplicating or skipping frames. This is useful when you want to open vfr video (for example mkv, rmvb, mp4, asf or wmv with hybrid video) in AviSynth. It is most useful when the fps parameter is set to the least common multiple of the component vfr rates, e.g. 120 or 119.880.
seekzero = false (in v2.56): An option to restrict seeking only back to the beginning. It allows limited seeking with files like unindexed ASF. Seeking forwards is of course done the hard way (by reading all samples).
timeout = 60000 (in milliseconds; 60000 ms = 1 min) (in v2.56): To set time to wait when DirectShow refuses to render. Positive values cause the return of blank frames for video and silence for audio streams. Negative values cause a runtime Avisynth exception to be thrown.
pixel_type (in v2.56): The pixel type of the resulting clip, it can be "YV12", "YUY2", "ARGB", "RGB32", "RGB24", "YUV", "RGB" or "AUTO". By default, upstream DirectShow filters are free to bid all of their supported media types in the order of their choice. A few DirectShow filters get this wrong. The pixel_type argument limits the acceptable video stream subformats for the IPin negotiation. Note the graph builder may add a format converter to satisfy your request, so make sure the codec in use can actually decode to your chosen format. The M$ format converter is just adequate. The "YUV" and "RGB" pseudo-types restrict the negotiation to all supported YUV or RGB formats respectively. The "AUTO" pseudo-type permits the negotiation to use all relevant formats in the order of preference YV12, YUY2, ARGB, RGB32, RGB24. Many DirectShow filters get this wrong, which is why it is not enabled by default. The option exists so you have enough control to encourage the maximum range of filters to serve your media. (See discussion.)
framecount (in v2.57): This is sometimes needed to specify the framecount of the video. If the framerate or the number of frames is incorrect (this can happen with asf or mov clips), use this option to force the correct number of frames. If fps is also specified the length of the audio stream is also adjusted.
logfile (in v2.57): Use this option to specify the name of a debugging logfile.
logmask = 35 (in v2.57): When a logfile is specified, use this option to select which information is logged.
Value | Data |
---|---|
1 | Format Negotiation |
2 | Receive samples |
4 | GetFrame/GetAudio calls |
8 | Directshow callbacks |
16 | Requests to Directshow |
32 | Errors |
64 | COM object use count |
128 | New objects |
256 | Extra info |
512 | Wait events |
Opens an avi with the first available RGB format (without audio):
DirectShowSource("F:\TestStreams\xvid.avi", \ fps=25, audio=false, pixel_type="RGB")
Opens a DV clip with the MS DV decoder:
DirectShowSource("F:\DVCodecs\Analysis\Ced_dv.avi") # MS-DV
Opens a variable framerate mkv as 119.88 by adding frames (ensuring sync):
DirectShowSource("F:\Guides\Hybrid\vfr_startrek.mkv", \ fps=119.88, convertfps=true)
Opens a realmedia *rmvb clip:
DirectShowSource("F:\test.rmvb", fps=24, convertfps=true)
Opens a GraphEdit file:
V=DirectShowSource("F:\vid_graph.grf", audio=False) # video only (audio renderer removed) A=DirectShowSource("F:\aud_graph.grf", video=False) # audio only (video renderer removed) AudioDub(V, A)
See below for some audio examples.
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.
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.
Some filters might have problems reporting the right samplerate, and then correct this when the file is actually playing. Unfortunately there is no way for AviSynth to correct this once the file has been opened. Use AssumeSampleRate and set the correct samplerate to fix this problem.
Unfortunately Directshow is not required to support sample exact seeking. Open the sound another way, or demux your video file and serve it to AviSynth another way. Otherwise you can specify "seekzero = true" or "seek = false" as parameters or use the EnsureVBRMP3Sync filter to enforce linear access to the Directshow audio stream.
Microsoft in their infinite wisdom chose to implement ASF stream timing in the ASF demuxer. As a result it is not possible to strip ASF format files any faster than realtime. This is most apparent when you first start to process the streams, usually after opening the Avisynth script it takes you a while to configure your video editor, all this time the muxer is accumulating credit time. When you then start to process your stream it races away at maximum speed until you catch up to realtime at which point it slows down to the realtime rate of the source material. This feature makes it impossible to use Avisynth to reclock 24fps ASF material upto 25fps for direct PAL playback.
This section will describe various tasks that might not be 100% obvious. :)
GraphEdit GRF-files are automatically detected by a .grf filename extension and directly loaded by DirectShowSource. For AviSynth to be able to connect to it, you must leave a pin open in GraphEdit of a 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. DirectShowSource only accepts YV12, YUY2, ARGB, RGB32 and RGB24 video formats and 32, 24, 16 and 8 bit PCM and IEEE FLOAT audio formats.
A given GRF-file should only target one of an audio or video stream to avoid confusion when directshowsource attempts the connection to your open pin(s). From version 2.57 this single stream restriction is enforced.
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.
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.
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 |
seekzero restricts seeking to begining only | |
timeout controls response to recalcitrant graphs | |
pixel_type specifies/restricts output video pixel format | |
v2.57 | framecount overrides the length of the streams. |
logfile and logmask specify debug logging. |
$Date: 2008/12/07 15:47:16 $