Log in

View Full Version : Avisynth and m2v sources


Chris K
29th December 2007, 13:09
Hi,

When I use Avisynth to serve a mpeg2 elementary streams like the example below,
Avisynth comes up with the wrong duration. E.g. 00:04:45 hms where the true
duration of the video stream is 00:09:20 hms.

V=DirectShowSource("F:/final.m2v", audio=False)
A=DirectShowSource("F:/final.mp2",video=False)
AudioDub(V,A)

This wouldn't be a problem because most programs report the wrong duration for
mpeg2 elementary streams. Problem is, that Avisynth stops serving at 00:04:45 hms.

I expected that Avisynth would go on serving as long as it finds frames in the
source and not based on the presumed duration.

Is there a way to overcome this problem?

Chris.

Dreassica
29th December 2007, 13:50
Use dgindex to parse the m2v and load with mpeg2source.

IanB
29th December 2007, 21:29
Or use the DirectShowSource(..., Framecount=nnnn) option to override/correct the length value. (Some DirectShow splitters, like fishermen, tend to lie about length)

Chris K
30th December 2007, 12:02
@Dreassica
Works fine, only with the drawback I have to first generate the d2v file manually.
MPEGDecoder.dll does it automatically but came up with corrupted frames?

@IanB
I prefer this one. Can calculate the framecount easily from frame rate and
true duration (which I have available most of the time).
Also found that giving a "oversized" framecount does exactly what I hoped for.
Avisynth just serves frame as long as it can get them. I hope you keep this in.

Thanks to both,
Chris.

IanB
30th December 2007, 13:36
an "oversized" framecountDSS will repeatadly return the last frame in the stream when framecount is larger than the stream.

Chris K
30th December 2007, 16:37
You are right, in case I use:

DirectShowSource("F:/final.m2v", framecount=50000)

it continues with blank frames in my case, but as soon as I use:

V=DirectShowSource("F:/final.m2v", framecount=50000)
A=DirectShowSource("F:/final.mp2")
AudioDub(V,A)

it stops exactly at the...??? probably audio duration. Don't know why?

Edit: Note that I'm feeding the script into FFmpeg. This reports a duration of 00:33:20.0 hms
while the source is about 9 minutes and FFmpeg stops encoding at this time.
When I play the script with WMP it still continues?

Chris.

IanB
30th December 2007, 21:23
Different length audio and video stream are quite legal.

Various tools will use/display either or both lengths, applying either a Min() or Max() function to get a total length or just encoding different lenghts.

Use Trim() to chop/pad the length of both stream to the correct overall length.