Log in

View Full Version : Problem with TimeStretch


daWsOn_s
23rd December 2008, 02:21
########################################
# [Source: NicAc3Source]
########################################
NicAc3Source("E:\WHEN_HARRY_MET_SALLY_SKU_3\VIDEO_TS\fddfs.ac3")

########################################
# [DSP: TimeStretch - 25 -> 23,976]
########################################
TimeStretch(last, rate=95.904)


Hello,
i have a problem with TimeStretch, I'm doing some PAL DVD rips than I want to re-encode to 24p (23,976) with original audio pitch and tempo.
The problem is that when I use TimeStrech the 6 channels end up mixed wrong.
Those files are from "when harry met sally".
This first one is the "original" one, this means that the pitch and speed are PALed. Anyway you can hear that the harry and sally voices are almost perfectly on the left and right.

http://www.megaupload.com/it/?d=4CTNHUKD

In this one (encoded with TimeStretch to recreate the original 24p) you can hear the voices get "mixed" up. They tend to go also on the other side and create a weird distant sound. In the "Constantine" movie in some scenes seems like you're hearing the sound in a tube:eek:

http://www.megaupload.com/it/?d=G46NKGYZ

At first I thought it was some error in the 5.1 handling so I tried to downmix to stereo but it happens anyway. I tried to change also in mp3,mp2,wav ... always the same. The problem appears ONLY with TimeStretch even if I just put the command without actually changing the final file of tempo and pitch like TimeStretch(last, rate=100).

Is that a bug?

tebasuna51
23rd December 2008, 10:44
Your first sample audio25p.m4a is stereo and not ac3 like you show in the avs, seems a dpl downmix from audio24p.m4a (5.1 and with more duration than audio25)

In the two samples the left and right channels (after upmix dpl audio25p) are correct and different but the center channnel is a mix of left, right and other channel.

Please put the original ac3.

daWsOn_s
23rd December 2008, 14:16
Sorry my mistake.

Here's the original AC3 (http://www.megaupload.com/it/?d=0Q80VV9L) and the correct 6 channels 25p econding (http://www.megaupload.com/it/?d=D1Q3D6XK) (which is fine)

tebasuna51
24th December 2008, 02:43
Sorry but I can't reproduce your problem.
In original ac3 the Left channel only have Harry voice and Right channel only Sally voice but the Center channel have 75% of Sally + 100% of Harry + rings and other voices.
After the TimeStretch the channel composition was identical without any new mix. Of course the pitch is changed and maybe you listen this strange.

IanB
24th December 2008, 08:22
For stereo (2 channel) TimeStretch processes both channels in unison, i.e. it maintains the phase relationship between the 2 channels.

For all other channel counts each channels is processed completely independently, so the phase relationship between the channels is destroyed!

Research up on how the SoundTouch library we use works. :search: "TimeStretch SoundTouch" by Sh0dan circa 2004

tebasuna51
24th December 2008, 14:58
For stereo (2 channel) TimeStretch processes both channels in unison, i.e. it maintains the phase relationship between the 2 channels.

For all other channel counts each channels is processed completely independently, so the phase relationship between the channels is destroyed!

First time I see that. Seems Sh0dan forget add to doc ...

...
The phase problems however remains when there are more than 2 channels present. I will make a note in the documentation.

Then, for rate conversion, we must use SSRC?
Or there are the same problem?

The phase is preserved with this 25 -> 23.976 conversion?:

ssrc(50050)
AssumeSampleRate(48000)

IanB
24th December 2008, 23:04
Yes, both SSRC() and ResampleAudio() are phase stable resamplers.

But this method changes the rate and pitch by ~4% which is not much ;)


For bonus points we could try experimenting with this style :-...
ConvertAudioToFloat()
M=ConvertToMono().Amplify(20)

C1=MergeChannels(GetChannel(1), M).TimeStretch(rate=95.904).GetChannel(1)
C2=MergeChannels(GetChannel(2), M).TimeStretch(rate=95.904).GetChannel(1)
C3=MergeChannels(GetChannel(3), M).TimeStretch(rate=95.904).GetChannel(1)
C4=MergeChannels(GetChannel(4), M).TimeStretch(rate=95.904).GetChannel(1)
C5=MergeChannels(GetChannel(5), M).TimeStretch(rate=95.904).GetChannel(1)
C6=MergeChannels(GetChannel(6), M).TimeStretch(rate=95.904).GetChannel(1)

MergeChannels(C1, C2, C3, C4, C5, C6)It makes a master mono track that we amplify a lot to make it very dominant. Then we perform 6 stereo TimeStretches, hopefully the very dominant mono track drives the correlation decisions within SoundTouch almost the same each time. We discard the dominant mono track, and reassemble the 6 individual tracks.

daWsOn_s
25th December 2008, 04:04
Hello,
i tried this.


########################################
# [Source: NicAc3Source]
########################################
NicAc3Source("E:\WHEN_HARRY_MET_SALLY_SKU_3\VIDEO_TS\1.ac3")

SSRC(50050).AssumeSampleRate(48000)


It seems to work, that means that the pitch and tempo are changed without the channels problem.
I need the avisynth script as final file to use it in megui, is there a gui to create the code without writing the code everytime? (for example I use BeLight for TimeStrech).
Can I use "50050,5"?
Why do I have to apply AssumeSampleRate? isn't 50050 the result with that sample rate?
Is "AssumeSampleRate(50050).SSRC(48000)" the same thing?

tebasuna51
25th December 2008, 21:16
Yes, both SSRC() and ResampleAudio() are phase stable resamplers.

But this method changes the rate and pitch by ~4% which is not much ;)
The ssrc(50050).AssumeSampleRate(48000) method don't change the rate (48000 before and after), affects both tempo and pitch at the same time, like TimeStretch(rate=) method:
# Sound tempo can be increased or decreased while maintaining the original pitch.
# Sound pitch can be increased or decreased while maintaining the original tempo.
# Change playback rate that affects both tempo and pitch at the same time.

The TimeStretch(tempo=) method, to preserve the pitch, can't be replaced with ssrc().AssumeSampleRate().

tebasuna51
25th December 2008, 21:37
Can I use "50050,5"?
No
Why do I have to apply AssumeSampleRate? isn't 50050 the result with that sample rate?
For the 'SlowDownd' 25 -> 23.976 we need more audio samples to increment the duration, then we convert from 48000 samples per second to 50050 but after say than must be played as 48000.
Is 50050 because:
(23.976... is exactly 24000/1001)
25 x 48000 / (24000/1001) = 50050

Is "AssumeSampleRate(50050).SSRC(48000)" the same thing?
Just the inverse, the 'SpeedUp' 23.976 -> 25.

I need the avisynth script as final file to use it in megui, is there a gui to create the code without writing the code everytime?
You can use BeHappy instead Megui for audio conversion, replacing the file SSRC.extension with this one (include the options SlowDownd and SpeedUp):
<?xml version="1.0"?>
<BeHappy.Extension xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://workspaces.gotdotnet.com/behappy">
<AudioDSP UniqueID="325bfe50-85b7-11da-a72b-0800200c9a66">
<Plugin>
<MultiOptionDSP Type="BeHappy.Extensions.MultiOptionDSP, BeHappy">
<DialogWidth>0</DialogWidth>
<TitleFormatString>Resample SSRC - {0}</TitleFormatString>
<Option>
<Name>SpeedUp 23.976->25</Name>
<Value>AssumeSampleRate(last, (AudioRate()*1001+480)/960).SSRC(AudioRate(last))</Value>
</Option>
<Option>
<Name>SlowDown 25->23.976</Name>
<Value>SSRC(last, (AudioRate()*1001+480)/960).AssumeSampleRate(AudioRate(last))</Value>
</Option>
<Option>
<Name>48000 Hz</Name>
<Value>SSRC(last, 48000)</Value>
</Option>
<Option>
<Name>44100 Hz</Name>
<Value>SSRC(last, 44100)</Value>
</Option>
<Option>
<Name>32000 Hz</Name>
<Value>SSRC(last, 32000)</Value>
</Option>
<Option>
<Name>24000 Hz</Name>
<Value>SSRC(last, 24000)</Value>
</Option>
<Option>
<Name>22050 Hz</Name>
<Value>SSRC(last, 22050)</Value>
</Option>
<Option>
<Name>16000 Hz</Name>
<Value>SSRC(last, 16000)</Value>
</Option>
<Option>
<Name>12000 Hz</Name>
<Value>SSRC(last, 12000)</Value>
</Option>
<Option>
<Name>11025 Hz</Name>
<Value>SSRC(last, 11025)</Value>
</Option>
<Option>
<Name>8000 Hz</Name>
<Value>SSRC(last, 8000)</Value>
</Option>
</MultiOptionDSP>
</Plugin>
</AudioDSP>
</BeHappy.Extension>

IanB
25th December 2008, 21:58
Opps!<Option>
<Name>SpeedUp 23.976->25</Name>
<Value>AssumeSampleRate(last,50050).SSRC(48000)</Value>
</Option>
You could also make it generic i.e.AssumeSampleRate(last,AudioRate()*1001/960).SSRC(AudioRate())

tebasuna51
26th December 2008, 02:19
Opps!
Corrected my error and accepted IanB suggestion.

When AudioRate()*1001/960 isn't a integer the conversion isn't exact because ssrc only accept integers like parameter.

IanB
26th December 2008, 06:19
Okay, more correctly (AudioRate()*1001+480)/960

i.e. For 44100 the intermediate number is 45983.4375 so do you want 45983 or 45984


And if you are going to say "SSRC(last, " then to be consistent you should say "AudioRate(last)"

tebasuna51
26th December 2008, 12:27
And if you are going to say "SSRC(last, " then to be consistent you should say "AudioRate(last)"

Yes, only confirm a doubt about 'last' variable. With:

AssumeSampleRate(last,48000)
AssumeSampleRate(last,50050).SSRC(AudioRate(last))

This AudioRate(last) is still 48000 because the 'last' variable in asigned only when the full line is finished?

Gavino
26th December 2008, 13:18
This AudioRate(last) is still 48000 because the 'last' variable in asigned only when the full line is finished?
Yes, that's correct.
Any implicit assignment to 'last' takes place after evaluation of the entire statement.

daWsOn_s
11th March 2009, 15:18
Does this give the same result?


TimeStretch(last, rate=95.904)

SSRC(last, 48000)



Or I must not use TimeStretch?

EDIT: nevermind, it creates the artifacts