VideoHelp Forum
+ Reply to Thread
Results 1 to 26 of 26
Thread
  1. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    Hi, please,


    dealing with half a day but still a lot of problems, I have this script:

    Code:
    SetMemoryMax(8192) 
    
    LoadPlugin("C:\Cesta\k\AviSynth\plugins\decomb.dll")
    
    inFile = "C:\!temp\avatar.mkv"
    outFile = "C:\!temp\avatar2.mkv"
    
    
    video = ffvideosource  (inFile)
    
    left = video.SelectEven()
    right = video.SelectOdd()
    
    stacked = StackHorizontal(left, right)
    
    interleaved = Interleave(left, right)
    filtered = decomb(interleaved)
    
    stacked.Trim(0, video.FrameCount-1, 0)
    filtered.Trim(0, video.FrameCount-1, 0)
    
    final = Interleave(stacked, filtered)
    
    x265Encoder("c:\Apps\x265\x265.exe", final, outFile, crf=18, preset="slow", tune="ssim", frames=video.FrameCount, fps=video.FrameRateNum/video.FrameRateDen, threads=16)
    havent found "decomb.dll"
    so fails on: decomb, trim etc.

    I'm a newbie, sorry
    Quote Quote  
  2. In Avisynth try something along the line:

    Code:
    ffms2("...your SBS source...")
    SBS=last
    left=SBS.crop(0,0,width/2,0)
    right=SBS.crop(width/2,0,0,0)
    upper=left.spline36resize(1920,540)
    lower=right.spline36resize(1920,540)
    stackvertical(upper,lower)
    
    return last
    Quote Quote  
  3. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    Thank you!
    Does this code choose only odd lines for the left and even lines for side right? Resize is unfortunately not enough.
    Quote Quote  
  4. It assumes progressive SBS video as a source and re-arranges the 2 pictures as OU, 1920x1080.
    "Lines" are not relevant.

    If your 3D source is line interleaved rather than SBS then you would need another script of course.
    Quote Quote  
  5. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    Thx. I watched full sbs made to just full ou and it really wasn't visibly so sharp. Surely correct odd rows for left and even rows for right gives better sharpness.

    Is any way how to incorporate this into your code like the "field" function in ffmpeg?

    Found this solution with ffmpeg:

    Code:
    !seperate left and right
    ffmpeg -i avatar2.mkv -vf stereo3d=sbsl:ml -an -sn 		1_L.mkv
    ffmpeg -i avatar2.mkv -vf stereo3d=sbsl:mr -an -sn 		1_P.mkv
    !keep just odd and even rows
    ffmpeg -i 1_L.mkv -vf field=type=top 				2_LH.mkv
    ffmpeg -i 1_P.mkv -vf field=type=bottom 			2_PH.mkv
    !join and create half top OU
    ffmpeg -i 2_LH.mkv -i 2_PH.mkv -filter_complex vstack=inputs=2 	3_HOU.mkv
    Is it ok? Looks the result is ok but want to be sure. Maybe not an effective code for CPU
    Last edited by maysider; 6th Feb 2024 at 05:55.
    Quote Quote  
  6. Originally Posted by maysider View Post
    Surely correct odd rows for left and even rows for right gives better sharpness.
    Maybe. Your eyes decide.
    How is your source muxed? How has it been converted to SBS?
    In Avisyynth you can use
    Code:
    separatefields()
    e=selecteven()  #even field
    o=selectodd()   #odd field
    Last edited by Sharc; 6th Feb 2024 at 06:10.
    Quote Quote  
  7. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    I really dont know how it was muxed then, I just downloaded

    but thank you, not it looks here are 2 solutions for that: ffmpeg and avisynth
    Quote Quote  
  8. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    but does my or yours reduce the quality of the movie or is it just basically a copy?

    oh, from a 21GB full SBS movie is cut left side with just 2.6GB without sound. What is wrong with this code? Why is the left side almost 10 time smaller when it should be around half the size? Level of AVC is changed from 5 to 4, does it mean anything?

    Code:
    !seperate left and right
    ffmpeg -i avatar2.mkv -vf stereo3d=sbsl:ml -an -sn 		1_L.mkv
    Last edited by maysider; 6th Feb 2024 at 07:54.
    Quote Quote  
  9. You should compare apples with apples.
    Your frame size is 960x1080, my script is for 1920x1080.
    The file size depends on the compression. You selected crf 23 (default value of x264 AFAIK) which is pretty strong.
    Quote Quote  
  10. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    no, from the full sbs 21GB 4Kx1K is cut just the left side and it is now 1920x1080 with 2.6GB. I didnt select crf. I thought it would just copy the stream not to compress and destroy the quality by every step I do
    Last edited by maysider; 6th Feb 2024 at 08:51.
    Quote Quote  
  11. You didn't specify the crf so the encoder just used its default which is crf 23.
    Secondly you compress the video twice: First for creating the left (right) views and then again to create the OU view. The intermediate views should be encoded lossless (or "visually lossless") to preserve the quality.
    Quote Quote  
  12. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    so should I use this? or lower crf for standard high quality?

    Code:
    ! 1 - separate
    ffmpeg -i avatar2.mkv -vf stereo3d=sbsl:ml -c:v libx264 -crf 18 -an -sn 			1_L.mkv
    ffmpeg -i avatar2.mkv -vf stereo3d=sbsl:mr -c:v libx264 -crf 18 -an -sn 			1_P.mkv
    !2 - remove rows
    ffmpeg -i 1_L.mkv -vf field=type=top 								2_LH.mkv
    ffmpeg -i 1_P.mkv -vf field=type=bottom 							2_PH.mkv
    !3 - merge
    ffmpeg -i 2_LH.mkv -i 2_PH.mkv -filter_complex vstack=inputs=2 	 -c:v libx264 -crf 18		3_HOU.mkv
    There is no compression in the 2nd step?
    The result is correct: from 4Kx1K to the final result 2Kx1K (in detail 1920x1080)
    Last edited by maysider; 6th Feb 2024 at 09:18.
    Quote Quote  
  13. Or try something like this (for 1920x1080 frame size):
    Code:
    ffmpeg -i "%~1" -vf "crop=iw/2:1080:0:0,scale=w=1920:h=540,setsar=1:1" -c:a copy -c:v libx264 -crf 0 "left.mp4"
    ffmpeg -i "%~1" -vf "crop=iw/2:1080:960:0,scale=w=1920:h=540,setsar=1:1" -c:a copy -c:v libx264 -crf 0 "right.mp4"
    ffmpeg -i "left.mp4" -i "right.mp4" -filter_complex:v "vstack" -c:a copy -c:v libx264 -crf 18 "OU_.mp4"
    Quote Quote  
  14. The quality suffers anyway when you convert from Full SBS to OU because the verical resolution is halved.
    Quote Quote  
  15. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    so you really helped me a lot, thank you! I havent found how to like your coments!
    Quote Quote  
  16. Most simple is probably (for 1920x2160 OU):
    Code:
    ffmpeg -i "%~1" -vf stereo3d=sbsl:tb2l -c:a copy -c:s copy -c:v libx264 -crf 18 "OU.mp4"
    or for 1920x1080 OU:
    Code:
    ffmpeg -i "%~1" -vf stereo3d=sbsl:tb2l,scale=1920:1080,setsar=1/1 -c:a copy -c:s copy -c:v libx264 -crf 18 "OU.mp4"
    Depends what your player accepts.....
    Last edited by Sharc; 6th Feb 2024 at 11:25.
    Quote Quote  
  17. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    Used "field" but had to change to "crop=iw/2:1080:1920:0" to cut the right half correctly

    What about
    ffmpeg -hwaccel vaapi -c:v h264_vaapi
    ?

    Will it work with my AMD machine? Do I have to install anything more to make it work?
    I have the most modern AMD GPU so is it ok, or any better tool for higher performance using AMD GPU?
    Last edited by maysider; 6th Feb 2024 at 14:09.
    Quote Quote  
  18. Originally Posted by maysider View Post
    Used "field" but had to change to "crop=iw/2:1080:1920:0" to cut the right half correctly
    Yes, it has to be adjusted according to source dimensions. Or automatically like

    For left half:
    Code:
    crop=iw/2:ih:0:0
    For right half:
    Code:
    crop=iw/2:ih:iw/2:0
    Quote Quote  
  19. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    thx Sharc, implemented

    what about GPU acceleration? it should be much faster, right? Tried but no success
    Quote Quote  
  20. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    Code:
    !HW 265
    ffmpeg -i avatar2.mkv -c:v hevc_amf -qp_i 23 -qp_p 23 -qp_b 23  -an -sn -t 50	1_final_265.mkv
    !HW 264
    ffmpeg -i avatar2.mkv -c:v h264_amf -qp_i 16 -qp_p 16 -qp_b 16  -an -sn -t 50	1_final_264.mkv
    did the trick on AMD Windows 11, so faster!!!
    Last edited by maysider; 7th Feb 2024 at 04:05.
    Quote Quote  
  21. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    but now absolutely dont know how to set the parametres of hevc_amf to be maybe like h264 crf=16, for a very good quality movie with fast scenes
    Quote Quote  
  22. By lowering the -qp_x values I would assume (I am on NVIDIA though)
    There is however no direct relation and comparison between 264 and 265, so it's basically trial and error to achieve the "same" quality (to be compared at same file size of course).
    (Quality of GPU encoding is still considered inferior compared to CPU encoding AFAIK)
    Quote Quote  
  23. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    thank you!
    inferior on GPU even today? why? whats the problem?
    Quote Quote  
  24. Member
    Join Date
    Mar 2009
    Location
    Czech Republic
    Search Comp PM
    btw, this should be enough quality for everything with a copy all the audio and sub streams through AMD HW coding to HEVC:

    Code:
    ffmpeg -i  "movie.mkv" -c:v hevc_amf -rc cqp -quality quality -qp_i 16 -qp_p 18 -map 0:v:0 -map 0:a -map 0:s 1_final_265.mkv
    Last edited by maysider; 7th Feb 2024 at 08:56.
    Quote Quote  
  25. Originally Posted by maysider View Post
    thank you!
    inferior on GPU even today? why? whats the problem?
    More complex algos in SW, better rate control .... Tests can be exhaustive though and differences may be subtle.
    Your eyes decide.
    Quote Quote  



Similar Threads

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