VideoHelp Forum




+ Reply to Thread
Results 1 to 6 of 6
  1. Member
    Join Date
    Jan 2009
    Location
    Macomb, (West Central) Illinois, USA
    Search Comp PM
    To make it simple, here is what I'm trying to do. I have videos that look like this:

    Name:  sonic1.png
Views: 669
Size:  35.1 KB


    And I would like the videos to look like this in the end:

    Click image for larger version

Name:	sonic1-sep.png
Views:	598
Size:	53.8 KB
ID:	7205

    I don't want the image's horizontal resolution to change, nor do I want the vertical resolutions of the top and bottom to change either. I simply want to be able to insert black in the middle and push the top and bottom apart. Of course, I would also letterbox this end result so that the final resolution is more normal.

    I looked in VirtualDub and the closest thing I could find would be the logo filter...

    Name:  logofilter.png
Views: 655
Size:  26.7 KB

    But that clearly overwrites the image. I really couldn't find any setting that would allow the image to be pushed apart.

    I really don't think this would be difficult to program (simply push apart the image by 84 pixels like I did in Paint), so, would it be possible to create an Avisynth script that would do this?

    I've never ran Avisynth before (I prefer GUI, like VirtualDub, Avidemux, etc.), but I would be willing to learn how to use Avisynth if I could achieve what I described above.

    Or, is there another way to achieve this? (VirtualDub filter, etc.) If necessary, I suppose I could save the top and bottom segments as separate videos if required.

    Anyway, I would appreciate any help given. Thanks!
    Quote Quote  
  2. yes you can do it in avisynth fairly easily , or any NLE like vegas, premiere etc..

    I'm assuming you don't want that white edge on the bottom of the middle black portion?

    An example how to do this

    Code:
    a=AVISource("video.avi")
     
    a.crop(0,192,0,0,true)
    bottom=last
     
    a.crop(0,0,0,-192,true)
    top=last
     
    middle=blankclip(a,height=84)
     
    stackvertical(top, middle, bottom)


    http://avisynth.org/mediawiki/Main_Page#New_to_AviSynth_-_start_here




    Of course, I would also letterbox this end result so that the final resolution is more normal.
    This is fairly easy to do as well, but you have to provide more info on the desired output format. Is this for DVD? internet? (square pixel output?)
    Last edited by poisondeathray; 5th Jun 2011 at 10:21.
    Quote Quote  
  3. Member
    Join Date
    Jan 2009
    Location
    Macomb, (West Central) Illinois, USA
    Search Comp PM
    First, I have to say sorry for the untimely response. Second, I have to say thank you for the info! I read up on how to use Avisynth and tried your code. I saved it in an .avs file and opened it up in VirtualDub. It worked like a charm.

    No, I don't want that white edge on the bottom of the black portion. VirtualDub's logo filter added that in for some reason, but it's a moot point now.

    The video is being prepared to be joined with other video clips, which are in a 16:9 format. So, I increased the size of the video and then letterboxed it that way (16:9) so the video isn't a goofy 256 x 468 and can be joined with the other clips. I uploaded the experimental letterboxed result to YouTube. I saved it in 720p, though in the future this won't be necessary. (I'll save as 854 x 480 instead since none of my clips are HD.)



    Looks good to me. Thanks again for your help.

    As far as learning more about Avisynth and what you did with this script...

    First, you set the video as "a" so it can easily be referenced in the rest of the script.

    I couldn't find where it discusses crop on the Avisynth Wiki, but I found this page. So then, the crop function crops pixels off (left edge, top edge, right edge, bottom edge). From what I gather from this function, the measurements of the video can be thought of in Cartesian coordinates (x,y) and what Avisynth does is move the edge of the video Z number of pixels along the x-axis and y-axis, except that the y-axis is backwards. So then, the right and bottom edges should always be negative. Or am I making this too complicated? I suppose that if the sign was wrong on one of the variables, then the video frame would be extended by a certain number of black pixels instead?

    Adding "true" to the variables allows the video to be processed faster, from what I gather? I don't really follow what was discussed because I am not familiar with byte alignment, etc.

    In v2.53 an option align (false by default) is added:
    Cropping an YUY2/RGB32 image is always mod4 (four bytes). However, when reading x bytes (an int), it is faster when the read is aligned to a modx placement in memory. MMX/SSE likes 8-byte alignment and SSE2 likes 16-byte alignment. If the data is NOT aligned, each read/write operation will be delayed at least 4 cycles. So images are always aligned to mod16 when they are created by AviSynth.
    If an image has been cropped, they will sometimes be placed unaligned in memory - "align = true" will copy the entire frame from the unaligned memory placement to an aligned one. So if the penalty of the following filter is larger than the penalty of a complete image copy, using "align=true" will be faster. Especially when it is followed by smoothers.
    Anyway, the first time the video was cropped in the script, it took off the top and the second time took off the bottom. Then you generated the middle black portion with a specific height and stacked them. This makes sense. But the "bottom=last" and "top=last"... Is "last" the last video that had been generated within the script?
    Quote Quote  
  4. Originally Posted by sincostan45 View Post
    First, you set the video as "a" so it can easily be referenced in the rest of the script.
    Yes you can use any variable . You could have called it "original", or "main", or "z"

    There's probably more efficient ways to write code, but I like breaking it out and keeping things simple


    I couldn't find where it discusses crop on the Avisynth Wiki, but I found this page. So then, the crop function crops pixels off (left edge, top edge, right edge, bottom edge). From what I gather from this function, the measurements of the video can be thought of in Cartesian coordinates (x,y) and what Avisynth does is move the edge of the video Z number of pixels along the x-axis and y-axis, except that the y-axis is backwards. So then, the right and bottom edges should always be negative. Or am I making this too complicated? I suppose that if the sign was wrong on one of the variables, then the video frame would be extended by a certain number of black pixels instead?
    crop takes the arguments (left, top, -right, -bottom)
    http://avisynth.org/mediawiki/Crop

    The right and bottom are always prefaced with negative


    Adding "true" to the variables allows the video to be processed faster, from what I gather? I don't really follow what was discussed because I am not familiar with byte alignment, etc.

    In v2.53 an option align (false by default) is added:
    Cropping an YUY2/RGB32 image is always mod4 (four bytes). However, when reading x bytes (an int), it is faster when the read is aligned to a modx placement in memory. MMX/SSE likes 8-byte alignment and SSE2 likes 16-byte alignment. If the data is NOT aligned, each read/write operation will be delayed at least 4 cycles. So images are always aligned to mod16 when they are created by AviSynth.
    If an image has been cropped, they will sometimes be placed unaligned in memory - "align = true" will copy the entire frame from the unaligned memory placement to an aligned one. So if the penalty of the following filter is larger than the penalty of a complete image copy, using "align=true" will be faster. Especially when it is followed by smoothers.
    Anyway, the first time the video was cropped in the script, it took off the top and the second time took off the bottom. Then you generated the middle black portion with a specific height and stacked them. This makes sense. But the "bottom=last" and "top=last"... Is "last" the last video that had been generated within the script?
    yes, it's not necessary, but might be marginally faster in some circumstances. I just leave it in because it won't hurt and may help



    A very good tool to use is AvspMod. You can preview scripts (hit f5), compare scripts in multiple tabs using number keys, use macros , sliders

    Just curious - Why is the video formatted like that in the first place?
    Quote Quote  
  5. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by sincostan45 View Post
    So then, the crop function crops pixels off (left edge, top edge, right edge, bottom edge). From what I gather from this function, the measurements of the video can be thought of in Cartesian coordinates (x,y) and what Avisynth does is move the edge of the video Z number of pixels along the x-axis and y-axis, except that the y-axis is backwards. So then, the right and bottom edges should always be negative. Or am I making this too complicated? I suppose that if the sign was wrong on one of the variables, then the video frame would be extended by a certain number of black pixels instead?
    There are two different ways to supply the parameters to Crop(), described in http://avisynth.org/mediawiki/Crop as
    Crop(clip clip, int left, int top, int width, int height, bool align)
    and
    Crop(clip clip, int left, int top, int -right, int -bottom, bool align)

    A positive value for the fourth and fifth parameters is taken as the desired width or height of the result.
    A negative (or zero) value is taken as the amount to be cropped off the right or bottom of the original.
    You can use either form (even mixing one style for width/right and the other for height/bottom), whichever is more convenient for the job in hand - pdr's script uses the second form.

    But the "bottom=last" and "top=last"... Is "last" the last video that had been generated within the script?
    If the result of a filter operation is not explicitly assigned to a variable, it will be saved by Avisynth in the special variable called 'last'. The value of this variable is also used as the default input clip to all filters(*).

    Another way of writing pdr's script could be:
    Code:
    AVISource("video.avi")
    bottom = crop(0,192,0,0,true)
    top = crop(0,0,0,-192,true)
    middle=blankclip(last,height=84)
    stackvertical(top, middle, bottom)
    (*)BlankClip is a special case since it also has a variant without a clip parameter. So here 'last' must be specified explicitly.
    Quote Quote  
  6. Member
    Join Date
    Jan 2009
    Location
    Macomb, (West Central) Illinois, USA
    Search Comp PM
    Awesome, thanks for explanations guys! This makes more sense than when I was trying to figure it out on my own. You know, this information you guys posted might be helpful to a lot of people. Why not add it to the Avisynth Wiki article?

    And AvspMod looks like a very nice tool, I'll check it out.

    Originally Posted by poisondeathray View Post
    Just curious - Why is the video formatted like that in the first place?
    This video comes from a Nintendo DS emulator. I work with video game footage for my video projects and I use emulators to record the footage. This is what a game looks like on a Nintendo DS:

    Click image for larger version

Name:	ds.png
Views:	297
Size:	637.9 KB
ID:	7312
    (Sorry for the bad picture.)

    In some games, what goes on in the game goes behind the middle part where there is no screen. Here, you can see that the top of the loop is cut off at the top of the bottom screen. It's there "in game", but not on either screen.

    Anyway, the .avis the emulator produces have the screens directly stacked on top of one another. In games like the one above, it makes the game look strange since there is supposed to be empty space between the screens. (See the screenshot at the top of this post.)

    By splitting apart the screens and putting black between them, it makes the video footage look like how it looks on a Nintendo DS, like in the YouTube video I embedded.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!