Answers.Body: <p>You have a fundamental misunderstanding of how lossy compression works.  It doesn't throw away information so much as ignore the portions of the image that don't conform to the patterns it is looking for.  It does care about small amounts of error, so it doesn't spend time to store them, however it still decodes to a complex video.  The lossless compression doesn't use the same algorithms as the lossy, the shortcuts taken by the lossy algorithm can't be reused by the lossless one.</p>
  
  <p>The lossy algorithm is optimized towards using patterns that will have minimal error with minimal data usage.  Lossless algorithms are optimized towards minimizing the data required when not losing any data, so they work quite differently.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-18T04:55:30.783Z
Answers.LastActivityDate: 2019-07-18T04:55:30.783Z
Answers.UserDisplayName: AJ Henderson
Answers.Body: <p>When data “thrown away” by the encoder, the decoder must still render a full image. The image is just not faithful to the original image, but it is a full image. When you reencode with CRF 0 you are telling the encoder, “I want the output to be identical to the input” and the encoder doesn’t know information was lost on a previous encode. so it must spend bits to encode the “new” image losslessly. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-17T08:39:01.983Z
Answers.Text: But since the new picture is less complex, shouldn't it take less space?
Answers.UserDisplayName: Joy Jin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-17T14:15:30.397Z
Answers.Text: The new picture is not less complex
Answers.UserDisplayName: SlimSCSI
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-17T16:18:00.580Z
Answers.Text: Think of it this way. If you compress with a very low bitrate in the first pass, you get a lot of artifacts and blocking that was not in the original images. Compressing that a second time would attempt to preserve that blockyness. Every time you compress, the generational loss is amplified and preserved, not reduced.
Answers.UserDisplayName: SlimSCSI
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-11T06:13:34.523Z
Answers.LastActivityDate: 2019-07-11T06:13:34.523Z
Answers.UserDisplayName: SlimSCSI
Answers.Body: <p>Maybe this helps you:
  We'll work with images, not video. It's a bit easyer.
  Imagine you have a 10x10 pixel image, every second pixel is whitenand every other is black.
  Now you lossy compress it, instead of storing black-white-black-white...
  It just stores "Display 100 Grey Pixels".</p>
  
  <p>Now you open the image in your NLE and reencode it lossless, now it has a 10x10 pixel image that is grey, so it will store 100x "This Pixel is grey"</p>
  
  <p>So instead of 1x "Display 100 Grey Pixels" in the beginning, you have 100x "Pixel is grey".</p>
  
  <p>This is really really really simplified as even s lossless codec can store it just as 1x "Display 100 Grey Pixel"</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-18T06:12:37.807Z
Answers.LastActivityDate: 2019-07-18T06:12:37.807Z
Answers.UserDisplayName: Timothy Lukas H.
Body: <p>I was re-encoding videos downloaded from YouTube with Lossless H.264 (using FFmpeg) because I'm experimenting with <code>CRF=0</code>. </p>
  
  <p>I found that resulting videos are much bigger (1 gigabyte) than the original video (100 megabyte). </p>
  
  <p>However, from my knowledge of lossy compression, it is basically like lossless compression (plus, it's the same codec) except it throws away lots of minor details that won't be noticed but take up lots of space. Hence, shouldn't I achieve a similar file size if I encode the decoded file using <code>CRF=0</code> because lots of data are already thrown away? I don't quite understand this.</p>
  
  <p>I use the following command: </p>
  
  <pre><code>ffmpeg -i 'file' -an -c:v libx264 -crf 0 'out file'
  </code></pre>
  
Tags: <ffmpeg><encoding><video-quality><libx264>
Title: Re-encoding Lossy formats with Lossless formats
UserDisplayName: Joy Jin
ThreadText: # Re-encoding Lossy formats with Lossless formats
  
  (Asked by: username_0 on 2019-07-11)
  
  I was re-encoding videos downloaded from YouTube with Lossless H.264 (using FFmpeg) because I'm experimenting with `CRF=0`.
  
  I found that resulting videos are much bigger (1 gigabyte) than the original video (100 megabyte).
  
  However, from my knowledge of lossy compression, it is basically like lossless compression (plus, it's the same codec) except it throws away lots of minor details that won't be noticed but take up lots of space. Hence, shouldn't I achieve a similar file size if I encode the decoded file using `CRF=0` because lots of data are already thrown away? I don't quite understand this.
  
  I use the following command:
  
  ```
  ffmpeg -i 'file' -an -c:v libx264 -crf 0 'out file'
  
  ```
  
  **Tags:** ffmpeg, encoding, video-quality, libx264
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2019-07-18. Score: 1
  
  You have a fundamental misunderstanding of how lossy compression works. It doesn't throw away information so much as ignore the portions of the image that don't conform to the patterns it is looking for. It does care about small amounts of error, so it doesn't spend time to store them, however it still decodes to a complex video. The lossless compression doesn't use the same algorithms as the lossy, the shortcuts taken by the lossy algorithm can't be reused by the lossless one.
  
  The lossy algorithm is optimized towards using patterns that will have minimal error with minimal data usage. Lossless algorithms are optimized towards minimizing the data required when not losing any data, so they work quite differently.
  
  
  ---
  
  ### Answer by username_2 on 2019-07-11. Score: 0
  
  When data “thrown away” by the encoder, the decoder must still render a full image. The image is just not faithful to the original image, but it is a full image. When you reencode with CRF 0 you are telling the encoder, “I want the output to be identical to the input” and the encoder doesn’t know information was lost on a previous encode. so it must spend bits to encode the “new” image losslessly.
  
  > **Comments:**
  > **username_0**: But since the new picture is less complex, shouldn't it take less space?  
  > **username_2**: The new picture is not less complex  
  > **username_2**: Think of it this way. If you compress with a very low bitrate in the first pass, you get a lot of artifacts and blocking that was not in the original images. Compressing that a second time would attempt to preserve that blockyness. Every time you compress, the generational loss is amplified and preserved, not reduced.  
  
  ---
  
  ### Answer by username_3 on 2019-07-18. Score: 0
  
  Maybe this helps you:
  We'll work with images, not video. It's a bit easyer.
  Imagine you have a 10x10 pixel image, every second pixel is whitenand every other is black.
  Now you lossy compress it, instead of storing black-white-black-white...
  It just stores "Display 100 Grey Pixels".
  
  Now you open the image in your NLE and reencode it lossless, now it has a 10x10 pixel image that is grey, so it will store 100x "This Pixel is grey"
  
  So instead of 1x "Display 100 Grey Pixels" in the beginning, you have 100x "Pixel is grey".
  
  This is really really really simplified as even s lossless codec can store it just as 1x "Display 100 Grey Pixel"
  
  
  ---
  
  