VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 15 of 15
Thread
  1. Hi,

    After googling around for hours, it seems that the VapourSynth is the latest advancement based on AviSynth. This piqued my interest;

    1.a - I would like to know, how to convert AviSynth scripts to VapourSynth ones correctly. This is what needs to be done;

    Code:
    #combine two videos together
    ffms2("E:\Game_Project\Taival\Marketing\3rd_recording01.mkv")++ffms2("E:\Game_Project\Taival\Marketing\3rd_recording02.mkv")
    #crop and addborder
    crop(0,45,0,-69)
    AddBorders(0,0,0,114)
    1.b - I would also like to know, if you can do this FFMpeg command with a VapourSynth script;

    Code:
    #remove every duplicate frame with specified similarity threshold.
    ffmpeg -i E:\3rd_recording_cropped-bordered.mkv -an -c hevc_nvenc -preset lossless -pix_fmt yuv444p -vf "select='if(gt(scene,0.01),st(1,t),lte(t-ld(1),1))',setpts=N/FRAME_RATE/TB" E:\3rd_recording_crop-bord-trim.mkv
    If these (1.a and 1.b) could be combined into one script, that would streamline everything needed in regards to initial processing of time-lapse videos.

    2. Can the latest HandBrake (1.2.0 at the time of writing) be used with this script in some way?

    Thank you for your time and effort
    Quote Quote  
  2. Member
    Join Date
    Nov 2018
    Location
    Germany
    Search PM
    I would like to know, how to convert AviSynth scripts to VapourSynth ones correctly.
    You canít just ďconvertĒ scripts to VapourSynth because VS is a completely different framework. There are equivalents for almost all functions and plugins, but you canít expect them to always behave the exact same way. Also, VS uses Python as its scripting langugage which obviously works way different than avs.

    If I understand the AVS script correctly, this should do what you want:

    Code:
    import vapoursynth as vs
    core = vs.core
    
    src = core.ffms2.Source(r"path to src1") + core.ffms2.Source("path to src2")
    src = core.resize.Point(src, format=vs.YUV444P8) # necessary because non-mod 2 resolutions obviously donít work in 420 
    cropped = core.std.Crop(src, 0, 0, 45, 69)
    withborders = core.std.AddBorders(cropped, 0, 0, 0, 114)
    withborders.set_output()

    The duplicate removal is most likely doable as well with PlaneStats/Expr and FrameEval, but that would take some more advanced scripting.

    2. Can the latest HandBrake (1.2.0 at the time of writing) be used with this script in some way?
    It cannot, as far as I know. I donít see why youíd need that though. Just use vspipe to pipe to ffmpeg or x264.
    Last edited by Lypheo; 10th Feb 2019 at 09:49. Reason: Iím dumb
    Quote Quote  
  3. VapourSynth package comes with a virtual fileserver allowing both AviSynth and VapourSynth scripts to be opened in software that otherwise don't support opening such scripts but do support uncompressed AVI - like HandBrake.
    http://www.vapoursynth.com/doc/avfs.html
    Quote Quote  
  4. Originally Posted by Lypheo View Post
    Just use vspipe to pipe to ffmpeg or x264.
    Thank you for the tip Could you instruct on how this could be done in a single script file - the above functions to combine, crop and add border to video and after that automatically launch the ffmpeg command through VSPipe?


    Originally Posted by sneaker View Post
    VapourSynth package comes with a virtual fileserver allowing both AviSynth and VapourSynth scripts to be opened in software that otherwise don't support opening such scripts but do support uncompressed AVI - like HandBrake.
    http://www.vapoursynth.com/doc/avfs.html
    Could you give me an example on how I would run the above script with AVFS? The instructions say to run the avfs.exe with the script file as an argument, but does not specify the format of the argument it needs to function.
    Quote Quote  
  5. Not sure I understand the question. Maybe it is too simple?
    Code:
    avfs "c:\script.vpy"
    or
    Code:
    avfs "c:\script.avs"
    or whatever.
    Quote Quote  
  6. Member
    Join Date
    Nov 2018
    Location
    Germany
    Search PM
    Thank you for the tip Could you instruct on how this could be done in a single script file - the above functions to combine, crop and add border to video and after that automatically launch the ffmpeg command through VSPipe?
    Ö Iím tempted to just say RTFM, but here goes.
    Save the script I wrote to some file (ending with .vpy) and run this command:
    Code:
    vspipe --y4m script.vpy - | ffmpeg -i pipe: -c:v hevc_nvenc -preset lossless -pix_fmt yuv444p -vf "select='if(gt(scene,0.01),st(1,t),lte(t-ld(1),1))',setpts=N/FRAME_RATE/TB" E:\3rd_recording_crop-bord-trim.mkv
    Quote Quote  
  7. you can crop and add borders (pad) in ffmpeg too
    Quote Quote  
  8. Originally Posted by sneaker View Post
    Not sure I understand the question. Maybe it is too simple?
    Code:
    avfs "c:\script.vpy"
    or
    Code:
    avfs "c:\script.avs"
    or whatever.
    Yup, was too simple Usually when documentation says "use as an argument" there is some front indicator to what kind of argument it is, like "-i E:\
    murderinc.mkv" or similar. Good to know, thank you for your help

    Originally Posted by Lypheo View Post
    Thank you for the tip Could you instruct on how this could be done in a single script file - the above functions to combine, crop and add border to video and after that automatically launch the ffmpeg command through VSPipe?
    Ö Iím tempted to just say RTFM, but here goes.
    Save the script I wrote to some file (ending with .vpy) and run this command:
    Code:
    vspipe --y4m script.vpy - | ffmpeg -i pipe: -c:v hevc_nvenc -preset lossless -pix_fmt yuv444p -vf "select='if(gt(scene,0.01),st(1,t),lte(t-ld(1),1))',setpts=N/FRAME_RATE/TB" E:\3rd_recording_crop-bord-trim.mkv
    Thank you for the patience, I have noticed some format differences between actual command lines and manuals, or just fixated too much on the different way the documentations have been written in, like for AVS, the wiki often uses a style of explanation that easily misleads beginners.

    For example, a AVS script documentation; "Crop(clip clip, int left, int top, int -right, int -bottom [, bool align ] )"
    The first "clip clip," is confusing, especially since to crop a video, you only need "crop(10,10,-10,-10)" in most cases.
    Luckily there was a clear example in the bottom of the wiki page, but not every manual/documentation have these.
    I checked the examples on VSPipe usage and only understood the logic of it after I watched your example. Might be because of several badly slept nights but still

    Thank you for your examples, sped up my progress tremendously
    Quote Quote  
  9. Originally Posted by poisondeathray View Post
    you can crop and add borders (pad) in ffmpeg too
    I'm currently exploring this option, thank you for the tip
    Last edited by pernicio; 10th Feb 2019 at 13:31. Reason: for not paying attention
    Quote Quote  
  10. I tried to apply the settings as instructed on the site, but I'm clearly doing something wrong. I tried many different settings, but this is the latest that doesn't work;
    Code:
    -vf "crop=w=1920:h=1080:x=45:y=69,pad=1920:1080:0:114"
    My aim is just to crop 45 pixel rows from above, and 69 pixel rows below the video and add a padding of 114 pixel to the bottom, so that the end result remains 1080p. What am I missing? Do I need to do a separate crop setting for both, bottom and top and somehow modify the padding?
    Quote Quote  
  11. crop x is on the horizontal axis, i.e. if you want to crop on left side. Not for bottom.
    Try:
    Code:
    -vf "crop=w=1920:h=(1080-45-69):x=0:y=45,pad=1920:1080:0:0"
    Note: cropping odd numbers of rows/columns on e.g. 4:2:0 video isn't easily possible. ffmpeg might round.
    Last edited by sneaker; 11th Feb 2019 at 09:02.
    Quote Quote  
  12. Originally Posted by sneaker View Post
    crop x is on the horizontal axis, i.e. if you want to crop on left side. Not for bottom.
    Try:
    Code:
    -vf "crop=w=1920:h=(1080-45-69):x=0:y=45,pad=1920:1080:0:0"
    Note: cropping odd numbers of rows/columns on e.g. 4:2:0 video isn't easily possible. ffmpeg might round.
    Nice! that worked perfectly Thank you so much. Hopefully there will be a simpler alternative to this in the future, like separation of advanced and simple cropping and padding.

    Couple of more questions about the logic of the filter arguments;

    1.a - If I ever wanted to crop from left and right side, would the argument look like this?
    Code:
    -vf "crop=w=(1920-12-3):h=1080:x=12:y=0"
    1.b - If I'd like to pad the left and/or right side of the video, what would the "pad" arguments be?
    For example, if I needed to fit a 1440x1080 4:3 video to a 1920x1080 16:9 size with 240 pixels of padding on both sides.

    2 - What would the "pad" be, if I would need to put the padding on top of the video?
    3 - Does "pad" argument work with the same logic as "crop"?

    Thank you for helping me understand the logic behind this, the width : height : x : y needs completely different kind of logic I have ever had to deal with when editing videos.
    For example, what does the "y=45" really tell the software to do in this argument, when the cropped pixels are already defined in the "h=(1080-45-69"?
    Code:
    "crop=w=1920:h=(1080-45-69):x=0:y=45"
    Quote Quote  
  13. Not much time right now, but e.g. h=(1080-45-69) does not by itself tell ffmpeg where to crop. It's just a mathematical expression that ffmpeg solves/evaluates so you don't have to calculate it manually. If you wrote h=966 the result would be exactly the same.

    Let's say your input has 1000 pixels height. h is the height of the output. y is how much ffmpeg crops from top. The rest is implicit. If I set e.g. h=700, y=100, then it's clear that 100 rows will be cropped from the top and 200 from the bottom.
    Quote Quote  
  14. Originally Posted by sneaker View Post
    Not much time right now, but e.g. h=(1080-45-69) does not by itself tell ffmpeg where to crop. It's just a mathematical expression that ffmpeg solves/evaluates so you don't have to calculate it manually. If you wrote h=966 the result would be exactly the same.

    Let's say your input has 1000 pixels height. h is the height of the output. y is how much ffmpeg crops from top. The rest is implicit. If I set e.g. h=700, y=100, then it's clear that 100 rows will be cropped from the top and 200 from the bottom.
    Makes sense, thank you for the clear explanation

    So, instead of needing to use cropping separately for top and bottom, you only need to define how much to crop form the top. The bottom is then cropped out by default in an area that is outside of the bounds of the defined pixel count (counted from top left corner of the video), which in this case is 966 pixels.

    Following this logic, the answer to my above questions would be like this;

    1.a - If I ever wanted to crop from left and right side, would the argument look like this?
    Code:
    -vf "crop=w=(1920-12-3):h=1080:x=12:y=0"
    Yes

    1.b - If I'd like to pad the left and/or right side of the video, what would the "pad" arguments be?
    Code:
    -vf "pad=1920:1080:240:0"
    This pads both sides with 240 pixels of black area and makes the video 1920x1080 (16:9), when the source video resolution is 1440x1080 (4:3).

    2 - What would the "pad" be, if I would need to put the padding on top of the video?
    Code:
    -vf "pad=1920:1080:0:114"
    3 - Does "pad" argument work with the same logic as "crop"?
    Yes

    Am I correct thus far?
    Quote Quote  



Similar Threads