VideoHelp Forum
+ Reply to Thread
Results 1 to 16 of 16
Thread
  1. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Which lossless video codec has the smallest file size? And what does incoding mean for videos?
    Last edited by Jay123210599; 25th Dec 2023 at 12:06.
    Quote Quote  
  2. Usually x264 or ffv1 , but it can depend on the pixel format and scenario

    But if you're starting with a lossy source, using a lossless video codec will actually make the filesize many times larger - Because video is decoded to uncompressed data before re-compressing with the lossless codec.
    Quote Quote  
  3. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Usually x264 or ffv1 , but it can depend on the pixel format and scenario

    But if you're starting with a lossy source, using a lossless video codec will actually make the filesize many times larger - Because video is decoded to uncompressed data before re-compressing with the lossless codec.
    How do I convert to x264 lossless, then? Will it make all frames keyframes?
    Quote Quote  
  4. Originally Posted by Jay123210599 View Post
    Originally Posted by poisondeathray View Post
    Usually x264 or ffv1 , but it can depend on the pixel format and scenario

    But if you're starting with a lossy source, using a lossless video codec will actually make the filesize many times larger - Because video is decoded to uncompressed data before re-compressing with the lossless codec.
    How do I convert to x264 lossless, then? Will it make all frames keyframes?
    ffmpeg
    Code:
    -c:v libx264 -qp 0
    eg.
    Code:
    ffmpeg -i input.ext -c:v libx264 -qp 0 output.mkv

    No, lossless x264 uses P frames for temporal compression to reduce the filesize by default. If you wanted all keyframes, add -g 1 . Filesize will increase for the intra (all keyframe) version. Both versions will be significantly larger than a source version that used lossy compression
    Quote Quote  
  5. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post
    Originally Posted by poisondeathray View Post
    Usually x264 or ffv1 , but it can depend on the pixel format and scenario

    But if you're starting with a lossy source, using a lossless video codec will actually make the filesize many times larger - Because video is decoded to uncompressed data before re-compressing with the lossless codec.
    How do I convert to x264 lossless, then? Will it make all frames keyframes?
    ffmpeg
    Code:
    -c:v libx264 -qp 0
    eg.
    Code:
    ffmpeg -i input.ext -c:v libx264 -qp 0 output.mkv

    No, lossless x264 uses P frames for temporal compression to reduce the filesize by default. If you wanted all keyframes, add -g 1 . Filesize will increase for the intra (all keyframe) version. Both versions will be significantly larger than a source version that used lossy compression
    Will -g 1 make all frames keyframes in any video codec?
    Quote Quote  
  6. Originally Posted by Jay123210599 View Post

    Will -g 1 make all frames keyframes in any video codec?
    It should for most of them
    Quote Quote  
  7. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    I think you're asking the wrong question. Not all lossless is lossless, format matters.

    What is the purpose here?
    - intermediary?
    - capture?
    - archive?

    The best is not the same for all.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  8. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by lordsmurf View Post
    I think you're asking the wrong question. Not all lossless is lossless, format matters.

    What is the purpose here?
    - intermediary?
    - capture?
    - archive?

    The best is not the same for all.
    All of the above.
    Quote Quote  
  9. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Not possible.
    Just as there are work projects which have 3 constraints (Fast, Cheap, Good/High quality) and you have to pick 1 or at best 2 of those constraints to prioritize, video & audio compression has similar constraints of size, quality, complexity, speed, latency, etc.
    The very feature which allows for small sizes does so by being more complex in its Gop structure/length and in being lossy.
    In other words, you cannot have your cake and eat it too. Or, there is no such thing as a free lunch.


    Scott
    Last edited by Cornucopia; 26th Dec 2023 at 10:34.
    Quote Quote  
  10. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Originally Posted by Jay123210599 View Post
    Originally Posted by lordsmurf View Post
    I think you're asking the wrong question. Not all lossless is lossless, format matters.

    What is the purpose here?
    - intermediary?
    - capture?
    - archive?

    The best is not the same for all.
    All of the above.
    That's not an acceptable answer. Each situation has different needs, and it has options therein based on factors.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  11. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by lordsmurf View Post
    Originally Posted by Jay123210599 View Post
    Originally Posted by lordsmurf View Post
    I think you're asking the wrong question. Not all lossless is lossless, format matters.

    What is the purpose here?
    - intermediary?
    - capture?
    - archive?

    The best is not the same for all.
    All of the above.
    That's not an acceptable answer. Each situation has different needs, and it has options therein based on factors.
    I have h264 and h265 videos that I want to losslessly cut into smaller parts, but there are certain sections that can only be cut at P or B frames instead of I frames. I'm also planning on converting said smaller parts into apng/gif files and uploading them into DeviantArt.
    Quote Quote  
  12. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Live with the loss, or live with the size.


    Scott
    Quote Quote  
  13. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Can always try -g 1 as suggested by poisondeathray , but to make for a smaller
    file, use it with something like CRF 14 and preset Medium. It's not lossless,
    but it gives very good results and it's easy to edit since it's all "I" frames.
    In a case like this, as has been suggested by many esteemed forum members,
    you have to find the right compromise
    Quote Quote  
  14. You don't need to encode using I frames for your scenario, because you can specify the exact section you want beforehand (e.g. mark in/out in vdub, or avidemux, or avisynth etc... ) and encode normally using long GOP ( I,B,P frames) , or for lossless - I,P frames only

    Since it's already "marked" perfectly with the exact frames , there is no reason to export using I frames, unless you plan on cutting that segment again later.

    Typically I-frame only would require 25-50% more bitrate (thus larger filesize) for a similar level of quality compared to long GOP . If you take the sample clip you uploaded in the other thread, I-frame lossless 10bit444 x264 is 300MB, long GOP lossless is 221MB. Both lossless . You would see similar trend for minimally lossy and lower bitrate ranges (correlating them with some "quailty" measure , such as VMAF, PSNR , SSIM)


    For the the apng or gif scenario, then vdub2 can trim to the section and export those directly as well , if you didn't want to keep the video segment or intermediate step .

    Apng encoding does not have that many materially different options, but there are dozens of gif optimization strategies. Because gif can only have 256 colors, there are many pallette optimization and dithering strategies . For that reason , you might not want to use vdub2 for gif creation since vdub2 doesn't have very many gif options
    Last edited by poisondeathray; 27th Dec 2023 at 22:01.
    Quote Quote  
  15. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    You don't need to encode using I frames for your scenario, because you can specify the exact section you want beforehand (e.g. mark in/out in vdub, or avidemux, or avisynth etc... ) and encode normally using long GOP ( I,B,P frames) , or for lossless - I,P frames only

    Since it's already "marked" perfectly with the exact frames , there is no reason to export using I frames, unless you plan on cutting that segment again later.

    Typically I-frame only would require 25-50% more bitrate (thus larger filesize) for a similar level of quality compared to long GOP . If you take the sample clip you uploaded in the other thread, I-frame lossless 10bit444 x264 is 300MB, long GOP lossless is 221MB. Both lossless . You would see similar trend for minimally lossy and lower bitrate ranges (correlating them with some "quailty" measure , such as VMAF, PSNR , SSIM)


    For the the apng or gif scenario, then vdub2 can trim to the section and export those directly as well , if you didn't want to keep the video segment or intermediate step .

    Apng encoding does not have that many materially different options, but there are dozens of gif optimization strategies. Because gif can only have 256 colors, there are many pallette optimization and dithering strategies . For that reason , you might not want to use vdub2 for gif creation since vdub2 doesn't have very many gif options
    How do I get long GOP lossless?
    Quote Quote  
  16. Originally Posted by Jay123210599 View Post

    How do I get long GOP lossless?
    long GOP is the default setting for x264, x265 .

    If you don't change -g in ffmpeg or the max keyframe interval. Default is 250 already instead of 1 . ffmpeg should use the same pixel format is input

    For your 10bit444 case , in vdub2 you'd have to select x264 10bit, YUV444 (normall it would be set to 420), rate control single pass - lossless . Or if you didn't want lossless, but some high quality but smaller filesize, use some low crf value instead . Do some tests to see what is an acceptable tradeoff for filesize vs. quality. But Long GOP is a must for reducing filesize at a given quality level if that was your main goal

    -qp 0 is lossless for libx264 in ffmpeg for all libx264 supported pixel types . -crf 0 is not lossless for 10bit, so use -qp 0

    For ffmpeg libx265 , you need -x265-params lossless=1
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!