View Full Version : opening an .MP4 in Avisynth ?

2nd March 2007, 23:51
Hi looking for suggestions or a link for opening an .MP4 file in avisynth ...

Saw neuron2's thread "AVC/H.264 Avisynth source filter released" http://forum.doom9.org/showthread.php?t=122598&page=4 however its closed for some patching (really looking forward to it).

Wonder if this'd work -
1. demux using AVIdemux2 http://avidemux.sourceforge.net/ (can it demux .MP4 I wonder?)
2. mux into an AVI using avc2avi http://forum.doom9.org/showthread.php?p=610495#post610495
3. use AVISource in Avisynth on the .avi from step 2 (have xvid and ffdshow installed, so one of these codecs should pick it up ?) ... cleanup in avisynth and feed into HC
4. use ffmpeggiu http://www.videohelp.com/tools?tool=ffmpegGUI to convert the audio from step 1 into .mp2 or something together with the .mpv file from step 3, as input to a DVD authoring tool.

Also, wondering does .MP4 have a framerate and if so how do I tell what it is ? AVIcodec doesn't seem to tell me about .MP4's. Do you reckon I'll have audio sync issues with the above approach ? You may have suggestions which work better (ps not really wanting to install haali).

3rd March 2007, 00:09
Why all that trouble? Just use DirectShowSource with fps and convertfps=true.

3rd March 2007, 00:10
I think MP4, like MKV, supports variable framerate. I'm also very much looking forward to neuron2's AVC filter. In the meantime, though, why not just install Haali Media Splitter and use DirectShowSource()?

3rd March 2007, 00:10
DirectShowSource ought to do it, as long as you have the codec installed to play the MP4 in Windows.

3rd March 2007, 00:20
OK :thanks: DirectshowSource seems like the go, since I have xvid and ffdshow...

does DirectshowSource depend on haali ? Not really wanting to install it - happy to demux the .mp4 first if I have to, assuming the demuxed video ES will go into DirectShowSource.

Also, sort of a gspot/avicoded tool type of question, how could I find out the .MP4's framerate and other info, since I'll need it for "with fps and convertfps=true" ... "MP4, like MKV, supports variable framerate" doesn't sound promising...

3rd March 2007, 00:39
You'll need an MP4 splitter on your PC for DirectShowSource to be able to play. My desktop PC was able to do it without my needing to install Haali Splitter but I think it might be either Nero or QuickTime which provided the splitter. Try creating a script with DirectShowSource("file.mp4")

just to test if you'll still need a splitter or not.

The latest version of GSpot supports MP4, I believe. There's also MediaInfo.

You can extract the video as AVI using mp4box but AVI doesn't really play nice with variable frame rate that's why it's better to use DirectShowSource in this instance.

3rd March 2007, 00:48
Ah. :thanks: ilovejedd, that makes it a bit clearer. I have a new full Nero7 so I hope that'll do the splitting... will give the script a try, and download gspot too. Pity avi and vfr don't mix. Oh well. Roll on, neuron2's AVC filter...

Any reason I should prefer either of Gspot or MediaInfo (eg no "phone-home" or some such... mediainfo appears to be a Sourceforge project which could be "safer" maybe) ?

3rd March 2007, 01:21
I use both but I use MediaInfo more frequently purely because there's a command line version. No spyware or adware in either. Although, GSpot seems to be more accurate and fault tolerant. I've had several files that were reported incorrectly with MediaInfo that GSpot handled correctly.

3rd March 2007, 05:17
Oh Dear. This


Opens in Windows Media Player 10, but HC shows the Avisynth error message

Directshowsource. Could not open as video or audio.

Any ideas ? Must I retreat to encoding Nero Vision, which doesn't let me clean it up with avisynth filters ?

3rd March 2007, 06:03
Can you open the script in VirtualDub? If not, then I guess you'll have to give Haali Splitter a try.

3rd March 2007, 09:33
Confirmed. This


Does open and play fine in Windows Media Player 10, but doesn't open and play in either of

1. HC which shows the Avisynth error message

Directshowsource. Could not open as video or audio.

2. Vdub 1.6.17 which says

Avisynth open failure
DirectShowSource: Could not open as video or audio.
Video returned: "DirectShowSource: couldn't open file D:\DVD\file.mp4:
Cannot play back the file. The format is not supported."
Audio returned: "DirectShowSource: the filter graph manager won't talk to me"

Seems strange that avisynth/directshowsource works in one program but not another for the exact same file/avs... I'm at a bit of a loss as to why that may be so. AviSynth version is 2.5.6 by the way. A bug of some sort ?

3rd March 2007, 13:16
Try 2.5.7, there were tons of DirectShowSource improvements in it. It also has a log= and logmask= parameters that you can use to help trace DShow errors.

23rd March 2007, 17:17

you've given me the key to get right framerate with variable framerate! :)


that's it! by the way, can you explain an avisynth newbie the need for:


even when virtualdub will output 24bit RGB?

my post covers 3gp > xvid conversion. you might find something useful there:


23rd March 2007, 20:35
The only reason for it is if you're opening it directly into a command-line codec, or want to feed it from virtualdub with fast recompress. Vdub can read just about any colorspace format.

23rd March 2007, 22:08
halsboss, iam guessing this is actually nero splitter problem, do try that halli way.

9th May 2007, 07:31
halsboss, iam guessing this is actually nero splitter problem, do try that halli way.

Thanks for the suggestion on the issue source. Just saw the mp4box documentation at http://gpac.sourceforge.net/doc_mp4box.php . Next crummy mp4 I come across, maybe I try the latest MP4box to re-jig it and see if that fixes it ? Say with "-tight" and/or "-isma" ? (saves me installing haali, I like to keep installed codecs/splitters to a minimum using ffdshow & MPC for most things)

Oh, fyi, Firefox printing of http://gpac.sourceforge.net/doc_mp4box.php is problematic per http://forums.mozillazine.org/viewtopic.php?p=2876382 ...


25th February 2008, 13:05
Hi, any new news on "opening an .mp4 in avisynth" front ?

eg, not knowing much about DGAVCDec ... would that do it ? I note its help file says DGAVCDec is an AVC (H.264) decoder suite. It is used to decode AVC streams from such sources as HD-DVD EVOs, captured transport streams, *.264 files, etc. Note that currently only AVC elementary streams and transport streams are supported, so if you have a different container type, such as *.mp4, you will have to demultiplex the raw AVC stream from its container before processing it with DGAVCDec. so what would you suggest to demux the .mp4 ?

25th February 2008, 13:36
Ah, found this wiki entry http://avisynth.org/mediawiki/FAQ_loading_clips#How_do_I_load_MP4.2FMKV.2FM2TS.2FEVO_into_AviSynth.3F which says
If your media file contains MPEG-4 ASP video, then there are two possibilities of opening them in AviSynth ...

and If your media file contains MPEG-4 AVC video, then there are two possibilities of opening them in AviSynth:

1) Using the plugin FFmpegSource. See above for its usage. At the moment, the supported containers are: AVI, MKV and MP4.

2) Get DGAVCDec. At the moment you need to extract the raw stream (*.264) from the container first (using MKVExtract, MPlayer, TSRemux or whatever program can extract those streams). Open the raw stream file in DGAVCIndex to create an index file (say track1.dga). Open the index file in AviSynth

As I'm not sure in the general case how to tell what the .mp4 contains (ASP or AVC), DGAVCDec with [which demuxer?] would do the trick ?

25th February 2008, 17:53
ffmpeg -i input.mp4
will tell you what you have for video.

use yamb (mp4box gui) to extractthee raw h264 stream.


26th February 2008, 10:20
Thankyou. This link http://forum.videohelp.com/topic346811.html#1818343 provides some pictorial detail on how to demux including program version info...
However also note the post underneath it which indicates an error message and what versions did download and work with the newer .mp4 AVC input file.