Changes between Version 13 and Version 14 of Postprocessing

Mar 4, 2015, 3:34:00 AM (2 years ago)

explain that newer codecs usually don't need PP. Tidy up the explanation of QP-adaptive PP. Make it clear that PP trades artifacts for blurring. Specify that the test images were done with FFmpeg's mpeg2 encoder (as mentioned on ffmpeg-devel)


  • Postprocessing

    v13 v14  
    1 Post-processing filters are used in videos for quality-improvement. They are especially relevant for filtering video material encoded with low-quality, as they allow to remove the more common encoding artifacts (e.g. blocking and ringing). 
     1Post-processing filters are applied after decoding a low-quality video, usually to make blocking and ringing artifacts less visually annoying.  They operate by blurring the video in a way that reduces blocking and ringing with as little impact as possible on the sharpness of the image.  There is always a tradeoff, though, and once a lossy codec has thrown away information, it can never be recovered without access to the original source.  Some things are more visually annoying than others, and postprocessing can make low-quality videos nicer to watch. 
    3 These filters are intended for recovering quality of videos ripped from DVD, VideoCD or after decompressing. 
     3Postprocessing is usually only useful with older codecs.  Newer ones (including h.264, h.265, and VP8/9) all include deblocking filters as part of the codec.  For example, in h.264, the deblocking filter is applied before a decoded frame is used as a reference for future frames, and the deblocking strength is selected by the encoder.  This is why it's called an "in-loop" deblocker, because it's inside the decode / reference loop, and why {{{-skip_loop_filter all}}} causes errors to accumulate.  (Every h.264 decoder must decode a valid h.264 stream to the same bit-identical output, so all of this filtering is specified exactly.  The encoder knows what the decoder is going to do, and thus knows what it's getting when choosing reference frames and sending the difference (residual).) 
     5The end result is that low-bit-rate h.264 video usually already has as good a balance of blurring vs. blocking and ringing as possible.  If you really hate blocking/ringing, and don't mind blurring as much, then you might still want to postprocess.  Or maybe you have a h.264 video where the encoder turned off deblocking (maybe targetting playback on slow CPUs since deblocking costs decoder CPU time), or the user set {{{deblock=-5:-5}}} so the output ended up with more blocking and less blurring than would be ideal. 
     7Anyway, most of the time it won't help to postprocess h.264, HEVC, VP8, or VP9 video. 
     9Postprocessing IS certainly useful for artifacty MPEG2 and MPEG4-ASP (divx, xvid), and even older codecs, as their output is often full of blocking and ringing when the encoder didn't have enough bitrate to make the output look good. 
    511FFmpeg includes the following post-processing filters: 
    1117* [ pp] - libpostproc wrapper 
    13 These filters basically smooth away blocking and other artifacts from low quality sources. The QP parameter is chosen by the encoder used to create the video, VCD, DVD, etc. Lower QP for the encoder results in higher bitrate and higher quality encoding. If no "QP" parameter is specified by the user to postprocessing filter uses the one that is stored in the encoded file for the specific area. In particular, the quantization parameter QP regulates how much spatial detail is saved. When QP is very small, almost all detail is retained. As QP is increased, some of that detail is aggregated so that the bit rate drops – but at the price of some increase in distortion and some loss of quality. 
     19These filters basically smooth away blocking and other artifacts from low quality sources.  By default, they use information from the decoder to adapt the filter strength to the quality of each block.  (QP = quantization parameter.  Lower number = less rounding off = higher quality.  Every block has its own QP, and ffmpeg's video decoders export this information along with the decoded video so filters can refer to it.)  Higher QP blocks get stronger PP applied, because more of their "detail" is probably actually blocking and ringing that we want to get rid of. 
     21This adaptive filtering is very similar to what h.264 does, but don't try to use x264 as a deblocker.  There isn't an option to tell x264 that you WANT it to try to deblock, so it will still be trying to preserve all the blocking and ringing in the frames you feed it.  It will see the filtered frames from its deblocking filter as worse matches for the input frames, because of the loss of all that "detail" (actually artifacts from the previous encoder, but it takes a human (or AI) to tell the difference). 
     23Transcoding from one lossy codec to another lossy codec will never increase quality.  In fact, it will always lose quality, by definition for lossy codecs.  If you have other reasons for transcoding old artifacty video into something else (e.g. player compatibility, using a clip as part of a longer video, or going to an even lower bitrate), then it can be a good idea to apply some PP before feeding it to the new encoder. 
    1526{{{uspp}}} uses an encoder, hence, should be used only when one has a powerful CPU. Also, {{{uspp}}} is very slow as compared to other filters. Therefore, for processing large amount of data, {{{fspp}}} is a good option (It gives good results if parameters are chosen wisely). 
    2738where PP is the postprocessing filter with its parameters.  
    29 When using postprocessing filters before encoding, keep in mind that even if encoding artifacts will be removed by the filter, new artifacts will be added by the new encoding. In some cases the postprocessing filters though will increase the visual quality (or even reduce the encoding output size), especially when encoding from low-quality content to high-quality (using a better codec or a higher bitrate). 
    3140Let's consider the example of 
    33 1. Test sequence from the movie "Matrix" (187 seconds) compressed to 200kbps. The following table shows the filter options used, and frame number "123" corresponding to the output video.  
     421. Test sequence from the movie "Matrix" (187 seconds) compressed with ffmpeg's MPEG2 encoder, at 200kbps to introduce lots of blocking and ringing. The following table shows the filter options used, and frame number "123" corresponding to the output video.  
    3544||=      Original Image       =||=       Query Image =||