Reputation: 31
I have seen ffmpeg has some codecs (e.g. H.264) which are defined as lossless and lossy at the same time, and from my understanding, lossless and lossy are mutually exclusive: a compression algorithm either losses information or doesn't.
How is it possible to be lossless and lossy at the same time?
Running ffmpeg -codecs 2>/dev/null| grep h264
, I get:
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [...]
DEV.LS
stands for Decoder, Encoder, Video, Not only intraframe compression, Lossy compression, Lossless compression.
Upvotes: 1
Views: 1255
Reputation: 8734
The answer was mentioned by @MoDJ in the comments.
The h.264
codec, like many others, has encoding options. Chief among them is the Constant Rate Factor, aka CRF
. The documentation from FFmpeg (an encoder which uses libx264
for encoding h.264/AVC) is a good reference in this case. It says:
The range of the CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28. Consider 17 or 18 to be visually lossless or nearly so; it should look the same or nearly the same as the input but it isn't technically lossless.
(...)
You can use -crf 0 to create a lossless video. Two useful presets for this are ultrafast or veryslow since either a fast encoding speed or best compression are usually the most important factors. (...)
Note that lossless output files will likely be huge, and most non-FFmpeg based players will not be able to decode lossless. Therefore, if compatibility or file size are an issue, you should not use lossless. (...)
To sum up: One particular stream cannot be both lossy and lossless at the same time, but whether a stream is lossy or lossless can be adjusted by a codec setting.
Upvotes: 0
Reputation: 151
Yes, it could be lossy as well as lossless at the same time. When it comes to H.264, MPEG and AVC, the colors, frames are highly affected and it creates visual viewing issues while zooming-in the videos. I have also posted a research study on it --- Check it out
Upvotes: 0
Reputation: 31
Checking in Wikipedia for H.264 it says:
H.264 is typically used for lossy compression in the strict mathematical sense, although the amount of loss may sometimes be imperceptible. It is also possible to create truly lossless encodings using it — e.g., to have localized lossless-coded regions within lossy-coded pictures or to support rare use cases for which the entire encoding is lossless.
Upvotes: 2