VideoHelp Forum




+ Reply to Thread
Results 1 to 20 of 20
  1. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    How do I convert a video into an image sequence of lossless webp files?
    Quote Quote  
  2. webp lossless only supports "RGBA" in 8bit , the webp YUV compression is lossy.

    webp lossless typically results in 10-30% better than PNG typical compression, but it varies on content. You can use brute force PNG optimzation such as optipng, pngcrush - but it might take minutes per frame for <1% better compression , and webp will still beat it . The main "negative" of webp is compatibility with some programs (should be ok in open source programs, modern browsers) . PNG is far more compatible

    The "lossless" refers to 8bit RGB input - ie. there are no additional compression losses - but there will technically be some loss from the colorspace conversion if you start with YUV - because you can never get back the original YUV data with 8bit RGB. (Similar with PNG for 8bit and 16bit RGB - they will be lossy for YUV input)

    You can use ffmpeg libwebp with -lossless 1

    Code:
    ffmpeg -i input.ext -c:v libwebp -lossless 1 -start_number 0 output%06d.webp
    If source video was YUV, then you must perform the YUV to RGB conversion correctly, otherwise you will get the wrong colors. For example, you definitely need the correct matrix, and perhaps the correct transfer and primaries. If HDR you'd probably want to tonemap for 8bit RGBA

    e.g. for a typical "HD" source, ffmpeg might automatically get it correct or incorrect. If video has correct flags, it might get or correct (or not, sometimes ffmpeg builds have bugs, the recent one does for zscale this last week, so verify the input and output) . If you wanted to specify 709 matrix input manually you might use

    Code:
    -vf zscale=min=709,format=bgra
    Quote Quote  
  3. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    webp lossless only supports "RGBA" in 8bit , the webp YUV compression is lossy.

    webp lossless typically results in 10-30% better than PNG typical compression, but it varies on content. You can use brute force PNG optimzation such as optipng, pngcrush - but it might take minutes per frame for <1% better compression , and webp will still beat it . The main "negative" of webp is compatibility with some programs (should be ok in open source programs, modern browsers) . PNG is far more compatible

    The "lossless" refers to 8bit RGB input - ie. there are no additional compression losses - but there will technically be some loss from the colorspace conversion if you start with YUV - because you can never get back the original YUV data with 8bit RGB. (Similar with PNG for 8bit and 16bit RGB - they will be lossy for YUV input)

    You can use ffmpeg libwebp with -lossless 1

    Code:
    ffmpeg -i input.ext -c:v libwebp -lossless 1 -start_number 0 output%06d.webp
    If source video was YUV, then you must perform the YUV to RGB conversion correctly, otherwise you will get the wrong colors. For example, you definitely need the correct matrix, and perhaps the correct transfer and primaries. If HDR you'd probably want to tonemap for 8bit RGBA

    e.g. for a typical "HD" source, ffmpeg might automatically get it correct or incorrect. If video has correct flags, it might get or correct (or not, sometimes ffmpeg builds have bugs, the recent one does for zscale this last week, so verify the input and output) . If you wanted to specify 709 matrix input manually you might use

    Code:
    -vf zscale=min=709,format=bgra
    What lossless image format is a better alternative for YUV videos (besides png files)?
    Quote Quote  
  4. Originally Posted by Jay123210599 View Post

    What lossless image format is a better alternative for YUV videos (besides png files)?
    PNG is 8 or 16bit RGB only too, so technically not lossless for YUV

    TIFF supports YUV, and multiple compression schemes, but not all programs handle the YUV variant correctly

    Why are you using an image sequence ? What is the background information or scenario ? How is it being used ?
    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

    What lossless image format is a better alternative for YUV videos (besides png files)?
    PNG is 8 or 16bit RGB only too, so technically not lossless for YUV

    TIFF supports YUV, and multiple compression schemes, but not all programs handle the YUV variant correctly

    Why are you using an image sequence ? What is the background information or scenario ? How is it being used ?
    What other lossless image formats support YUV? Are they smaller than TIFF? I also want to upload the images.
    Quote Quote  
  6. Originally Posted by Jay123210599 View Post
    What other lossless image formats support YUV? Are they smaller than TIFF? I also want to upload the images.
    Upload images to a website, for a browser or mobile device(phone) for display ? Best bet is 8bit RGB, such as PNG (without gAMA or cHRM tags) , or webp

    AVIF and HEIF support YUV , but they have even lower compatibility


    Don't worry about the technical quality loss for 8bit RGB in your display scenario - When you "see" something on a monitor or TV it has been converted to RGB anyways - it's an RGB converted representation of that YUV data. If you playback a video in a video player, you're not watching YUV directly, but a RGB converted representation. The YUV to RGB loss might be important if it was part of pipeline where you were doing other manipulations.
    Quote Quote  
  7. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post
    What other lossless image formats support YUV? Are they smaller than TIFF? I also want to upload the images.
    Upload images to a website, for a browser or mobile device(phone) for display ? Best bet is 8bit RGB, such as PNG (without gAMA or cHRM tags) , or webp

    AVIF and HEIF support YUV , but they have even lower compatibility


    Don't worry about the technical quality loss for 8bit RGB in your display scenario - When you "see" something on a monitor or TV it has been converted to RGB anyways - it's an RGB converted representation of that YUV data. If you playback a video in a video player, you're not watching YUV directly, but a RGB converted representation. The YUV to RGB loss might be important if it was part of pipeline where you were doing other manipulations.
    What about JPEG XL? How do I use ffmpeg to make those images?
    Quote Quote  
  8. Originally Posted by Jay123210599 View Post

    What about JPEG XL? How do I use ffmpeg to make those images?

    Not sure, I haven't used JPEGXL much or tested it in browsers for support


    For any ffmpeg codec, you can print the help file to a text file by using

    Code:
    ffmpeg -h encoder=blah 1>help.txt
    eg.

    Code:
    ffmpeg -h encoder=libjxl 1>libjxl.txt
    Encoder libjxl [libjxl JPEG XL]:
    General capabilities: threads
    Threading capabilities: other
    Supported pixel formats: rgb24 rgba rgb48le rgba64le gray ya8 gray16le ya16le grayf32le
    libjxl AVOptions:
    -effort <int> E..V....... Encoding effort (from 1 to 9) (default 7)
    -distance <float> E..V....... Maximum Butteraugli distance (quality setting, lower = better, zero = lossless, default 1.0) (from -1 to 15) (default -1)
    -modular <int> E..V....... Force modular mode (from 0 to 1) (default 0)
    The ffmpeg version supports 8 and 16bit RGB and grayscale, but not YUV directly


    If it was for a website, I would stick to PNG or webp

    Believe it or not, but many people in the world still use Windows XP (!) and legacy browsers . Some do not support webp properly. It's no good if people can't see your images. I'd use the highest compatibility format - PNG

    But PNG can be tricky, because of the cHRM and gAMA tags. If you use something like ffmpeg, and the input YUV video has colorimetry tags, the output PNG will be tagged cHRM and gAMA tags. The problem is different programs, browsers (or even versions of the same browser) can display colors differntly if they are color managed.

    But a non tagged "plain" sRGB PNG will almost always display the same in all programs. You can check PNGs with tweakpng

    You can check your workflow with known colors, such as colorbars or patterns
    Quote Quote  
  9. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post

    What about JPEG XL? How do I use ffmpeg to make those images?

    Not sure, I haven't used JPEGXL much or tested it in browsers for support


    For any ffmpeg codec, you can print the help file to a text file by using

    Code:
    ffmpeg -h encoder=blah 1>help.txt
    eg.

    Code:
    ffmpeg -h encoder=libjxl 1>libjxl.txt
    Encoder libjxl [libjxl JPEG XL]:
    General capabilities: threads
    Threading capabilities: other
    Supported pixel formats: rgb24 rgba rgb48le rgba64le gray ya8 gray16le ya16le grayf32le
    libjxl AVOptions:
    -effort <int> E..V....... Encoding effort (from 1 to 9) (default 7)
    -distance <float> E..V....... Maximum Butteraugli distance (quality setting, lower = better, zero = lossless, default 1.0) (from -1 to 15) (default -1)
    -modular <int> E..V....... Force modular mode (from 0 to 1) (default 0)
    The ffmpeg version supports 8 and 16bit RGB and grayscale, but not YUV directly


    If it was for a website, I would stick to PNG or webp

    Believe it or not, but many people in the world still use Windows XP (!) and legacy browsers . Some do not support webp properly. It's no good if people can't see your images. I'd use the highest compatibility format - PNG

    But PNG can be tricky, because of the cHRM and gAMA tags. If you use something like ffmpeg, and the input YUV video has colorimetry tags, the output PNG will be tagged cHRM and gAMA tags. The problem is different programs, browsers (or even versions of the same browser) can display colors differntly if they are color managed.

    But a non tagged "plain" sRGB PNG will almost always display the same in all programs. You can check PNGs with tweakpng

    You can check your workflow with known colors, such as colorbars or patterns
    How do I increase the compression rate to the maximum for png files to get the smallest file size without losing quality? Can I set the compression rate for gif/apng files too (since they require encoding anyway) and not get any visual quality loss?
    Quote Quote  
  10. Originally Posted by Jay123210599 View Post
    How do I increase the compression rate to the maximum for png files to get the smallest file size without losing quality?
    PNG is always lossless compression for 8bit or 16bit RGB - there is no lossy mode. But there can be display and handling problems (eg. the gAMA , cHRM tags above)

    Compression is generally a processing time vs. compression ratio trade off , with diminishing returns. At the highest compression ratios it might take a long time for a tiny reduction in filesize, it might not be worth it for most people

    For ffmpeg you can look at the help for the PNG options. The default is no prediction which is fairly fast in terms of PNG compression (PNG compression is slow overall, in general). Mixed prediction might be 3-4x slower but produce something 5-15% smaller in filesize.

    Beyond that, there is brute force methods that can reduce an existing png with high compression even farther, but they are very slow at the highest compression - such as optipng, pngcrush . It might take a few minutes per frame to shave off another 0 - 1% . Diminishing returns. Webp lossless will still beat it (but people using old OSes and browsers might not support webp)


    Can I set the compression rate for gif/apng files too (since they require encoding anyway) and not get any visual quality loss?

    GIF is always very lossy for most sources , because it only support 256 colors. 8bit RGB such as PNG supports ~16.3 million colors .

    There are GIF optimizers that produce large filesizes and better quality (compared to typical GIFS) and higher quality GIFs such as gifski .

    PNG optimizers were mentioned above; and for ffmpeg apng the prediction settings are in the help file (same as png)
    Quote Quote  
  11. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post
    How do I increase the compression rate to the maximum for png files to get the smallest file size without losing quality?
    PNG is always lossless compression for 8bit or 16bit RGB - there is no lossy mode. But there can be display and handling problems (eg. the gAMA , cHRM tags above)

    Compression is generally a processing time vs. compression ratio trade off , with diminishing returns. At the highest compression ratios it might take a long time for a tiny reduction in filesize, it might not be worth it for most people

    For ffmpeg you can look at the help for the PNG options. The default is no prediction which is fairly fast in terms of PNG compression (PNG compression is slow overall, in general). Mixed prediction might be 3-4x slower but produce something 5-15% smaller in filesize.

    Beyond that, there is brute force methods that can reduce an existing png with high compression even farther, but they are very slow at the highest compression - such as optipng, pngcrush . It might take a few minutes per frame to shave off another 0 - 1% . Diminishing returns. Webp lossless will still beat it (but people using old OSes and browsers might not support webp)


    Can I set the compression rate for gif/apng files too (since they require encoding anyway) and not get any visual quality loss?

    GIF is always very lossy for most sources , because it only support 256 colors. 8bit RGB such as PNG supports ~16.3 million colors .

    There are GIF optimizers that produce large filesizes and better quality (compared to typical GIFS) and higher quality GIFs such as gifski .

    PNG optimizers were mentioned above; and for ffmpeg apng the prediction settings are in the help file (same as png)
    By the way, I keep getting this for JXL. How do I fix that?
    Image
    [Attachment 76215 - Click to enlarge]
    Quote Quote  
  12. Originally Posted by Jay123210599 View Post

    By the way, I keep getting this for JXL. How do I fix that?
    Those are probably correct assumptions for a typical HD source

    Otherwise you probably need to set the primaries and transfer as mentioned earlier for YUV to RGB conversions

    It looks like you need browser addons for JPEGXL support (does not come by default) . Many people will not have this and will not be able to see your images - I would avoid JPEGXL too for that reason
    Quote Quote  
  13. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post

    By the way, I keep getting this for JXL. How do I fix that?
    Those are probably correct assumptions for a typical HD source

    Otherwise you probably need to set the primaries and transfer as mentioned earlier for YUV to RGB conversions

    It looks like you need browser addons for JPEGXL support (does not come by default) . Many people will not have this and will not be able to see your images - I would avoid JPEGXL too for that reason
    How do I convert jxl to png without changing the file size?
    Quote Quote  
  14. Originally Posted by Jay123210599 View Post

    How do I convert jxl to png without changing the file size?
    Not possible, for 8bit lossless RGB it will just increase in size . You're going from higher lossless compression ratio to lower lossless compression ratio
    Quote Quote  
  15. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post

    How do I convert jxl to png without changing the file size?
    Not possible, for 8bit RGB it will just increase in size
    How do I make png files in kbs (lower than 1 mb)?
    Quote Quote  
  16. Originally Posted by Jay123210599 View Post

    How do I make png files in kbs (lower than 1 mb)?
    Downscale to some lower resolution, or crop to a smaller area of interest if you're trying to show something specific


    Do you need "lossless" ? For web delivery often high quality lossy is enough . If you need a full quality version, post it on some file hosting site like google drive for download separately

    People will complain if it takes a few minutes to load your images and cause lag
    Quote Quote  
  17. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post

    How do I make png files in kbs (lower than 1 mb)?
    Downscale to some lower resolution, or crop to a smaller area of interest if you're trying to show something specific


    Do you need "lossless" ? For web delivery often high quality lossy is enough . If you need a full quality version, post it on some file hosting site like google drive for download separately

    People will complain if it takes a few minutes to load your images and cause lag
    How do I use PotPlayer and/or MPC-HC to make image sequences?
    Quote Quote  
  18. Originally Posted by Jay123210599 View Post
    How do I use PotPlayer and/or MPC-HC to make image sequences?
    There won't be any material difference than using ffmpeg or some other tool to make the image sequence
    Quote Quote  
  19. Banned
    Join Date
    Oct 2023
    Location
    Los Angeles
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Jay123210599 View Post
    How do I use PotPlayer and/or MPC-HC to make image sequences?
    There won't be any material difference than using ffmpeg or some other tool to make the image sequence
    No, but seriously, how do I do that?
    Quote Quote  
  20. potplayer has capture option under the video menu , capture consecutive images. There are BMP/PNG/jpeg options . Not sure about mpchc, maybe it can only do 1 frame at a time
    Quote Quote  



Similar Threads

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