# Let's change Version to 29.970fps using a permitted rate/scale combination. # We'll use ChangeFPS to duplicate frames as required. The rate/scale of # 30000/1001 comes from the table of permitted values for acheiving 29.970fps # on DivX Labs. # Version().AddBorders(2,80,2,80,$000000).ChangeFPS(30000,1001) # Now do the same with a clip that has an audio track. Notice that ChangeFPS # doesn't change the duration of the track or modify the audio, so there is # no extra work to do! # myvideo = Version().AddBorders(2,80,2,80,$000000) # myaudio = WAVSource("C:\SomeFolder\MyAudio.wav") # mydub = AudioDub(myvideo, myaudio) # return ChangeFPS(mydub, 30000,1001) # We can also write the above more simply. Remember that almost everything # in AVISynth is either inputting or outputting a "clip", making it easy to # chain filters together. When you use the "." symbol the clip on the left of # the "." just becomes the first argument to the filter on the right of the # symbol. In the example below we also use the "\" symbol to break an expression # between multiple lines for readability. # Version().AddBorders(2,80,2,80,$000000)\ # .AudioDub(WAVSource("C:\SomeFolder\MyAudio.wav")).ChangeFPS(30000,1001) # Okay, how about AssumeFPS? Remember, there is more work to do with AssumeFPS # and it's probably not the best choice because it implies changing the audio # or introducing a small desync. Let's assume the following AVI file has an # audio track at 44.1Khz, and simply adapt it to our new frame rate. This will # cause a pitch shift that will become more noticable for larger rate changes. # After adapting the rate we resample the audio back to a standard rate, # e.g. back to 44.1Khz ready for encoding later. We could use VirtualDub's #"Save WAV..." function (from the File menu) to write the processed audio to file. # # By using AVISynth to process the audio we're assuring everything stays in sync, # even if we use AVISynth's Trim() filter to cut up the video. # # In the example below we use the Audiorate() clip property to automatically # convert the resampled audio to the same rate as in the original file # (which we assume is a standard rate). # # See http://avisynth.org/mediawiki/Clip_properties for more clip properties. # MyVideo = AVISource("C:\SomeFolder\SomeFile.avi") # Return MyVideo.AssumeFPS(30000, 1001, sync_audio = true)\ # .ResampleAudio(MyVideo.Audiorate()) # Let's do the same again, but this time we'll time-stretch the audio to avoid # changing its pitch. With a good timestretch algorithm you should be able to # alter the duration by at least 3-4% without artifacts becoming too noticable. # Because the audio is coming from an AVISource we'll create two new clips to # cleanly separate the audio, process it, then dub everything back together again. # Note that TimeStrech is not 100% precise, the documentation states that: # # "inaccuracies should not exceed a few 10's of milliseconds for movielength samples" # # .. so we only want to use TimeStretch when we're correcting larger desync's. # # In the example below we use the FrameRate() clip property to automatically # calculate the tempo change based upon the original frame rate and the new # frame rate (tempo = 100 mean original tempo). # MySource = AVISource("C:\SomeFolder\SomeFile.avi") # MyVideo = MySource.KillAudio().AssumeFPS(30000, 1001) # MyAudio = MySource.GetChannel(1,2)\ # .TimeStretch(tempo = (100 * MyVideo.Framerate()) / MySource.Framerate()) # Return AudioDub(MyVideo, MyAudio) # Finally, keep in mind that ConvertFPS may introduce desync with subtitle formats # that are based upon associating subtitles with frame numbers, and AssumeFPS may # introduce desync with subtitle formats that are based upon associating subtitles # with timestamps. If you have have already prepared subtitle files for your video # ensure that you either choose a suitable rate adjustment method, or convert your # subtitles into an appropriate format before muxing them into the final file.