1. Akiba-Online is sponsored by FileJoker.

    FileJoker is a required filehost for all new posts and content replies in the Direct Downloads subforums.

    Failure to include FileJoker links for Direct Download posts will result in deletion of your posts or worse.

    For more information see
    this thread.
    Dismiss Notice

Mostly automatic encoding/preparing for posting process

Discussion in 'Tutorials' started by SamKook, Jun 27, 2012.

  1. Kevin_san

    Kevin_san New Member

    Ok I wasn't here for weeks,
    at first I'd like to share 3 more kernels:
    C40i ="3 -9 25 -25 130 0 0 2 -4 -25 0 0 -5 5 25 0 0 0 -1 -7 0 0 0 0 3"
    C40k ="3 -10 23 -28 123 0 0 2 -4 -25 0 0 -5 5 25 0 0 0 -1 -7 0 0 0 0 3"
    C40k1="3 -10 25 -28 132 0 0 2 -4 -27 0 0 -5 5 23 0 0 0 -1 -7 0 0 0 0 3"

    There are diagonal coefficients now that make the pixel "rounder" and everything looks more natural and smooth.
    Especially the last turns out very versatile, probably good for a default setting.
    It sharpens a bit, reduces halo a bit, and makes many yadif'd videos quite nice looking, more like classic TV with only minimal bobbing. But it needs the postprocessing with the upsampling to reach full quality.
    Many encodes look better than the original MPEG2, at least in the VLC player.

    About the QTGMC, I agree it should be recommended, but also I think a tuned process that integrates the convolution in place of one of the complex sharpeners inside QTGMC, might improve the quality of the result a lot, also in that it does not "equalize" sharpness over the whole area. What I saw is that videos end up almost as sharp in every corner, when the original deliberately (by the camera artist) kept only the center or focus sharp, like the face of a girl. What the complex sharpeners do though, is improve the artifact situation with those poorly encoded (overloaded) originals.

    I think yadif does some pseudo-interpolate, in that it can detect _some_ edges and smooth them out over the doubled lines.
     
  2. iConsume

    iConsume Active Member

    SK,

    i'm on a mac so most of these tips i don't believe would apply. i don't think many, if any, of the gui apps available on this platform offer the kind of customization you recommend.

    but i do have a question: if you had only a standard DVD as source material, what would your recommendation be as far as expectations of the highest possible resolution? anything beyond regular DVD dimensions? reason i ask is because some of your old Rui Saotome rips, I don't think they were available in HD or FHD at the time you encoded them (I might be wrong) but your shares were super clear and with beautiful resolution. maybe even high resolution.
     
  3. Kevin_san

    Kevin_san New Member

    I switched to the new AviDemux 2.6.18 BTW, it is faster (good multithreading) and has a few new options, e.g. x265. The x264 parameter set has changed, when we load an old script file, not everything is right.
     
  4. Kevin_san

    Kevin_san New Member

    if avisynth works on a mac, then any customization is possible. QTGMC is just a script, that manages a number of object files that hold the actual filter code.
    QTGMC does so much of search, interpolation, and AI pattern replacement, that the outcome is practically a different product with increased resolution and smoothness that looks very sharp at the same time.
    but you can't beat shannon. just that the original often is practically worse than 720x480. so within that frame the process can restore quite a lot but it cannot generate data to fill a physically higher resolution with something meaningful.
    what we see is that many players just perform better, when the input is upsampled. the point is the filtering and resizing from 480 lines to the actual screen of the user. the slow filtering in the upsampling is such that the pixel absolutely disappears, while most players will show still some "stairs" at sharp edges or letter fonts, when fed with that format.
     
  5. SamKook

    SamKook Akiba Citizen Uploader

    I personally prefer to leave the resolution unchanged so all my mkv encodes are at DVD resolution(720x480, unless I crop a few pixels to remove black bars) which I use as a source instead of the digital versions most people use nowadays and I just fix the aspect ratio inside the stream(has better compatibility than if you do it in the container) to make it 853x480 if 16:9 or 640x480 if 4:3.

    I use a video renderer(madvr) with my player that allows me to do complex resizing and filtering in real time so that gives the best result for me since I have a decently powerful PC to play them.


    If you play them on a slow pc, you may want to look into upsampling(making the resolution higher when encoding) like kevin_san suggests, but that's not something I've done in any of my encodes.

    QTGMC and slow encoding settings are what help making the picture clear.

    My scripts are windows only(and what's posted is an outdated version) but I'm pretty sure there's a way to make avisynth works with wine so you could use it for encoding on a mac, but you'd have to do a bit of research to make that work.
     
  6. SamKook

    SamKook Akiba Citizen Uploader

    I've been meaning to take a look at a recent version of x265 since I've seen a few nice looking encodes with pretty small sizes, but I've barely done anything encoding or akiba related lately.
     
  7. Kevin_san

    Kevin_san New Member

    for those who encode on their own..
    another example that (somewhat) corrects a black halo above a bright horizontal object.
    some older videos are notorious for this. improvement is great though.
    it takes some sensitive tuning else the result would look blurred in one direction.


    Code:
    #LoadPlugin("F:\programs\AviSynth+\plugins+\dgdecode58.dll")
    MPEG2Source ("E:\fun\wrk\1\MyDVD.d2v",cpu=0,info=2)
    
    #------ these are kernels for the "bad after-interlace sharpening" fault:
    C60 =  "0 -0   0  0 112    0  0 -0 -0 -5   0  0  -0  -0  30    0  0  0 0 -3   0  0  0  0  8" #C
    C61 =  "0 -0   0  0 112    0  0 -0 -0 -6   0  0  -0  -0  10    0  0  0 0 -3   0  0  0  0  0" #C
    C62 =  "0 -0   0  0   0    0  0  0 -0  0   0  0 112   0   0    0  0 25 0 -0   0  0  0  0  0" #C
    C63 =  "0 -0   0  0   0    0  0  0 -0  0   0  0 113   0   0    0  0 19 0 -0   0  0  0  0  0" #C
    C64 =  "0 -0   3  0   0    0  0  8  0  0   0  0 140   0   0    0  0 15 0 -0   0  0  3  0  0" #C
    C65 =  "0 -0  15  0   0    0  0 27  0  0   0  0 141   0   0    0  0 37 0 -0   0  0 27  0  0" #C
    
    #-- basically we undo the vertical sharpen on the fields, and redo it after deinterlacing
    #   coefficient #18 is the intensity, for the simple, asymmetric case
    #   it deals with the black halo at the upper edge of a bright rectangular object on dark background
    CC=last
    ConvertToRGB32(matrix="PC.709",interlaced=true,chromaresample="lanczos4")
    SeparateFields
    GeneralConvolution(0, C63) ### select kernel to use, specify its variable name here
    Weave
    ConvertToYV12(matrix="PC.709",interlaced=true,chromaresample="lanczos4")
    MergeChroma(CC) # we assume that chroma is not concerned so we put back the original
    #---------
    
    
    #-- Deinterlace Yadif -- delete this, when source is not actually interlaced i.e. shows combing without
    #Load_Stdcall_plugin("F:\programs\AviSynth+\plugins\yadif.dll")
    Yadif(mode=1,order=1)
    
    AssumeFPS(60000,1001)
    
    # -----
    global rff=60000./1001. # for resulting 60fps
    
    #--- show some still pictures: (correct the audio intro length for this!)
    tpos=0.0*60.+0.000    # pics start time = minutes*60 + ss.ddd #(seconds)
    fpos=int(tpos*rff)    # if we do it by frame number
    tsl=int(1.0*rff/2.)+1 # duration of one pic
    n=fpos+0 #sometimes add 1
    
    /*
    #--- the following is a particular example to cut together DVD intro, slide show, and movie in a controlled manner
    vv=last
    intro = cut(vv,0,0., 1,06.548-6.5+26./rff) # -13 pics * 0.5s + 26 fields
    pics  = cut(vv,1,06.565, 1,06.999) 
    movie = cut(vv,1,06.999, 98,21.819)
    
    pics = Loop(pics,tsl,n+26,n+27)
    pics = Loop(pics,tsl,n+24,n+25)
    pics = Loop(pics,tsl,n+22,n+23)
    pics = Loop(pics,tsl,n+20,n+21)
    pics = Loop(pics,tsl,n+18,n+19)
    pics = Loop(pics,tsl,n+16,n+17)
    pics = Loop(pics,tsl,n+14,n+15)
    pics = Loop(pics,tsl,n+12,n+13)
    pics = Loop(pics,tsl,n+10,n+11)
    pics = Loop(pics,tsl,n+8,n+9)
    pics = Loop(pics,tsl,n+6,n+7)
    pics = Loop(pics,tsl,n+4,n+5)
    pics = Loop(pics,tsl,n+2,n+3)
    pics = Loop(pics,tsl,n+0,n+1)
    #
    last = intro + pics + movie
    */
    
    
    AddBorders(4,4,4,8,$7F7F7F)
    ConvertToRGB32(matrix="PC.709",interlaced=false,chromaresample="lanczos4")
    
    C40  = "3 -5 17 -21 112  0  0 -0 -4 -13   0  0 -6 -0  15   0  0  0  0 -4   0  0  0  0  0" #
    C40a1= "3 -9 21 -17 112  0  0  0 -4 -12   0  0 -8 -0  14   0  0  0  0 -4   0  0  0  0  0" #
    C40a2= "3 -5 21 -17 112  0  0  2 -4 -12   0  0 -8  4  10   0  0  0 -1 -4   0  0  0  0  2" #
    C40b ="-2 -3 19 -21 112  0  0 -0 -4 -13   0  0 -6 -0  15   0  0  0  0 -4   0  0  0  0  0" #
    C40c = "3 -3 23 -23 112  0  0 -0 -4 -10   0  0 -7 -0  15   0  0  0  0 -5   0  0  0  0  0" #
    C40d = "3 -5 23 -25 112  0  0 -0 -4 -10   0  0 -7 -0  15   0  0  0  0 -4   0  0  0  0  0" #
    C40e = "3 -5 23 -25 140  0  0 -0 -4 -10   0  0 -6 -0  15   0  0  0  0 -4   0  0  0  0  0" #
    C40f = "5 -5 29 -25 130  0  0 -0 -3 -12   0  0 -5 -0  15   0  0  0  0 -4   0  0  0  0  2" #
    C40g ="5 -11 29 -25 130  0  0 -0 -3 -10   0  0 -5 -0  20   0  0  0  0 -6   0  0  0  0  2" #
    C40h ="5 -11 29 -25 130  0  0 -0 -3 -30   0  0 -5 -0  40   0  0  0  0 -8   0  0  0  0  3" #
    C40i ="3  -9 25 -25 130  0  0  2 -4 -25   0  0 -5  5  25   0  0  0 -1 -7   0  0  0  0  3" #
    C40k ="3 -10 23 -28 123  0  0  2 -4 -25   0  0 -5  5  25   0  0  0 -1 -7   0  0  0  0  3" #
    C40k1="3 -10 25 -28 132  0  0  2 -4 -27   0  0 -5  5  23   0  0  0 -1 -7   0  0  0  0  3" #that's a good general one
    C41  = "3 -8  7 -11 112  0  0 -0 -6 -12   0  0 -3  2  14   0  0  0  0 -4   0  0  0  0  2" #C4.1 naturalsharp
    
    GeneralConvolution(0, C40a2) # select kernel to use, specify its variable name here
    
    ConvertToYV12(matrix="PC.709",interlaced=false,chromaresample="lanczos4")
    
    CShft(last,-0.3,-1.5)  # adjust per video for rainbow artifacts / chroma position
    
    Crop(0,6,-2,-2)
    
    
    
    #--------------------------- helper funcs ---------------------------------------
    function CShft(clip In, float X, float Y) {
    w = In.Width()
    h = In.Height()
    Tmp = In.BlackmanResize(w, h, -X, -Y, w-X, h-Y, 5)
    In = MergeChroma(In, Tmp)
    return In}
    
    function cut(clip In, int Mins, float secs, int Mins2, float secs2) {
    tpos = 60.*Mins + secs
    te =   60.*Mins2 + secs2
    Outclp=Trim(In,int(rff*tpos)+1,-int(rff*(te-tpos))-1)
    return Outclp}
    
    it is only for interlaced videos and you need to use a simple deinterlacer.
    it is the line with "yadif" and it needs to load its DLL correctly. (remove the # sign and enter correct path)

    however, it also could be merged with the complex deinterlacer scripts by a skilled coder.
     
    Last edited: Feb 8, 2017
  8. Lonsdaleite

    Lonsdaleite New Member

    Any chance you might re-up the batch files? I'd like to use them as a reference for my encode workflow.
     
  9. SamKook

    SamKook Akiba Citizen Uploader

    Done, looks like one of the previous forum update decided that an imouto picture was better than my script, lol.

    You may also be interested in this(a much simpler script for simply re-encoding a video): https://www.akiba-online.com/threads/wmv-to-mkv-re-encoding-help.1082131/#post-2090539

    You don't need anything remotely as complicated as this script to do things manually, you basically only have to make an avisynth script with the video processing you want and then use a few separate tools(mostly command line stuff) to process or encode your stuff. This is only to automate some of the process to save me some time. I really need to finish v 1.3 one of these days.