VideoHelp Forum

Try NordVPN to access Netflix or other streaming services from any country and also surf safely!
+ Reply to Thread
Results 1 to 12 of 12
  1. Hi,

    I have ripped some blu ray with MakeMKV and now I need to save space by convert it to H265 with ffmpeg.

    Unfortunately some blu ray (expecially when the movie is old) are mastered with bad quality. Here an example:

    [Attachment 59482 - Click to enlarge]

    In the most optimistic situation the compressed file quality is identical to source like in my case:

    [Attachment 59483 - Click to enlarge]

    Here the command that I use:

    ffmpeg -y  -i title00.mkv  -c:v libx265 -an -crf 23  -x265-params ref=4:star:subme=4:bframes=8:rd=4:rd-refine=0:qcomp=0.65:fades=1:strong-intra-smoothing=1:ctu=32:qg-size=32:sao=0:selective-sao=0:cu-lossless=0:cutree=1:tu-inter-depth=3:tu-intra-depth=3:max-merge=2:rskip=2:rskip-edge-threshold=2:rc-lookahead=80:aq-mode=2:aq-strength=1.0:rdoq-level=1:psy-rd=4.0:psy-rdoq=15.0:limit-modes=0:limit-refs=3:limit-tu=4:deblock=-4,-4:weightb=1:weightp=1:rect=0:amp=0:wpp=1:pmode=0:pme=0:b-intra=1:b-adapt=2:b-pyramid=1:tskip=1:tskip-fast=0:fast-intra=0:early-skip=0:splitrd-skip=0:min-keyint=24:keyint=240:transfer=bt709:colorprim=bt709:colormatrix=bt709:crf-min=10 -t 200  ouput.mkv
    I was thinked to add some blur or noise reduction to my command, but I ask if there is a better solution with ffmpeg in cases like this.

    Thanks !
    Quote Quote  
  2. That look like upscaled SD, not HD. Try something like:
    -vf scale=iw/2:ih/2,hqdn3d=4.0:3.0:6.0:4.5
    Quote Quote  
  3. Thank you !! with your suggest the image have more quality:

    [Attachment 59485 - Click to enlarge]

    I have another movie ripped from blu ray where the quality is not bad but I think can be better:

    [Attachment 59486 - Click to enlarge]

    can you suggest another filter to improve it ?

    Thanks !
    Quote Quote  
  4. You need to provide video samples for any substantial filtering suggestions. In general, removing grain risks generating posterization artifacts with 8 bit video. If you're going to remove noise I recommend filtering in 10 bits and encoding with 10 bit x265. Assuming your playback devices support that.
    Quote Quote  
  5. Thank you I have upload a sample of video:

    original and compressed (the quality is similar). Can you please suggest a bit improvement ?

    Thanks !
    Quote Quote  
  6. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Search Comp PM
    You can upload videos here up to 500MB in size,a lot easier for others to access.
    I think,therefore i am a hamster.
    Quote Quote  
  7. Try something along the lines of:

    ffmpeg -y -i original.mkv -pix_fmt yuv420p10le -vf crop=1440:1080:240:0,hqdn3d=2.0:3.0:3.0:4.5 -c:v libx265 -preset medium -profile main10 -global_quality 20 output.mkv
    I lowered the noise reduction setting so everything looks a little more natural.
    Quote Quote  
  8. The result is excellent !! compliments !!
    Quote Quote  
  9. Oops, that "-global_quality 20" setting isn't doing anything with x265 -- it was for another encoder (I was copy/pasting from other batch files). Use "-crf 28" instead with x265. Lower values of N get higher quality (and larger files), higher values get lower quality (and smaller files). 28 is the default.

    After changing to -crf N I realized that you will probably want to go back to higher settings for hqdn3d and lower crf values. Try:

    ffmpeg -y -i original.mkv -pix_fmt yuv420p10le -vf crop=1440:1080:240:0,hqdn3d=2.0:3.0:6.0:4.5 -c:v libx265 -preset medium -profile main10 -crf 25 output.mkv
    A good section of the clip for testing is from about 32 to 38 seconds into the clip. Try different fhqdn3d settings and crf values on that section. Watch the detail the headrest behind Data's head, and the noise in the shadow there. Also watch the small low contrast details on Data's head when it moves (wrinkles, rough skin, etc.). If you filter too much they will disappear when his head is moving, then reappear when it stops. Or just disappear altogether. You want to strike a balance between loss of those real details and reducing noise.

    You can concentrate on that section and get quick turnaround with:

    ffmpeg -y -i original.mkv -ss 00:00:32 -to 00:00:38 -pix_fmt yuv420p10le -vf crop=1440:1080:240:0,hqdn3d=2.0:3.0:6.0:4.5 -c:v libx265 -preset medium -profile main10 -crf 25 output.mkv
    Last edited by jagabo; 20th Jun 2021 at 19:00.
    Quote Quote  
  10. Many Thanks, Il will do, for your experience there si quality difference between preset medium and slow ? or there is only file size difference with the some quality ?
    Quote Quote  
  11. Personally, I usually don't use much noise reduction because it will result in some loss of detail, and the noise doesn't bother me. hqdn3d=2.0:3.0:6.0:4.5 will cause obvious loss of detail with some video (I didn't notice any bad problems with this Star Trek clip).

    I don't actually use x265 much. And when I do it's just for a quick test. So I'm not real familiar with precisely how its presets effect quality and size. But, if its like x264, both quality and size change with the preset when using crf encoding. The general rule is use the slowest preset you can stand.
    Quote Quote  
  12. I found this article about the different noise reduction on ffmpeg:

    Since you got me down the rabbit hole of denoisers, I figured I would share my research results with anyone whoís interested.

    ffmpeg has six denoisers built-in that I was able to find, which Iíve listed below along with their transcoding speeds on a 1080p source video using a four-core laptop computer.

    I wrote scripts that used a variety of settings with each denoiser to make sure I was seeing the best each one had to offer.

    - atadenoise (20 fps) - by averaging pixels across frames, it reduces contrast of noise areas to make them less obvious as opposed to using a specialized algorithm to smooth the noise away;
    this reduces overall image contrast; filter also darkens the overall output

    - dctdnoiz (1.6 fps) - creates beautiful detail on a still image, but randomizes the noise across frames so much that it actually makes the noise look worse during playback, plus it darkens the output

    - nlmeans (0.6 fps) - darkens the output, but sometimes has redeeming qualities (more on this later)

    - hqdn3d (21 fps) - color neutral which is good, but the output looks smeary to me where it loses a lot of fine detail in hair strands and wood grain

    - owdenoise (0.3 fps) - color neutral wavelet denoiser with stunningly good results on high-res sources

    - vaguedenoiser (7.6 fps) - another color neutral wavelet denoiser whose output looks identical to owdenoise, but its processing speed is 25x faster;
    tried every combination of threshold and nsteps, and found the default settings of 2/6 to consistently produce the closest-to-real-life results

    I tested the denoisers on videos I took with my own mirrorless camera, meaning I remember what the scene looked like in real life. In one video, there happened to be a guy in a black business dress shirt made of silk or
    satin or something with a sheen to it, but the sheen wasnít coming through due to the noise of the original footage.
    The wavelet-based denoisers were the only ones to remove and smooth the noise such that the fabric regained the smooth sheen you would expect from silk.
    To my eye, it bumped up the realism of the video an entire notch to see fabric actually look like fabric.
    The rest of the frame also dropped to zero dancing noise. It turned the video into a still photograph when nothing was moving.
    I didnít realize until this experiment that even a tiny amount of dancing noise can seriously detract from the realism of a video, and that a sense of immersion can be restored by getting rid of it.
    Obviously, vaguedenoiser is my new weapon of choice.

    So, about nlmeansÖ I found a radical difference between the ffmpeg version and the HandBrake version.
    I think HandBrake wins on every metric. nlmeans in ffmpeg actually makes video look worse (blockier) if the resolution is 1080p or above, or if the video comes from an excellent camera
    that has little noise to begin with. nlmeans in ffmpeg also canít be used as a finishing step because it darkens the output, which destroys any color grading that happened before it.
    But I found two places where nlmeans in ffmpeg outshined the other ffmpeg denoisers: low-resolution video, and very-high-noise video. nlmeans does great at restoring a VHS capture,
    which I sense from the authorís web site was one of the original design goals.
    Secondly, in my tests, nlmeans did better than the other ffmpeg denoisers on high-resolution high-noise videos, which in my case meant a smartphone video in low light using digital zoom.
    Given these two specialized cases where nlmeans performed well, I could see a workflow where I used nlmeans to create denoised intermediates, then color graded the intermediates to fix the darkened output.
    Running nlmeans on a noisy source then adding it to the timeline and running vaguedenoiser on the total project did not cause any harm in my tests. But for best results,
    I think HandBrake is still the way to go where nlmeans is involved.

    For my purposes, I think I will stick to vaguedenoiser because itís beautiful on 1080p and 4K, and it is easily added to my existing ffmpeg filter chain when I do my finishing steps.
    I donít have to create an intermediate to pass off to HandBrake this way. However, if I came across a particularly noisy source video, I would probably run it through HandBrake before adding
    it to my Shotcut project to get the same benefits Andrew noticed.

    What you think ?
    Quote Quote  

Similar Threads