I have been recording the same event from two different DV Camcorders, capturing to either DV AVI intelaced, or WMV interlaced files (depending on how I felt about quality vs hard drive space on each given day.)
So, I end up with two videos, each starting at two slightly different points in time showing the same thing.
Manually, I can find the field (half-frame) in stream A that matches the same point in time in stream B. For that I use VirtualDub with bob doubler internal plugin.
So, for instance, frame 4.5 (i.e., 4th (interlaced) frame, top field) in stream A is matched with frame 300 (i.e., 300th frame, bottom field) in stream B. So, the "difference" here is 295.5 frames.
Now, I'd like to see both views next to each other in VirtualDub.
For that, I have been struggling to figure out the following AviSynth script.
-It should open both video files.
-It should be able to reference the fields, rather than the frames (same thing that bob doubler does in VirtualDub).
-It should offset one video by the "frame difference" (see above), so that if it needs to display frame 300 in my stream B, it knows to display frame 300-295.5 (=4.5) in my stream A (and obviously, black frames in stream A, if I display anything less than 295.5 in stream B).
-It should resize the frames, since my capture is standard 720x480, but in one case AR is 4:3 and in another 16:9, to square pixels of my choosing (I'd like to play with different sizes - I just want the aspect ratio to be right).
-Finally, it should display the two videos side by side. (Oh, and the audio, I only need to hear it from one of the video files).
So far my attempts have been pathetic.
Even this simple thing doesn't work all the way - I don't get any audio:
Code:stream_a = AVISource("C:\RAW_DATA\Media\stream_A1.avi", audio=True).BilinearResize(720, 540, 8, 0, 720, 480) stream_b = AVISource("C:\RAW_DATA\Media\stream_B1.avi").BilinearResize(960, 540, 8, 0, 720, 480) StackHorizontal(stream_a, stream_b)
Apprectiate any help, tx.
+ Reply to Thread
Results 1 to 20 of 20
-
-
The reason you get no audio is that AviSource does not handle audio in a Type 1 DV file.
Use Type 2 DV, or use DirectShowSource to read Type 1.
Also, I think BilinearResize(..., 720, 480) should be (..., 704, 480).
For your other requirements, you need to bob-deinterlace (eg with Yadif(mode=1, order=0)) to get 59.94fps progressive, then each original field becomes a separate frame and you can line them up exactly by adding blank frames at the start of the 'later' clip.
For your example, after deinterlacing:
A = BlankClip(A, 591) + A # 591 = 2 x 295.5Last edited by Gavino; 11th Nov 2010 at 03:51. Reason: mention Yadif
-
Thanks, Gavino.
But I must have entered "thick zone".
I have C:\Program Files\AviSynth 2.5\plugins\yadif.dll (downloaded from http://avisynth.org.ru/yadif/yadif.html)
I have this line in my script:
Code:stream_a = DirectShowSource("stream1A.avi", audio=True).BilinearResize(640, 480, 8, 0, 720, 480).Yadif(mode=1, order=0)
---------------------------
VirtualDub Error
---------------------------
Avisynth open failure:
Script error: there is no function named "Yadif"
(C:\RAW_DATA\Media\test.avs, line 1)
---------------------------
OK
---------------------------
Also, regarding 704,480, I did see that too, somewhere. But I didn't understand: I thought 720x480 = 4:3 or 16:9.
Well, according to this https://forum.videohelp.com/threads/269644-DV-to-704x480-or-720x480, no. It's actually 704x480 with padding of 8 pixels on either side (that gets cut off by most TVs).
Therefore, what my DV Camcorder actually gives me with its 720x480 is ... lets see...4.0909 : 3, yes?
I 'd prefer not to cut anything off, of course. -
yadif is a different type of filter that has to be manually loaded . It's a "C" plugin
Load_Stdcall_Plugin("C:\PATH\yadif.dll") -
He was talking about this part of the script:
BilinearResize(640, 480, 8, 0, 720, 480)
If you don't want to cut anything off, then that part of the script is incorrect. He was figuring you had 8 columns of pixels on each side to be removed and, if so, the line should be:
BilinearResize(640, 480, 8, 0, 704, 480)
And even if there aren't 8 columns of black pixels on each side, to keep a proper aspect ratio it should still be cropped like that. And if it's really active video that you don't want cropped, then you wouldn't resize to 640x480 but maybe 656x480. -
Ah.. thanks.
Well, almost seem to be there. Except, after adding this Yadif call I can no longer view my video in VirtualDub while its active. I just get green instead of the video. As soon as I Alt-Tab to a different application (like notepad with my .avs script), I can see that behind it the video re-appears and shows normally in VirtualDub, but as soon as I activate VirtualDub (bring it to the front) it turns back to green - what gives? -
@manono
Yeah. Well, technically speaking 640 should become 654.5455, but because it's not exactly "divisible by 4", 656 seems like a good number. -
And correct: my DV camcorder doesn't give me any "vertical black bars" on the sides - it's useful image everywhere
-
Ok, I just confirmed that Yadif has nothing to do with it - it happens without that call also.
Your suggestion to disable direct x did the trick - thanks.
While I have this thread going - how do I also delay my out-of-sync audio (this is for files captured through WMEncoder, where the audio stream was from my external sound card, not DV Camcorder)? -
Ok, great. Am I correct to make the .AudioDelay call inline with StackHorizontal?
-
Yes, that's one way to do it, eg
StackHorizontal(stream_a, stream_b).DelayAudio(0.5)
You could also attach it to the input clip filter chain instead, eg
stream_a = AviSource(...). ... .DelayAudio(0.5)
Or just add a separate line at the end
DelayAudio(0.5)
All have the same final result. -
Sounds good.
In the interest of polishing this further, is there anything out there that's more "lightweight" than Yadif (which, I think, does some serious frame comparisons when it operates)?
With it, my CPU usage climbs to 100% when I try playing back my synced videos and so it's not a smooth experience.
All I need is to separate my fields BFF - very predictable. -
Actually, Yadif is fairly fast - the top-quality deinterlacers are many times slower.
You could also try LeakKernelDeint(), or even the built-in Bob().
BTW It is not simply separating the fields - it also has to interpolate the missing lines - otherwise you would get a half-height image that bobs up and down on each new frame. -
Ok, thanks for letting me know. My solution to smooth playback problem: set virtualdub to process every other frame (Video->Frame Rate). That way, when I hit Enter to playback, it doesn't show every frame, but that's ok. I don't need 59.94 fps. Then when I want to study the motion frame by frame I can stop and use my arrows/mouse wheel and get to see every frame.
Thanks for all the help.
I have more related questions which I will ask in different threads. -
You can also use 'trim' to sync up the two sources by cutting short the longer source. Or if you want to add frames to the shorter source, I find it easier to use stream_a=stream_a.trim(0,-1).loop(f) to make copies of the first frame rather than messing with blankclip.
Darryl
(correction after reading Gavino's reply)
stream_a=stream_a.trim(0,-1).loop(f)+stream_aLast edited by dphirschler; 12th Nov 2010 at 12:47.
-
Yes, that's a useful alternative. But you would still have to add the extra frames in with the '+' operator:
stream_a=stream_a.trim(0,-1).loop(f) + stream_a
Simpler is to use the Loop function like this:
stream_a = stream_a.Loop(f+1, 0, 0)
which adds f copies of the first frame. -
Yes, that looks real good. My main point was that blankclip is a pain for me because I almost always have trouble joining the blankclip with the video. Anything can cause incompatibility - frame rate, size, colorspace, audio properties. That's why I like 'loop' better.
Darryl -
Similar Threads
-
How to display .png just for (exam 3 seconds or 100 frames) with Avisynth?
By xicudiz in forum EditingReplies: 2Last Post: 9th Apr 2011, 21:41 -
AviSynth - Add specific Chapters timecodes to your script
By imager in forum EditingReplies: 2Last Post: 26th Dec 2009, 07:25 -
How to display variable values 4 debuggin in Avisynth
By lindylex in forum ProgrammingReplies: 15Last Post: 6th Dec 2009, 09:36 -
Specific video card requirements for HD playback?
By GLE3 in forum Newbie / General discussionsReplies: 17Last Post: 1st Apr 2009, 12:12 -
MT2S files play video in MPC but no sound+Ultra Cyberdvd wont display video
By btvs2000 in forum Software PlayingReplies: 7Last Post: 22nd Sep 2008, 15:44