Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th July 2012, 19:42   #1  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Samplerate and Sync.

Okay i am recording gameplays, and i get Desync overtime.
It seems to be the cause of some kind of sync clock between the sound and the CPU, i have 2 sound cards, 1 built in, 1 external.

Of both of them i get best results with the one built in.
Though i do get desync overtime, but itīs not delay, itīs the opposite, so in 5 hours of constant gameplay, the audio can be about 500ms earlier then the video.


Now i have "solved" this by manually adding DelayAudio(x.xx), but itīs not a good solution.

So now i started to think, isnīt there a way to make it go 500ms slower over 5 hours?

I donīt know how to calculate that, so i found a setting called AssumeSamplerate (tried playing with fps but it changed the video of course).

And if i use it to reduce the samplerate with 1, itīs pretty much in sync.

from 48000 to 47999.

Donīt know what changed there, but i guess it plays a small bit slower.

The problem is, i got a separate Intro, and i usually use SSRC() to get both of them into 48khz, but SSRC canīt change the samplerate of 47999 to that, so i have to reduce it to 44.1khz.


I normally donīt care about that becuase itīs not audible, but i want to know for learning reasons.

Is there a way to do what i am doing more properly?
Is there anything thatīs wrong?

Thanks
zerowalker is offline   Reply With Quote
Old 12th July 2012, 19:56   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
I calculate sample rate for 0.5 delay over 5 hours (18000 secs) to be 0.999972222 of original
which at 48000 is 47998.66667 or about 47999 as you tried.

Suggest maybe
Code:
    AssumeSamplerate(47999)
    ResampleAudio(48000)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 12th July 2012, 20:04   #3  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
How did you calculate that?
This kind of calculation is not within my field if i say so;P

And yes i noticed that ResampleAudio works but SSRC doesnīt.
But SSRC is higher quality (atleast i read so).

But wondering, should i resample the to a standard samplerate, or should i resample the separate files to the 47999 samplerate?

Last edited by zerowalker; 12th July 2012 at 20:11.
zerowalker is offline   Reply With Quote
Old 12th July 2012, 20:25   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
((18000-0.5) / 18000.0) = 0.999972222

0.999972222 * 48000 = 47998.66667 ie 47999 would play about 0.5 secs longer.

Well, to lengthen the sample, you play 1 sample fewer per second so over 5 hours
the fewer played samples accumulate to about 0.5 and so plays longer (or later @ 5 hours)
but if you want to eg burn on DVD using standard samplerate then you have to resample
to be compatible. SSRC used be be a lot better than Resampleaudio, but not any more
http://forum.doom9.org/showthread.php?t=165321

SSRC is more restrictive in what rates it can convert and will often fail, it is also slower.

Suggest as posted in previous post, or if you want 44.1Khz then 44100 instead of 48000
in ResampleAudio().

You could also use TimeStretch filter, but over 5 hours, it may not work reliably (lack of precision).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 12th July 2012, 20:33   #5  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Ah nice, learned some calculation, will go back many times for that one, i am really not that bright with math;P

Hmm as i understood SSRC was better thanks to the 32bit float, but now ResampleAudio has it aswell, so there isnīt really any difference, and SSRC has much more restrictions?

I am going for playback on PC, but this will go to youtube, which uses 44.1.

But what is the highest quality, or mostly intact to the originaly, resampling to 48khz (adding 1 samplerate), or downsampling to 44.1, or letting it stay at the Assumedsamplerate (i guess this one).
And is there a way to make AssumeSamplerate work with a more precise number (47998.66667)?

And another thing, as i understand, my sound is recording in about 1.3 samplerates to few each second, or something.
What is lost with that except losing some secs over a long time?

Is the audio Really slower?
As it doesnīt skip anywhere, so i canīt think of anything else then that it doesnīt follow the correct samplerate.

Last edited by zerowalker; 12th July 2012 at 20:42.
zerowalker is offline   Reply With Quote
Old 12th July 2012, 20:49   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
If you want to change the length then you need to do the AssumeSampleRate otherwise
the length will be wrong. After that, you choose whatever compatible rate you require.
If you dont resample, you could just play that on PC and be happy, so long as you dont want to
give it to YouTube or burn on DVD etc, you take your pick. If you want two different versions,
then convert to 44.1 for YouTube and decide what you want for yourself, 48 or 44.1khz would be
the better choice unless you just dont care. Which is best, well it probably does not matter too
much, as far as I know, adult humans can hear in the (roughly) 20hz to 20khz range (babies
probably a little higher, because they are smaller, and less damaged hearing over time). To
accurately represent 20khz you need double that, ie 40khz, so even CD 44.1 khz is a little
excessive to most needs, and DVD 48khz is well, un-necessary. Where high rates are good to have,
is in the studio where many transformations may be done, the higher sample rate keeps better
precision, but when editing and manipulation is complete, then 44.1 khz is probably quite sufficient.
I'm sure there are many here on D9 who would disagree, but they must have hearing that is out of
human range (I have long suspected that many of them have pointy ears).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 12th July 2012 at 21:17.
StainlessS is offline   Reply With Quote
Old 12th July 2012, 21:14   #7  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
I Will go with 47999 if there isnīt a way to be more precise.
And if youtube doesnīt downsample it, i will do it manually.

But what i donīt understand with the, humans hear 20 to 20k, is the thing with 44.1 and 48.
I understand that there is more precision from Analog to Digital with higher samplerate, and Bit depths and all that. But how come you canīt downsample from 40+ to 20khz, without it sounding like a radio, i thought we only heard till 20khz?

I guess itīs some technical thing and not constatly related to the human hearing samplerate estimation?
zerowalker is offline   Reply With Quote
Old 12th July 2012, 21:21   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
If you downsample 40khz+ to 20khz, then it can only accurately represent 20khz/2 = 10khz.
Hence the radio like sound. You need twice the sample rate.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 12th July 2012, 21:29   #9  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Oh, why is that?
Why not just name it 10khz instead of 20 then?
Or am i missing something?
zerowalker is offline   Reply With Quote
Old 12th July 2012, 22:02   #10  |  Link
librarian
Registered User
 
Join Date: Nov 2011
Posts: 63
Quote:
Originally Posted by StainlessS View Post
... then 44.1 khz is probably quite sufficient...
I agree, for normal adults 40 y.o. limits are often 40 - 14.000 Hz.
On Youtube there are some tests:

http://www.youtube.com/watch?v=R0A72A-c8EU
http://www.youtube.com/watch?v=igGroIcga3g

I ignore their precision (it depends on your sound card too), but for a rough measure may be enough.

@ zerowalker

Nyquist Theorem
librarian is offline   Reply With Quote
Old 12th July 2012, 23:18   #11  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 720
Doing listening tests on with Youtube videos or with any lossy-compressed sound seems to be a bad idea! Audio coders often apply a low-pass filter on the source before encoding to limit the content bandwidth explicitly.

Back to the topic, you should resample your sound instead of just setting its sampling rate to a value extremely close to a standard rate. Some players might round it to 48000 Hz, like video decoders sometimes do with 29.970000 fps they round to the exact ratio 30000/1001 = 29.970029970029... Convert it to 44.1 or 48 kHz, it doesn't matter much, especially if you want to upload it on YT where it will be compressed and damaged anyway.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 13th July 2012, 09:16   #12  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Okay i have uploaded it for now, will see if itīs anything wrong with it.
And for the decoding, it says the correct samplerate (LAV Audio).

But still wondering, as StainleSS calculated, the samplerate is in float, but AssumeSamplerate only works in Int.
Is there a way to workaround this?
Itīs not a Big issue, but it would be nice to sync it more precise.
zerowalker is offline   Reply With Quote
Old 13th July 2012, 13:19   #13  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
I think i learned a way to workaround the Int restriction.

If i use this: AssumeFPS(29.99921630094044, sync_audio=true)
for example.

a = video.
b = video_audio.AssumeFPS(29.99921630094044, sync_audio=true)

a.Audiodub(video_audio)


Is there anything wrong with this?
Is it worse/better or identical to the use of Assumesamplerate?
zerowalker is offline   Reply With Quote
Old 13th July 2012, 16:35   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
Samples may be in float, but samplerate is ALWAYS in int.

Do as already suggested, you are just wasting your time.

EDIT: You are also giving yourself a messed up video frame rate to match a messed up audio rate.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 13th July 2012 at 16:46.
StainlessS is offline   Reply With Quote
Old 13th July 2012, 16:43   #15  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Okay, but how am i wasting time, doesnīt the thing i wrote above work accurately?
Or is there something thatīs bad with it?

And your suggestion, do you mean stay with a rounded number, or use timestretch?
Cause timestretch works pretty much as what i am trying to do i think?
zerowalker is offline   Reply With Quote
Old 13th July 2012, 16:58   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
AssumeSamplerate(47999)
ResampleAudio(48000)

See previous EDIT.

Timestretch at 5 hours would probably work but due to float precision and the maths it uses, it would
likely result in your only being able to adjust length in steps of maybe 0.5 seconds, maybe 1 second,
something like that. I've done it before and ended up spending a LOT of time to little good effect.
If you want to use timestretch, suggest cutting into several pieces and adjust them individually.
It might not be 5 hours, may be about 7 hours, but at some point the precision is insufficient
and is just not usable. Try it yourself, but dont ask me to help, I've already been there.

EDIT: If you do try Timestretch, cutting into pieces, then give yourself a few extra seconds on the
ends of EACH piece.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 13th July 2012 at 17:00.
StainlessS is offline   Reply With Quote
Old 13th July 2012, 20:23   #17  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Yeah i know that, it worked very well, but itīs not precise with the samplerate thanks to Int.

And as you say that Timestretch is not the best piece of work i havenīt tried it, and donīt think i really want to.

But i want to know as i wrote before, is there a reason not to use this:

AssumeFPS(29.99921630094044, sync_audio=true)
And take that audio and put it in the same clip but with original 30fps.

That way i donīt have to resample, and i get to work with float numbers to get a more precise sync
zerowalker is offline   Reply With Quote
Old 13th July 2012, 20:38   #18  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
sync_audio=true, resamples.

EDIT: Oops, no it doesn't its same as as AssumeSampleRate, but to match the new length
after ASsumeFPS.

If you want to use AssumeSampleRate, then why do it via the back door using AssumeFPS
for a clip that you will throw away anyway.

EDIT: You're going to give your self a headache.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 13th July 2012 at 21:11.
StainlessS is offline   Reply With Quote
Old 13th July 2012, 21:13   #19  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Itīs because AssumeSampleRate uses Int and canīt be precise.
AssumeFPS uses Float and can be as precise as the calculation is.

Itīs not necessary for this stuff to be Perfect no, but itīs better to learn it if i need it in the future
zerowalker is offline   Reply With Quote
Old 13th July 2012, 22:01   #20  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,151
I'm not altogether sure what it is that you have learnt.

From Avisynth source
Code:
int audio_samples_per_second;   // 0 means no audio
So no matter how you arrive at your destination, the sample rate is always going to be int.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 13th July 2012 at 22:09.
StainlessS is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:21.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.