View Full Version : Joining two vidoes with different FPS
tacman1123
23rd October 2008, 22:52
I have two video clips, one from a DV Camera, one from a webcam. I'd like to splice them together. Below is the code with information about each of the clips.
# DV Videocamera (66 frames, 2.2s)
avi=DirectShowSource("c:\avi\frontdesk\432.472.avi")
# 720x480 66F@29.97fps = 2.20secs
# Audio (Rate:48000 Length:105706 Channels:2 Bits:16)
# +AudioInt +YUV +YUY2 +FrameBased +Interleaved
# -AudioFloat -Planar -RGB -RGB24 -RGB32 -YV12 -Planar -FieldBased
avi=H==avi.height ? avi : avi.Lanczos4Resize(W, H)
c1=avi.AssumeFPS(F).ConvertToYV12().ResampleAudio(R)
# Webcam (49 frames, 1.9s)
avi=DirectShowSource("c:\avi\frontdesk\p440_081023_174343_453.avi")
# 320x240 49F@25.26fps = 1.94secs
# Audio (Rate:44100 Length:77410 Channels:2 Bits:16)
# +AudioInt +RGB +RGB24 +FrameBased +Interleaved
# -AudioFloat -Planar -RGB32 -YUV -YUY2 -YV12 -Planar -FieldBased
avi=H==avi.height ? avi : avi.Lanczos4Resize(W, H)
c2=avi.ConvertFPS(F).ConvertToYV12().ResampleAudio(R)
c1+c2
The video plays, the resizing works (that is, the webcam video resizes to WxH, the same size as the dv), the audio sounds right (I took a stab at the resampling based on advice here), BUT the video frame rate isn't right -- the webcam video plays too fast, then repeats.
I've tried ChangeFPS(), ConvertFPS(), AssumeFPS(), but nothing seems to work. I suspect this is something simple, can anyone point me to what else I should try?
Thx,
Tac
Guest
23rd October 2008, 23:20
Give the whole script. We can't see what F is.
tacman1123
24th October 2008, 09:49
Sorry, forgot that I have some globals defined in the plugins directory (these are from some scripts here, I think maybe MikeyMike's Ken Burns Effect examples):
# some globals
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
Global Resizer = "BlackmanResize"
Global Blank = BlankClip(1, W, H, pixel_type="YV12", fps=F, stereo=true, audio_rate=R).Loop(1)
Guest
24th October 2008, 13:55
Now I don't see some more missing variables, e.g., "ntsc_video".
Give the whole script in one piece!
tacman1123
24th October 2008, 14:15
"ntsc_video" is a pre-defined setting for the FPS routines:
http://avisynth.org/mediawiki/AssumeFPS
I used the preset rather than 29.97, because I believe it's more accurate and I'm trying to avoid the "FrameRates don't match" error.
I'm wondering if "Bob" and "Weave" come into play here, I see them in some sample scripts when doing conversion, but don't understand them.
Here's the full code
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
# DV Videocamera (66 frames, 2.2s)
avi=DirectShowSource("c:\avi\frontdesk\432.472.avi")
# 720x480 66F@29.97fps = 2.20secs
# Audio (Rate:48000 Length:105706 Channels:2 Bits:16)
# +AudioInt +YUV +YUY2 +FrameBased +Interleaved
# -AudioFloat -Planar -RGB -RGB24 -RGB32 -YV12 -Planar -FieldBased
avi=H==avi.height ? avi : avi.Lanczos4Resize(W, H)
c1=avi.AssumeFPS(F).ConvertToYV12().ResampleAudio(R)
# Webcam (49 frames, 1.9s)
avi=DirectShowSource("c:\avi\frontdesk\p440_081023_174343_453.avi")
# 320x240 49F@25.26fps = 1.94secs
# Audio (Rate:44100 Length:77410 Channels:2 Bits:16)
# +AudioInt +RGB +RGB24 +FrameBased +Interleaved
# -AudioFloat -Planar -RGB32 -YUV -YUY2 -YV12 -Planar -FieldBased
avi=H==avi.height ? avi : avi.Lanczos4Resize(W, H)
c2=avi.ChangeFPS("ntsc_video")
c2=c2.ConvertToYV12().ResampleAudio(R)
c1+c2
Gavino
24th October 2008, 14:16
tacman1123: Does your webcam video play OK on its own when sourced in a script by DirectShowSource? It seems to have a strange frame rate (25,26fps).
Guest
24th October 2008, 14:29
WHat's the point of this goofy line:
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
When you can use "ntsc_video" directly.
Also, try it all with AVISource rather than DirectShowSource.
tacman1123
24th October 2008, 15:35
Very odd -- the webcam clip by itself plays ok in Windows Media Player, and plays okay with AviSource(), but NOT with DirectShowSource. I thought DirectShowSource would play anything pretty much the same way you'd see it in Windows Media Player.
As for the goofy FrameRate line, I took that whole section from mikeytown2's Zoombox routines. There's a "Good Practices" thread at http://forum.doom9.org/showthread.php?p=1140113#post1140113 where it's mentioned.
My big problem with using AviSource is that often it fails, especially when I'm loading clips from my mini DV camera (specfically, AviSource doesn't load the audio, where DirectShowSource does).
I guess I could try to load the file with AviSource(), and if it didn't load audio then re-load it with DirectShowSource.
Guest
24th October 2008, 16:35
My big problem with using AviSource is that often it fails, especially when I'm loading clips from my mini DV camera (specfically, AviSource doesn't load the audio, where DirectShowSource does). Post a sample that does that, so we can get to the root cause and try to resolve it.
kemuri-_9
24th October 2008, 18:35
I've found for AVIs with AC3 audio, AVISource() will not be able to open the audio stream
I find it easiest to demux the audio out and use NicAudio() on it.
I imagine any similar audio codecs without installed ACM codecs used in the AVI container will have similar problems.
mikeytown2
27th October 2008, 07:15
@neuron2
he got the oddball line from my post here most likely
http://forum.doom9.org/showthread.php?p=1140888#post1140888
In short I did it that way so I didn't have to write 30000.0/1001.0 since ConvertFPS() only takes floats.
IanB
27th October 2008, 09:43
@mikeytown2,
RTFM! AssumeFPS, ChangeFPS and ConvertFPS all accept many forms.ConvertFPS (clip, float new_rate, int "zone", int "vbi")
ConvertFPS (clip, int numerator [, int denominator], int "zone", int "vbi")
ConvertFPS (clip1, clip2, int "zone", int "vbi")
ConvertFPS (clip, string preset, int "zone", int "vbi")
mikeytown2
27th October 2008, 10:56
went off the wiki, didn't see string so I assumed it didn't take it.
http://avisynth.org/mediawiki/ConvertFPS
tacman1123
27th October 2008, 20:46
@IanB Since the code you posted isn't in the wiki, where'd you get it from? Is there a manual to check against? Poking around, I see better documentation (at least for this call) at
http://avisynth.org.ru/docs/english/quick_ref.htm
I attempted to update the wiki to bring these into sync, but it's a template call (a little bit tricky), and it seems it takes me about 1/2 hour per change because of wiki captcha problems. I assume I'm not the only one who isn't updating the wiki because of tech issues.
mikeytown2
27th October 2008, 21:40
Manual is here most likely on your computer
C:/Program Files/AviSynth 2.5/Docs/english/index.htm
Wilbert
27th October 2008, 21:48
@IanB Since the code you posted isn't in the wiki, where'd you get it from? Is there a manual to check against? Poking around, I see better documentation (at least for this call) at
http://avisynth.org.ru/docs/english/quick_ref.htm
I attempted to update the wiki to bring these into sync, but it's a template call (a little bit tricky), and it seems it takes me about 1/2 hour per change because of wiki captcha problems. I assume I'm not the only one who isn't updating the wiki because of tech issues.
Apparently i forgot to update it. I will do this tomorrow.
IanB
28th October 2008, 23:49
What's the issue with the doco here? Everywhere I look it is correct. The lines I pasted came from the Wiki, and they are the same as the installed documentation. :confused:
mikeytown2
29th October 2008, 04:32
http://avisynth.org/mediawiki/index.php?title=FPS&action=history
IanB
29th October 2008, 09:58
went off the wiki, didn't see string so I assumed it didn't take it.
http://avisynth.org/mediawiki/ConvertFPSAnd your reference points to the correct documentation :confused:
http://avisynth.org/mediawiki/index.php?title=FPS&action=historyEven more confused, since the 2.5.7 update, the history just fixes a few typos here and there :confused: Very!
Wilbert
29th October 2008, 18:54
And your reference points to the correct documentation
I corrected it yesterday:
http://avisynth.org/mediawiki/index.php?title=FPS&diff=5541&oldid=5260
IanB
29th October 2008, 22:23
Okay I can see it now, I must have been looking just as you fixed it :o
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.