Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Noise reduction with ffmpeg

  1. #1
    Join Date
    Jun 2010
    Beans
    57

    Noise reduction with ffmpeg

    I archived some old VHS tapes using an stk1160 video grabber. Naturally these are a bit noisy and I read that ffmpeg can do noise reduction in two pass mode. This is what I tried:
    Code:
    ffmpeg -i invideo.avi -sameq -vcodec libx264 -nr 1000 -pass 1 -passlogfile passlog -acodec libvo_aacenc outvideo.mp4
    ffmpeg -i invideo.avi -sameq -vcodec libx264 -nr 1000 -pass 2 -passlogfile passlog -acodec libvo_aacenc outvideo.mp4
    Now I have different issues:

    1. Audio is gone after the first pass
    2. The first pass result looks fragmented and a lot of frames seem to be missing
    3. Second pass does not start and gives the following error message:
    Code:
    [libx264 @ 0x1630d60] constant rate-factor is incompatible with 2pass.
    Last edited by xxlray; December 6th, 2012 at 04:39 PM.

  2. #2
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Noise reduction with ffmpeg

    I doubt -nr requires two passes to work properly, but I've never used it. You should use the hqdn3d filter for noise reduction. I'm unsure if the so-called "ffmpeg" from the repository has this filter. If that is the case, then you can compile ffmpeg, use a PPA, or an already compiled static build.

    Do not use -sameq. It does not mean "same quality" and has been removed upstream.

    Encoding with two-passes is generally used if you are targeting a specific output file size. In most other cases you should do a single pass with -crf. For two-passes, the first pass does not need to encode the audio, and you don't even need to output to a file. See the FFmpeg and x264 Encoding Guide for more info.

    One series of tests shows that the native FFmpeg aac encoder provides better quality than libvo_aacenc.

    Example:
    Code:
    ffmpeg -i input.avi -vcodec libx264 -crf 24 -preset slow -filter:v hqdn3d=4.0:3.0:6.0:4.5 -acodec aac -strict experimental -ab 192k output.mp4

  3. #3
    Join Date
    Jun 2010
    Beans
    57

    Re: Noise reduction with ffmpeg

    Thank you for the answer. I tried you command but got the following error message:
    Code:
    Unrecognized option 'filter:v'
    Afterwards I checked my ffmpeg version:
    Code:
    $ ffmpeg -version
    ffmpeg version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
    That is why I tried to install the version from the ppas:
    Code:
    $ sudo add-apt-repository ppa:jon-severinsson/ffmpeg
    $ sudo apt-get update && sudo apt-get upgrade
    There was a warning that because of Ubuntu 12.04 only an older version of ffmpeg could be added by the ppa (I forgot to copy it) and I still get the same error message from ffmpeg while its version seem to not have changed at all.
    Furthermore when displaying the version of ffmpeg I can see the following warning:
    Code:
    *** THIS PROGRAM IS DEPRECATED ***
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
    I need not to stick to ffmpeg if you can tell me how to achieve the same in avconv or transcode or whatever.

  4. #4
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Noise reduction with ffmpeg

    Quote Originally Posted by xxlray View Post
    Thank you for the answer. I tried you command but got the following error message:
    Code:
    Unrecognized option 'filter:v'
    Your ffmpeg is too old. Try using "-vf" instead.

    Quote Originally Posted by xxlray View Post
    Afterwards I checked my ffmpeg version:
    Code:
    $ ffmpeg -version
    ffmpeg version 0.8.4-4:0.8.4-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
    You're not using ffmpeg from FFmpeg. See Who can tell me the difference and relation between ffmpeg, libav, and avconv.

    Quote Originally Posted by xxlray View Post
    That is why I tried to install the version from the ppas:
    Code:
    $ sudo add-apt-repository ppa:jon-severinsson/ffmpeg
    $ sudo apt-get update && sudo apt-get upgrade
    There was a warning that because of Ubuntu 12.04 only an older version of ffmpeg could be added by the ppa (I forgot to copy it)
    What the PPA installs will most likely be newer than what the repository provides.

    Quote Originally Posted by xxlray View Post
    I still get the same error message from ffmpeg while its version seem to not have changed at all.
    In that case the PPA version may not have installed properly. It appears you did not run:
    Code:
    sudo apt-get install ffmpeg
    Quote Originally Posted by xxlray View Post
    Furthermore when displaying the version of ffmpeg I can see the following warning:
    Code:
    *** THIS PROGRAM IS DEPRECATED ***
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
    This is a poorly worded and potentially misleading message. See the link above. It also means you're not using anything from the PPA.

    Quote Originally Posted by xxlray View Post
    I need not to stick to ffmpeg if you can tell me how to achieve the same in avconv or transcode or whatever.
    I do not use avconv. Someone else will have to help you with that.

  5. #5
    Join Date
    Jun 2010
    Beans
    57

    Re: Noise reduction with ffmpeg

    Quote Originally Posted by FakeOutdoorsman View Post
    In that case the PPA version may not have installed properly. It appears you did not run:
    Code:
    sudo apt-get install ffmpeg
    That does not work either:
    Code:
    $ sudo apt-get install ffmpeg
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    ffmpeg is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Nevertheless the ppa seems to be installed correctly:
    Code:
    $ ls /etc/apt/sources.list.d/ | grep ffmpeg
    jon-severinsson-ffmpeg-precise.list
    Anyway the vf option seem to have worked. The result looks a lot smoother. Is it possible to protect corners somehow?

  6. #6
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Noise reduction with ffmpeg

    Quote Originally Posted by xxlray View Post
    Is it possible to protect corners somehow?
    Protect corners? Sorry, but I don't understand what you mean.

  7. #7
    Join Date
    Jun 2010
    Beans
    57

    Re: Noise reduction with ffmpeg

    Sorry (not a native speaker) I meant edge protection. In theory it is possible to have edge detection e.g. by a Laplace filter and apply no or a smaller linear filter for noise reduction there. I just wonder whether a practical solution exists, too.

  8. #8
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Noise reduction with ffmpeg

    If you show a before and after image then maybe I can provide suggestions.

  9. #9
    Join Date
    Jun 2010
    Beans
    57

    Re: Noise reduction with ffmpeg

    I attached a noisy and a denoised still. You can see that the already poor edges get even more blurred when you look at the hand.
    Attached Images Attached Images

  10. #10
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Noise reduction with ffmpeg

    hqdn3d can cause blur. FFmpeg has a filter called "edgedetect", but I don't think it can be used to tell hqdn3d what to do. Perhaps you should investigate Avisynth.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •