PDA

View Full Version : Converting/changing FPS question


Mike109
10th October 2008, 08:00
I want to convert some 30fps progressive NTSC .avi files from a Canon digital still camera to 29.97fps NTSC .avi in order to import into a slideshow program (DVD slideshow GUI).

I have only been working with AviSynth, Avisource, ffdshow and .avi files for a few days, so I am new to all this. I tried to read the pertinent material at avisynth.org/mediawiki and also searched & read pages of messages here at doom9.org.

I am not a programmer so it took me a while to figure out things, but my small script works. However I want to optimize the parameters.

AVISource("C:\Temp Video\Myvideo.avi")
ConvertFPS(29.97)

I am aware of the differences between AssumeFPS, ChangeFPS and ConvertFPS. And have tried all three but cannot tell any difference in picture quality. They all seem to have some blurring. However the source video has blurring & I’m guessing this is because it is 30fps progressive. I have seen scripts using two of these, such as AssumeFPS & ConvertFPS and am not sure why both are used. An example is:

ConvertToYUY2() # Required by ConvertFPS.
ConvertFPS(29.97) # Convert frame rate to NTSC(p), duration unchanged
AssumeFPS(29.97, 1, TRUE)

I understand the "true" parameter will adjust the audio sample-rate to match
the video length. But I thought ConvertFPS did this. What am I missing & how do I properly use the TRUE statement?

Is there a preferred way to minimize blurring & keep the audio in sync?

If “ConvertToYUY2()” is required by ConvertFPS, why does my script work without it?

Thank you in advance,
a stumbling newbie

2Bdecided
10th October 2008, 11:20
You just need

AVISource("C:\Temp Video\Myvideo.avi")
AssumeFPS(30000,1001,true)

This keeps the original frames, and simply slows playback down to 29.97. There will be no additional bluring.


To be honest, I'm surprised you need to change the frame rate. The AVIs from my Canon digital still camera are exactly 30fps, and I have another camera which procuces AVIs that are slightly faster (i.e. even further away from 29.97fps), and most software seems happy to accept either. Any compatibility issues are due to frame size (only 320x240), or audio (only 16kHz or 11kHz), not frame rate.

Hope this helps.

Cheers,
David.

Mike109
10th October 2008, 18:17
David,

Thank you for the reply. The AVIs from my Canon will play on my computer and on my TV when connected to the camera. I tried 30fps with the slideshow program but it did not work. The program author said I need 29.97fps. Perhaps because a DVD can be burned and it needs to be NTSC compliant.

The video clips I'm currently working with only have background sound, nothing that is lip synced to the video. Therefore I cannot tell if audio & video stay in sync. But when I do get to use synced video & audio, how does your script keep the audio in sync? Does it speed it up or re-sample it and cut-out bits?

Thanks again,
Mike

smok3
10th October 2008, 19:43
check http://avisynth.org/mediawiki/AssumeFPS

i belive

AVISource("C:\Temp Video\Myvideo.avi")
AssumeFPS(ntsc_video,true)
ssrc(your samplerate)

should be the full solution.

edit: actually that should be handled by a single command imho, like
AssumeFPS(ntsc_video,sync=true, resample=true) # where resample should know what was the input samplerate automagically
please

Comatose
10th October 2008, 19:48
It slows it down.

assumefps(30000,1001,true) is equal (I think) in function to:

fps = Frameratenumerator()/Frameratedenominator() # 30/1
assumefps(30000,1001,false)
new_fps = 30000.0/1001 #29.97~
multiplier = new_fps/fps # 0.999001
samplerate = audiorate() # 48000
new_samplerate = Int(samplerate * multiplier) # 47952
AssumeSamplerate(new_samplerate) # Audio slowed down to 47952 Hz
#ResampleAudio(samplerate) # Audio resampled to 48000 Hz (or not, I checked after smok3's post and it doesn't do this step...)

smok3
10th October 2008, 21:43
probably there is a reason for no resample, could be that one would want to upsample maybe, dunno...

Mike109
11th October 2008, 02:11
I tried:
AssumeFPS(30000,1001,true)
I got an error message:
Can’t load the file: “C\xxxxxxxxxxxxxxx.avs
Video framerate doesn’t match”.
I’m presuming that is because the framerate is not exactly 29.97fps.

I tried:
AssumeFPS(ntsc_video,true)
I got an error message:
“Can’t load the file: “C\xxxxxxxxxxxxxxx.avs
I don’t know what ‘ntsc_video’ means”.

I tried:
AssumeFPS(“ntsc_video“,true)
I got an error message:
Can’t load the file: “C\xxxxxxxxxxxxxxx.avs
Video framerate doesn’t match”.

From what I can tell from the AviSynth web site, “ntsc_video“ is legitimate.
Maybe it’s not converting exactly and therefore the slideshow program is rejecting it.

So far what works is:
AssumeFPS(29.97)
ChangeFPS(29.97)
ConvertFPS(29.97)

So it appears that if I want to keep the original frames and not add any additional blurring then AssumeFPS(29.97) is the only option. Is this correct or am I missing something?

From everyone’s experience, does anyone really notice the slowdown?

2Bdecided
11th October 2008, 20:40
From everyone’s experience, does anyone really notice the slowdown?Of course not! It's 0.1%.

Cheers,
David.

Mike109
12th October 2008, 02:15
Thank you everyone for your responses.

I have read many, many AviSynth topics on Syntax, Grammar, etc. Anything that I thought may lead me to the basics. But some things I cannot seem to find.

Sometime I see a small script written on a single line, such as previously mentioned:
AssumeFPS(ntsc_video,sync=true, resample=true)

Sometimes I see as shown on the AviSynth web site:
AVISource("FILM_clip.avi") # Get 24fps clip
LanczosResize(768,576) # Resize to PAL square-pixel frame size.
AssumeFPS(25, 1, true) # Convert frame rate to PAL, also adjust audio.
SSRC(44100) # Restore audio sample rate to a standard rate.

But I have never seen when to use a single line vs. multiple lines.

I see quite a bit on resampling audio, but not a lot on the use of “true”.
From what I understand:
AssumeFPS(30000,1001,true)
Resamples the audio & keeps it in sync.
When do you use true instead of a resampling statement?

Also the above referenced AviSynth web site script has:
AssumeFPS(25, 1, true)
What does the number “1” do?

Any guidance would be most appreciated,
Mike

Mike109
12th October 2008, 09:07
More questions - part two.

I have spent hours reading about AviSynth scripts. Maybe it’s because I am not a programmer, but what I find is not in terms that I understand. I’m still working on what should be a relatively small & simple script to convert 30fps to 29.97fps. Take for example the following two scripts that I came across.

assumefps(29.97, sync_audio=true)
ResampleAudio(48000)

AR=AudioRate()
AssumeFPS(29.97, True)
ResampleAudio(AR)

What is the difference between “sync_audio=true” and just “True”?
If I use either of these do I need to ResampleAudio?
If so, what is the difference between the two different ResampleAudio scripts?

Alex_ander
12th October 2008, 09:43
What is the difference between “sync_audio=true” and just “True”?
If I use either of these do I need to ResampleAudio?
If so, what is the difference between the two different ResampleAudio scripts?

1.The difference is in 'full' and 'short' form (parameter is not called by name only its value is written). Short form can be used mainly (and not in all existing filters) in case you've mentioned all previous parameters so that AviSynth could apply parameter values to right parameters.
2.The difference between those scrips is in direct and indirect usage of audio sample rate. 'Indirect' version takes value from input video and restores that value after sync adjustment (where sample rate is changed for this to a non-standard value - that's a probable reason for your having error message in external program).

So you need:

AssumeFPS("ntsc_video",true)
ResampleAudio(48000)

Mike109
12th October 2008, 17:58
1.The difference is in 'full' and 'short' form (parameter is not called by name only its value is written). Short form can be used mainly (and not in all existing filters) in case you've mentioned all previous parameters so that AviSynth could apply parameter values to right parameters.
2.The difference between those scrips is in direct and indirect usage of audio sample rate. 'Indirect' version takes value from input video and restores that value after sync adjustment (where sample rate is changed for this to a non-standard value - that's a probable reason for your having error message in external program).

So you need:

AssumeFPS("ntsc_video",true)
ResampleAudio(48000)


Your script still gives me the error message: "I don’t know what ‘ntsc_video’ means”
Using just "AssumeFPS("ntsc_video") gives the same message.
It appears I need to specify 29.97, such as AssumeFPS(29.97).

But I'm still confused why the need for both of the audio scripts. What happens to the audio if you do not use "ResampleAudio(48000)"?

Wilbert
12th October 2008, 18:26
Your script still gives me the error message: "I don’t know what ‘ntsc_video’ means”
You need to update your AviSynth version.

But I'm still confused why the need for both of the audio scripts. What happens to the audio if you do not use "ResampleAudio(48000)"?
Why don't you try it? You will see that the video and audio are in sync, but the audio has a weird sample-rate.


AssumeFPS("ntsc_video",audio_sync=true)

When setting audio_sync to true your audio is slowed down to the match the duration of your video stream. Your video and audio stream will remain in sync.

The problem is that most encoders won't accept such a weird sample-rate, so you will have the resample it to a "normal" rate by using "ResampleAudio(48000)". (When resampling your audio, it will always remain in sync.)

Mike109
12th October 2008, 22:43
Wilbert,

My AviSynth is version 2.58, build date Aug 30, 2008. I have tried "ntsc_video" several times & I always get the same error message.

I am under the impression from reading the AviSynth wiki that using "ntsc_video" still provided a ratio, but the ratio is still an approximation. My guess is that the DVD slideshow GUI program requires an exact 29.97fps in order to work. Again that is just a guess as I am new to the slideshow program, AviSynth and writing scripts.

The projects that I have been trying only have background sound so I cannot tell if the audio is in sync. If I do not use "ResampleAudio(48000)", how do I check out the weird sample-rate as you mentioned?

Wilbert
12th October 2008, 23:16
My AviSynth is version 2.58, build date Aug 30, 2008. I have tried "ntsc_video" several times & I always get the same error message.
I guess it's a bug then.

I am under the impression from reading the AviSynth wiki that using "ntsc_video" still provided a ratio, but the ratio is still an approximation. My guess is that the DVD slideshow GUI program requires an exact 29.97fps in order to work. Again that is just a guess as I am new to the slideshow program, AviSynth and writing scripts.

In v2.57, the behaviour with respect to the framerate is a bit changed. The main issue is that users are allowed to specify the framerate as float, but the NTSC (FILM and Video) and PAL standards require ratios as framerate. Besides this AviSynth exports the framerate as a ratio, so when specifying a float, it will be converted to a ratio. The ratios of the standards are given by 24000/1001 for 23.976 (FILM) and 30000/1001 for 29.97 (Video). When specifying these floats, they are exported by AviSynth as ratios, but not as the standard ratios.' One of the reasons for this is, that those floats are approximations (remember that 24000/1001 = 23.9760239760...), so how should AviSynth know how to choose the correct ratio? In order to overcome this issue, the user can use AssumeFPS(24000,1001) or simply AssumeFPS("ntsc_film").

Another problem is that the converted floats were (in v2.56 and older) exported with 64 bit precision, resulting in very large numerators and denominators, making some players crash. To overcome this, a smart float-ratio is added internally, and the framerates are approximated accurately by ratios of small numbers.
see http://avisynth.org/mediawiki/AssumeFPS .

Try

AVISource("C:\Temp Video\Myvideo.avi")
AssumeFPS(30000,1001,true)
ResampleAudio(48000)


The projects that I have been trying only have background sound so I cannot tell if the audio is in sync. If I do not use "ResampleAudio(48000)", how do I check out the weird sample-rate as you mentioned?
Try:

AVISource("C:\Temp Video\Myvideo.avi")
AssumeFPS(30000,1001,true)
Info()

2Bdecided
12th October 2008, 23:37
My guess is that the DVD slideshow GUI program requires an exact 29.97fps in order to work.Possible, but a bit rubbish, as NTSC video isn't exactly 29.97fps!

It is exactly the aforementioned fraction.

Cheers,
David.

Gavino
13th October 2008, 00:36
I guess it's a bug then.
I assume you mean a bug in DVD Slideshow GUI, as there sure ain't nothing wrong with Avisynth.

Mike109
13th October 2008, 03:17
I previously tried & just tried again.
AVISource("C:\Temp Video\Myvideo.avi")
AssumeFPS(30000,1001,true)
ResampleAudio(48000)

I get the same error message, and the title bar is from DVD slideshow GUI
Can’t load the file: C\xxxxxxxxxxxxxxx.avs
Video framerate doesn’t match

So I presume the slideshow program is not accepting the script.

45tripp
13th October 2008, 05:05
open the project settings and change to ntsc before importing.

Mike109
13th October 2008, 05:44
open the project settings and change to ntsc before importing.


I did. And I can burn a compliant DVD. But whether I use AssumeFPS, ChangeFPS or ConvertFPS, only using (29.97) seems to work.

Is there a downside to specifying (29.97) versus (30000,1001) or ("ntsc_video")?

45tripp
13th October 2008, 06:00
ok
(i thought i'd tried that.)

no, no downside.

edit:added a note at dvd slideshow development thread

Mike109
13th October 2008, 08:56
When I add the “Info()” to any of the scripts it causes the video to stutter & jump at the beginning. This is when viewing with Windows Media Player 6.4. Of course I would not use Info() in the actual final script.

So it looks like the following script is the one to use because only (29.97) will work with the slideshow program.

AssumeFPS(29.97,true)
ResampleAudio(48000)

2Bdecided
13th October 2008, 12:44
Not that it matters, but are you feeding avs files directly to the slideshow program? What if you render to an intermediate AVI first?

Cheers,
David.

IanB
13th October 2008, 14:35
@Mike109,

1, Info() use the internal text writing routine, and it is quite slow. It is often slow enough to impede realtime playback, but is only intended as a quick diagnostic of clip parameters.

2. It seems DVD Slideshow GUI foolishly want an input FPS of 29.97! (2997/100) It does not seem able to accept the exact ntsc frame rate, i.e. 29.9700299700... or 30000/1001. Realistically it should accept anything between 29.9691 and 29.9709 or maybe more, which would allow a tolerance of +/-200 milliseconds in 2 hours.

The preset name for 29.97! is "ntsc_round_video", you should test it to confirm your premise about DVD Slideshow GUI's restriction.

3. I use the term "Reclock" when describing the change in the sample rate of video or audio without changing the actual data samples. This is what AssumeFPS() and AssumeSampleRate() do, i.e. they just change the specification of how fast to play back the data samples, they change the information speed.

ChangeFPS(), ConvertFPS(), ResampleAudio() and SSRC() all keeps the information speed the same but change the sample rate by changing the actual data samples.
...Source(...) # 30/1 fps, 44100Hz
AssumeFPS("ntsc_round_video", true) # reclock to 2997/100 fps, 44056Hz
ResampleAudio(48000) # 2997/100 fps, 48000Hz

Mike109
14th October 2008, 00:15
Initially I did create a new AVI using VirtualDub. I did use 29.97fps for the new AVI and the video did play in DVD slideshow GUI. It was suggested I use AviSynth and use a script versus creating a new AVI in order to not lose any quality by converting to an intermediate format.

For what it’s worth, the DSG forum does state:
“DSG only takes 25 (PAL) or 29.97 (NTSC) frames pr. sec.”

I did try "ntsc_round_video” and the slideshow did accept this:
AssumeFPS("ntsc_round_video",true)
ResampleAudio(48000)

Comatose
14th October 2008, 07:45
Pfft. A know-it-all developer who doesn't actually know what he's doing...

45tripp
14th October 2008, 08:35
Pfft. A know-it-all developer who doesn't actually know what he's doing...

uhmmm
tin3tin is always asking questions and trying things...

Comatose
14th October 2008, 10:03
Really? tin3tin's the developer? I thought it was some commercial program... ><

I take it back then, sorry!

2Bdecided
15th October 2008, 12:13
It was suggested I use AviSynth and use a script versus creating a new AVI in order to not lose any quality by converting to an intermediate format.You could use a lossless intermediate format. I asked the question because some software which thinks it works properly with AVS, doesn't. Sometimes rendering the AVS to AVI in VirtualDub is enough to solve the problem.

I'm not proposing this as a solution - just one method of finding out exactly where the problem is (or isn't).

Cheers,
David.

neuron2
15th October 2008, 12:21
Pfft. A know-it-all developer who doesn't actually know what he's doing... You're barely escaping a rule 4 strike for this. You may want to re-read our forum rules.

http://forum.doom9.org/forum-rules.htm