60 field per second on computer with AVISYNTH - 60fps-2.AVS (0/1)

Discussion in 'Amateur Video Production' started by Andy Landfather, Aug 2, 2003.

  1. I've been working on a script for avisynth that will take video from a
    capture card (29.97 frame per second interlaced), seperate the fields
    and rearrange them into a sequence of fields at 60 fps,

    Basically it takes a sequence of frames

    A C E
    B D F

    and turns them into a sequence of fields

    A C E
    B D F

    This, in an attempt to try and mimic the field scan of a TV on the
    computer monitor. The results are interesting but there are problems.

    Number one, I have come 3/4 of the way to achieving the desired result
    but there seems to be one field that just isn't doing what it's
    supposed to, but for the other three the ruselt is achieved.

    Two, it seems like even if the effect is achieved, the result doesn't
    look the same as a TV. I have inserted lines into the script with the
    "Tweak" function in order to dim, or darken the repetitive field in
    each frame, hoping this would mimic the effect of alternate scan lines
    losing their intensity with time so that ie. in a television the odd
    field would be half it's original brightness by the time the even scan
    line is painted on screen. The value of -90 brightness almost makes
    the line dissappear but then the scene gets very dark overall and I
    can't increase the brightness of the bright field or it will
    oversaturate.

    Basically I just capture with an ATI rage fury pro with no field
    swapping, then open the script, which points to my capture file, then
    output to picvideo mjpeg and my computer is able to play the resulting
    60fps scene. And it's only a celeron 500! Any compression would
    probably work if your computer is powerful enough.

    I just thought I'd pass this along since I'm about out of ideas on it!
    Any ideas would be appreciated.

    Andy
     
    Andy Landfather, Aug 2, 2003
    #1
    1. Advertisements

  2. Here is the script pasted here for our friends on Google, hehe :)

    clip1 = AviSource("e:\CAPTURE.AVI")
    #clip1s = Swapfields(clip1)
    clip2 = SeparateFields(clip1)
    #A
    clipA = SelectEvery(clip2, 20, 0, 4, 8, 12, 16)
    #dim
    clipAd = Tweak(clipA, 0, 1, -90.0, 1)
    #B
    clipB = SelectEvery(clip2, 20, 1, 5, 9, 13, 17)
    #dim
    clipBd = Tweak(clipB, 0, 1, -90.0, 1)
    #C
    clipC = SelectEvery(clip2, 20, 2, 6, 10, 14, 18)
    #dim
    clipCd = Tweak(clipC, 0, 1, -90.0, 1)
    #D
    clipD = SelectEvery(clip2, 20, 3, 7, 11, 15, 19)
    #dim
    clipDd = Tweak(clipD, 0, 1, -90.0, 1)

    clip6 = Interleave(clipA, clipBd)
    clip6b = Weave(clip6)
    clip7 = Interleave(clipAd, clipD)
    clip7b = Weave(clip7)
    clip8 = Interleave(clipC, clipDd)
    clip8b = Weave(clip8)
    clip9 = Interleave(clipCd, clipC)
    clip9b = Weave(clip9)

    clip10 = Interleave(clip6b, clip7b, clip8b, clip9b)

    return clip10
     
    Andy Landfather, Aug 2, 2003
    #2
    1. Advertisements

  3. Ok. I have figured it out. Here is the new script. It creates the
    field sequence perfectly now. BTW I forgot to mention I open this
    script with VirtualDub.

    Andy

    clip1 = AviSource("e:\CAPTURE.AVI")
    #clip1s = Swapfields(clip1)
    clip2 = SeparateFields(clip1)
    #A
    clipA = SelectEvery(clip2, 20, 0, 4, 8, 12, 16)
    #dim
    clipAd = Tweak(clipA, 0, 1, -90.0, 1)
    #B
    clipB = SelectEvery(clip2, 20, 1, 5, 9, 13, 17)
    clipB = DeleteFrame(clipB, 0)
    #dim
    clipBd = Tweak(clipB, 0, 1, -90.0, 1)
    #C
    clipC = SelectEvery(clip2, 20, 2, 6, 10, 14, 18)
    #dim
    clipCd = Tweak(clipC, 0, 1, -90.0, 1)
    #D
    clipD = SelectEvery(clip2, 20, 3, 7, 11, 15, 19)
    #dim
    clipDd = Tweak(clipD, 0, 1, -90.0, 1)

    clip6 = Interleave(clipA, clipBd)
    clip6b = Weave(clip6)
    clip7 = Interleave(clipAd, clipD)
    clip7b = Weave(clip7)
    clip8 = Interleave(clipC, clipDd)
    clip8b = Weave(clip8)
    clip9 = Interleave(clipCd, clipB)
    clip9b = Weave(clip9)

    #A C
    #B D

    #A Ad C Cd
    #Bd D Dd B

    clip10 = Interleave(clip6b, clip7b, clip8b, clip9b)

    return clip10
     
    Andy Landfather, Aug 3, 2003
    #3
  4. So one more time. I found a little glitch with the 4th framem and
    fixed it, Here's the working script,

    clip1 = AviSource("e:\CAPTURE.AVI")
    #clip1s = Swapfields(clip1)
    clip2 = SeparateFields(clip1)
    #A
    clipA = SelectEvery(clip2, 20, 0, 4, 8, 12, 16)
    #dim
    clipAd = Tweak(clipA, 0, 1, -90.0, 1)
    #B
    clipB = SelectEvery(clip2, 20, 1, 5, 9, 13, 17)
    #dim
    clipBd = Tweak(clipB, 0, 1, -90.0, 1)
    clipB = DeleteFrame(clipB, 0)

    #C
    clipC = SelectEvery(clip2, 20, 2, 6, 10, 14, 18)
    #dim
    clipCd = Tweak(clipC, 0, 1, -90.0, 1)
    #D
    clipD = SelectEvery(clip2, 20, 3, 7, 11, 15, 19)
    #dim
    clipDd = Tweak(clipD, 0, 1, -90.0, 1)

    clip6 = Interleave(clipA, clipBd)
    clip6b = Weave(clip6)
    clip7 = Interleave(clipAd, clipD)
    clip7b = Weave(clip7)
    clip8 = Interleave(clipC, clipDd)
    clip8b = Weave(clip8)
    clip9 = Interleave(clipCd, clipB)
    clip9b = Weave(clip9)

    #A C
    #B D

    #A Ad C Cd
    #Bd D Dd B

    clip10 = Interleave(clip6b, clip7b, clip8b, clip9b)

    return clip10
     
    Andy Landfather, Aug 3, 2003
    #4
  5. Andy Landfather

    - Guest


    Won't the perceived behaviour of this depend on the vertical refresh
    rate of the video card and monitor?

    For example if you have say a 70Hz refresh rate and are able to pump
    60 pics a second to the secreen then some of these are going to appear
    twice. There might even be a strobe/brightness effects if the pics are
    not updated at each vertical retrace.

    I have heard that some PC-based DVD playind software does soemthing
    like this and that it performs better if you set your montitor refresh
    rate to a multiple of the field rate. But I have never seen any
    documented proof of this.
     
    -, Aug 5, 2003
    #5
  6. I don't know a whole lot about the technicalities of TV or monitors
    unfortunately. But one way I have thought of it is: if I set my
    monitor refresh to 120 hz, that is so fast that it seems like the
    phosphor dots would have little time for their intensity to
    decay...that is if they have similar charachteristics as those in a
    TV. So if that were true, you could almost consider the screen of a
    monitor continuously painted. I dunno. But certainly at 120 hz the
    30hz refresh of a single field in ntsc is much much less.

    Still I see combing but I don't on a TV!?

    Using this filter and setting different values of intensity for the
    repeated field to mimic the decay in intensity of a field, I find that
    a value of -60 works good in the Tweak command. But less decay than
    that...the picture shows combing in some scenes and looks a little
    more blurred. More decay than that and the picture looks dark and you
    can definately see the "missing" scanlines.

    Just wierd...that you don't see combing on a tv...and it would seem if
    you truly reproduced the effect of tv on a monitor, you shouldn't see
    it there either?
     
    Andy Landfather, Aug 6, 2003
    #6
  7. Andy Landfather

    FLY135 Guest

    One other thought on this subject is that the decay characteristics on a TV
    probably are not linear. So that would mean that darker portions of the
    image would decay at a different rate than brighter areas. So it would be
    difficult or impossible to pick any particular fixed amount of intensity
    reduction to match a TV image. However I like your idea.
     
    FLY135, Aug 6, 2003
    #7
  8. Andy Landfather

    Samuel Paik Guest

    Why not just use SeparateFields followed by the Bob command?
     
    Samuel Paik, Aug 7, 2003
    #8
  9. Well, that would result in

    ABCDEF
    ABCDEF

    Where for instance field A has been interpolated up to twice it's
    height. So then a "copy" of field B is painted in the next frame,
    where the decaying field A should be.
     
    Andy Landfather, Aug 7, 2003
    #9
  10. Thanks, that's interesting. BUT! hehe :) the effect could be
    duplicated it seems to me in theory. I have seperated each field into
    a frame sequence so they can all be operated on seperately.

    If the relationship of decay vs intensity that you speak of can be
    approximated, then a filter could be implemented that creates the
    "decaying" fields with a more accurate method than simply reducing the
    brightness to 1/2!

    You see? A filter that reduces each pixels intensity by some function
    of it's original brightness! ...not saying it's possible with the
    tools we have now...but still it is possible.
     
    Andy Landfather, Aug 7, 2003
    #10
  11. There was only one dvd player that I have ever saw that tried to show
    fielded video...it was called "sthsvcd" but the overall quality of
    it's decoding looked terrible. Maybe because of my Celeron-500.
    I've wondered this too about my ATI rage fury pro, it looks smooth but
    still I think the picture is sharper when the capture is opened in
    Virtualdub. I'm still not 100% certain whether it's deinterlaced or
    real fields, wish there was a test for this. Possibly a digital
    camera!? If you set the shutter speed to 1/60 sec surely the fields
    would be detectable?
     
    Andy Landfather, Aug 7, 2003
    #11
  12. Very interesting! Maybe then if there were a Vdub blur filter with a
    radius of 1/4 pixel!?
    Same here. Thing is though, you can use AVISYNTH scripts on playback
    too! So in theory this filter could be applied on playback of any
    interlaced frame source! But the computer power required??? Hmm.
     
    Andy Landfather, Aug 7, 2003
    #12
  13. Andy Landfather

    FLY135 Guest

    Of course I see. That's the reason that I suggested it. My guess is that
    low intensity phosphers would decay at a slower rate than bright phosphers.
    So if you graphed brightness (Y axis) vs. decay rate (X axis) it would look
    like a rising exponential curve.
     
    FLY135, Aug 7, 2003
    #13
  14. Andy Landfather

    Samuel Paik Guest

    Decaying? Ah, how long do you think the persistence of television
    monitor phosphors is? Hint: it is very short.
     
    Samuel Paik, Aug 7, 2003
    #14
  15. Andy Landfather

    FLY135 Guest


    I have a better idea. Why don't you just give us the specifics.
     
    FLY135, Aug 7, 2003
    #15
  16. Andy Landfather

    Samuel Paik Guest

    I don't have the relevent standards on hand (and even then, most
    TVs don't use the standard NTSC phosphors), but for essentially
    all TVs, the phosphors should decay to under 10% in much less
    than one field time.

    Try taking a picture of your TV with an exposure of 1/100th of a
    second or less. You'll get some part of the screen bright--which
    is the area actually scanned by the beam during the exposure--a
    ramp from bright to dark, and the rest dark. The ramp can be used
    for a quick and dirty estimate of the persistence--I just did this
    and I'd guesstimate the ramp at between 1/4 and 1/8 the screen height,
    so say 2-4 mSec.

    In other words, the OP is basically barking up the wrong tree for
    simulating a "TV" effect on a progressive monitor.

    Sam
     
    Samuel Paik, Aug 8, 2003
    #16
  17. Andy Landfather

    - Guest

    Or perhaps a camcorder. It would obviously capture the separate fields
    (if they existed). Then feed the camcorder capture into AVISYNTH and
    do a separatefields.
    Choose a section with fast movement and see if all adjacent fields are
    different. This might be difficult in practice as the camcorder and
    monitor would not be synced together - it might be easier if you set
    the monotor's vertical rate to 60Hz (for NTSC).
     
    -, Aug 8, 2003
    #17
  18. Andy Landfather

    - Guest

    But let's not also forget that main reason you see combing is that on
    a PC monitor you have two instants in time 1/60th of a second apart
    being shown at the *same* instant and frozen for 1/30th of a second.
    While on TV you are seeing the "instants" at the correct instant and
    for 1/60th of a second.

    The images on the PC therefore contain a sort of temporal scrambling
    which is made the more obvious because each image is displayed for
    1/30th of a second.
     
    -, Aug 8, 2003
    #18
  19. Then there is the question of the persistence of the eye. If the
    pictuer appears fully illuminated then the persistence of the eye must
    be much greater than 4 or 8 times 1/60 second...or 1/15 second to
    1/7.5 second.

    But that cannot be true because if you process a file with my script
    using a -90 value for the "decay" of the repeating field, the "blank"
    line is very obvious.

    Nevertheless, if the persistence of the phosphors in the tv is as your
    camera test shows, then the even field should be completely GONE by
    the time the odd one gets there. Correct?

    Then I would suspect the "blurring" or oversized electron beam that
    was mentioned above.

    This would only require a small blur to get rid of the "blank line"
    effect. I'd hate to have to save an image sequence and process them in
    photoshop just to test this, but I don't know of any blur filters for
    Virtualdub with a 1/4 pixel blur radius.
     
    Andy Landfather, Aug 8, 2003
    #19
  20. Also it would have to be a blur in the vertical direction only...to
    not smear any of the horizontal resolution.
     
    Andy Landfather, Aug 8, 2003
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.