Log in

View Full Version : MPEG and Avisynth


AlexeyS
19th July 2005, 17:46
Can I make Avisynth to have MPEG2 output? For example, I have script:
loadplugin("c:\Program Files\AviSynth2\plugins\dgdecode.dll")
loadplugin("c:\Program Files\AviSynth2\plugins\decomb.dll")
loadplugin("c:\Program Files\AviSynth2\plugins\TomsMoComp.dll")
movie = MPEG2Source("d:\1.d2v")
movie = TomsMoComp(movie,0,15,1)
movie = LanczosResize(movie,720,400)
l = WAVSource("d:\waves\FL.wav")
c = WAVSource("d:\waves\C.wav")
r = WAVSource("d:\waves\FR.wav")
rl = WAVSource("d:\waves\SL.wav")
rr = WAVSource("d:\waves\SR.wav")
s = WAVSource("d:\waves\LFE.wav")
audio = MergeChannels(l,c,r,rl,rr,s)
audiodub(movie,audio)

I want the application (Nero Recode) see this file as MPEG2 with AC3 muxed - and not as AVI. Is this possible?

mg262
19th July 2005, 17:49
Can I make Avisynth to have MPEG2 output? For example, I have script:
loadplugin("c:\Program Files\AviSynth2\plugins\dgdecode.dll")
...
audiodub(movie,audio)

I want the application (Nero Recode) see this file as MPEG2 with AC3 muxed - and not as AVI. Is this possible?Not really (AFAIK), but I don't see why you would want to do that. When you compress, you lose quality. So you gain nothing (and lose something) by making it see an MPEG2 rather than uncompressed video. Similarly for AC3 versus uncompressed audio. perhaps you could explain what your intent is?

AlexeyS
19th July 2005, 18:35
Not really (AFAIK), but I don't see why you would want to do that. When you compress, you lose quality. So you gain nothing (and lose something) by making it see an MPEG2 rather than uncompressed video. Similarly for AC3 versus uncompressed audio. perhaps you could explain what your intent is?
Ok. I want to encode MPEG2+AC3 to Nero Digital AVC - HDTV AVC profile. My MPEG2 and AC3 tracks are ok. If I convert it to Xvid or something else, I get new encoded movie without any problems.

But when I encode movie with Nero Recode, I have really big video/sound sync problem.

I can't encode video (MPEG2 to AVC) and audio (AC3 to AAC) separately and then mux it, because MP4Box have problems with muxing HDTV AVC video too.

The only way is to mux MPEG2 video with AC3 audio and encode it with Nero Recode.

But the problem is Nero Recode has terrible deinterlacer and I get laggy video output.

mg262
19th July 2005, 18:40
I don't believe you can get any kind of output from AVISynth except uncompressed... but even if you could, it would be equivalent to taking the output and passing it through an MPEG2 encoder like CCE. You could trying doing this or similarly try encoding with say XVid (at a very high bit rate in either case) and then passing that into Nero recode, but I think you would be much better off trying to find the cause of the sync problems. Actually, do you get sync problems if you encode to XVid and pass the result into Recode?

Edit: here is something else to try. Figure out what the frame rate is (either 25 for29.97 most probably), and just pass your input through the script:

AssumeFPS( 25 or 29.97 )

encode the result as XVid and see whether it is in sync.

AlexeyS
19th July 2005, 19:07
I don't believe you can get any kind of output from AVISynth except uncompressed... but even if you could, it would be equivalent to taking the output and passing it through an MPEG2 encoder like CCE. You could trying doing this or similarly try encoding with say XVid (at a very high bit rate in either case) and then passing that into Nero recode, but I think you would be much better off trying to find the cause of the sync problems. Actually, do you get sync problems if you encode to XVid and pass the result into Recode?
No, of course I don't want to recompress. I just want to Recode 'thinks' I give MPEG2 to it.

Audio sync problem is there. I try to encode properly for about month - I think I've tried everything. It seems HDTV AVC has a lot of bugs (when I encode same video not as HDTV, there is no any problems).

So Nero Recode and MP4Box still have bugs. I think it's, because nobody encoded movies/video to HDTV AVC profile yet.

AlexeyS
19th July 2005, 19:26
AssumeFPS( 25 or 29.97 )
Ok, I'll try. But is it only for video? Maybe I need this also for audio (how?)?

mg262
19th July 2005, 19:36
Ok, I'll try. But is it only for video? Maybe I need this also for audio (how?)?
Nothing to the audio.

If the frame rate is exactly what it is 'supposed to be' that line shouldn't change anything and things should stay in sync. If it's out by a tiny fraction, the rate-changed video will be out of sync with the unchanged audio. In theory!

AlexeyS
19th July 2005, 19:50
Nothing to the audio.

If the frame rate is exactly what it is 'supposed to be' that line shouldn't change anything and things should stay in sync. If it's out by a tiny fraction, the rate-changed video will be out of sync with the unchanged audio. In theory!
I don't understand why I need to encode Xvid first and then encode Xvid to Recode. :confused:

When I encode to Xvid - I always get 'right' video/audio file without any sync problems.

Prodater64
19th July 2005, 19:57
Ok. I want to encode MPEG2+AC3 to Nero Digital AVC - HDTV AVC profile. My MPEG2 and AC3 tracks are ok. If I convert it to Xvid or something else, I get new encoded movie without any problems.

But when I encode movie with Nero Recode, I have really big video/sound sync problem.

I can't encode video (MPEG2 to AVC) and audio (AC3 to AAC) separately and then mux it, because MP4Box have problems with muxing HDTV AVC video too.

The only way is to mux MPEG2 video with AC3 audio and encode it with Nero Recode.

But the problem is Nero Recode has terrible deinterlacer and I get laggy video output.

As I understand, you have a mpeg2 video elementary stream and an ac3 audio stream.
If you have individual wavs (as I see in your script) from each channel rebuild ac3 with besweet.
If you want to multiplex it as mpeg2 program stream, just do it with bbmpeg (yes, it multiplex mpeg video streams with ac3 audio).
If you need to apply resize and another filters, you need to pass it through avisynth, then avisynth video output is raw video = uncompressed video and you have not any other option than recompress it.

mg262
19th July 2005, 20:18
I don't understand why I need to encode Xvid first and then encode Xvid to Recode. :confused:In an attempt to figure out at what stage in the process the synchronisation error comes in. I'm really not an expert on this at all; this is just the kind of technique I've used in similar situations -- it's very possible that someone might give you better advice.

AlexeyS
25th July 2005, 21:14
Edit: here is something else to try. Figure out what the frame rate is (either 25 for29.97 most probably), and just pass your input through the script:

AssumeFPS( 25 or 29.97 )
Tried this:
...
...
...
audio = MergeChannels(l,c,r,rl,rr,s)
audiodub(movie,audio).AssumeFPS(29.97)

Still have problem. It seems audio has smaller FPS than video. But waves were converted from 'normal' AC3 file. I mean, if I'll mux it to mpeg, there will be no audio sync problem.

Prodater64
25th July 2005, 23:33
Still have problem. It seems audio has smaller FPS than video. But waves were converted from 'normal' AC3 file. I mean, if I'll mux it to mpeg, there will be no audio sync problem.


1 - Did you read my previous post. I would thank you if you said thanks, at least.

2 - What are individual streams time (audio and video)?

AlexeyS
26th July 2005, 10:00
1 - Did you read my previous post. I would thank you if you said thanks, at least.
Thanks.

2 - What are individual streams time (audio and video)?
Streams time are the same. I've said:
But waves were converted from 'normal' AC3 file. I mean, if I'll mux it to mpeg, there will be no audio sync problem.

Prodater64
26th July 2005, 14:49
But waves were converted from 'normal' AC3 file. I mean, if I'll mux it to mpeg, there will be no audio sync problem.

Did you try to do what I said.
Rebuild ac3 and multiplex with bbmpeg?

AlexeyS
26th July 2005, 14:52
Did you try to do what I said.
Rebuild ac3 and multiplex with bbmpeg?
Yes, I've tried and it works. But what if I need to do good deinterlace first? I need to use AviSynth anyway.

Wilbert
31st July 2005, 12:03
But what if I need to do good deinterlace first?
Just process your video with AviSynth. Question, has your AC3 a delay? Did you add that delay in bbmpeg? Did you add that in those wav files of your first script?

AlexeyS
31st July 2005, 12:31
Just process your video with AviSynth. Question, has your AC3 a delay? Did you add that delay in bbmpeg? Did you add that in those wav files of your first script?
No, when I mux MPEG2 video and AC3 audio - it's ok. No delays etc.

Prodater64
31st July 2005, 19:24
... But what if I need to do good deinterlace first? I need to use AviSynth anyway.

Of course you need to use avisynth if you want to apply any filter or resize to your original stream, but then is not only recode, but re-encode.
So, decide what want to do between possibles options:

Recode with any change.
Reencode using avisynth, doing resize and filtering, deinterlacing, etc. as you want.

AlexeyS
31st July 2005, 19:57
Of course you need to use avisynth if you want to apply any filter or resize to your original stream, but then is not only recode, but re-encode.
So, decide what want to do between possibles options:

Recode with any change.
Reencode using avisynth, doing resize and filtering, deinterlacing, etc. as you want.
Maybe it's possible to use .avs scripts (with sound) with Recode?

Recode has no filters (except bad deinterlace, resize and crop).

Re-encoding is not good, I don't want to use 70-120 Gb videos - it's ugly.

Prodater64
31st July 2005, 21:09
Maybe it's possible to use .avs scripts (with sound) with Recode?



I don't know that. Im not Nero Recode user.