feat: add AV1/AVIF, WebP support for Images & Screen Recording (extends #7897)#8151
feat: add AV1/AVIF, WebP support for Images & Screen Recording (extends #7897)#8151cryptofyre wants to merge 17 commits intoShareX:developfrom
Conversation
Add WebP image format support by integrating libwebp.dll and related libraries. This includes adding WebP to the list of supported image formats, updating file dialogs, and implementing encoding/decoding functionality using native methods. The changes enable the application to handle WebP images for both loading and saving operations.
This commit introduces support for the AVIF image format, including encoding, decoding, and integration into the existing image handling system. The changes include: - Adding AVIF to the list of supported image formats in Enums.cs, FileHelpers.cs, and MimeTypes.cs. - Implementing AVIF encoding and decoding in ImageHelpers.cs. - Updating the project file to include the avif.dll and remove unused WebP decoder libraries. - Adding necessary native methods, constants, and structures for AVIF handling in NativeMethods.cs, NativeConstants.cs, NativeEnums.cs, and NativeStructs.cs. - Refactoring the SaveImageAsStream method in TaskHelpers.cs to support AVIF encoding. The addition of AVIF support enhances the application's ability to handle modern image formats, providing better compression efficiency and quality compared to traditional formats like JPEG and PNG.
Remove unused `System.Runtime.InteropServices` import from `TaskHelpers.cs` to clean up the code. Fix logical error in `MimeTypes.cs` by correctly grouping conditions for image mime type validation.
- Implemented dynamic label updates for image quality based on selected format in TaskSettingsForm. - Added new AV1 codec options (av1_nvenc, av1_amf, av1_qsv, av1_svt, av1_libaom, av1_rav1e) in Enums.cs and updated VideoConverterOptions to handle these codecs. - Updated VideoConverterForm to reflect changes in AV1 codec handling and quality settings.
- Introduced new AV1 codec options (libsvtav1, libaom_av1, librav1e) in Enums.cs. - Updated FFmpegOptionsForm to handle AV1 codecs in the video codec selection. - Enhanced FFmpegOptions to generate appropriate arguments for AV1 encoding with NVENC, AMF, and QSV. - Ensured compatibility for AV1 codecs in the screen recording options.
|
Did notice a bug with the previewer where it cant read the image; Will look into it tomorrow. |
|
Hey, would you be willing to add the tune iq option for avif? |
|
Sure that's doable, ill throw it in with the rest of my fixes later today. |
- Introduced a new enum `AvifTuneIQ` to specify tuning options for AVIF encoding. - Updated `SaveImageAsStream` and related methods to accept and utilize the `AvifTuneIQ` parameter. - Enhanced the `TaskSettings` to include AVIF tuning settings in the UI. - Modified the `TaskSettingsForm` to allow users to select AVIF tuning options, improving image quality control during AVIF encoding.
Looking closer at this, i'm unsure about the best way to go about this without going about a full rework for per codec basis; Maybe as a patch we could just open it in the users specified photo app and hide options for beautification and what not? Ultimately up to the maintainers to decide on this one. |
|
What version of libaom is the avif part using? it would be nice if it's up to date |
|
waiting for the feature for 2 years, hope its not getting longer to get merged |
|
Hi, I am curious about the DLLs in this pull request. I recognize that there's no NuGet package for libavif and the like. However, I must ask:
|
| args.Append($"-preset {FFmpeg.QSV_Preset} "); | ||
| args.Append($"-b:v {FFmpeg.QSV_Bitrate}k "); | ||
| break; | ||
| case FFmpegVideoCodec.av1_qsv: |
There was a problem hiding this comment.
Missing an option for AVIF. It supports animation too.
|
WebP for saving images will be cooool |
|
Will this ever be merged? Seems like a no brainer. |
|
8 month ago, I was like, "Finally, the wait is ending after years active issue discussions requesting native support" and happy that I can finally just install ShareX on any device and have WebP work. Now? I'm realising that if even open-source can't achieve modern codec support, then it is no wonder the industy is the way it is. It isn't as if he isn't aware this exists. I've tried so many different software for screenshotting, but nothing ever came close to ShareX, which is disappointing because the codec support has always been restricted seemingly just because. I was 13 when WebP was first requested, and I was 14 when the maintainer for this project last entertained the idea of adding WebP support. I am turning 22 in ~50 days. I get it, it's open-source, and nobody should ever feel entitled to feature requests-- this isn't how I feel, though. Going back to when I first began requesting WebP in March of 2023, I have never felt that way. I've always just expected ShareX to take the lead like they always have been. There have been several issues opened exclusively requesting just WebP (#765, #1529, #3656, #5250, #6090), and I fear that #8151 is just going to be delegated as a nuisance and ignored, too. This project gets updates only ever 6-12 months now, which is already really good for a long standing project, but each update I am dejected that this feature was once again ignored for another 6-12 months despite seemingly being ready to implement. From what I can find, the last time the maintainer ever directly addressed the prospect of adding WebP was in 2016, after which he has insisted twice to just use 'Actions', which is actually all the times he has since acknowledged WebP being in demand till very recently just to mention 'Actions' again in response to somebody suggesting 'Actions'. I don't understand the lack of initiative to just even comment on the idea that clearly has a lot of attention, and now even an entire pull request for. I can't stress enough that #6090 has been active for years, and during all that time, the maintainer has not acknowledged it. I joked about how WebP will only be added when JPEG XL becomes widely supported, and I've since seen somebody joking about how this is exactly the same as the 7-Zip developers refusing to add dark-mode. I feel like it isn't gonna be a joke for very long, and the latter pretty much already isn't. Basically, my point in typing all of this isn't to put pressure on this feature request, but to just ask for at least a comment regarding it. I've been actively following this for almost four years of my life, surely there has got to be something to say about this feature request that isn't pointing me towards the 'Actions' feature that doesn't even properly support clip-boarding without locally saving the image. 😞 I've tried my best to not have my intentions misconstrued, so I hope my perspective can be understood. |
|
Guys, I got tired of waiting and made a build with this PR SVT AV1 video encoder, avif and webp screenshots not working, seems like something wrong with avif.dll and webp.dll idk |
|
God I hope this gets merged I'm so sick of having to deal with gifs and their color banding |
|
@Delphox avif screenshots is working for me now, thanks! |
|
I knew it. Even when the community would make the feature, the suborn dev would not merge the PR. Dev is an old man yelling at clouds. Time to abandon ShareX. |
This is not an airport; there is no need to announce your departure. |


This pull request implements comprehensive AV1 codec support across ShareX's media handling capabilities. It adds AVIF and WebP image format support with native encoding/decoding, and introduces full AV1 video codec support for screen recording with both software and hardware-accelerated encoding options.
All of the AVIF/WebP work was done by @ooopus and not by myself; This is simply an extension of the PR at #7897 on the topic of AV1 as a codec (as AVIF is an extension of AV1 lol)
Image Format Support (thanks @ooopus!)
WEBPandAVIFto theEImageFormatenum, and included their extensions in theImageFileExtensionsarray inFileHelpers.csto enable recognition and handling of these formats.IsImageMimeTypelogic and MIME type mappings to recognizeimage/webpandimage/avifas valid image types.Native Interop and Encoding/Decoding
libwebp.dllandavif.dllinNativeMethods.cs, enabling encoding, decoding, and memory management for WebP and AVIF images. This includes methods for creating encoders/decoders, converting between color formats, and managing image data.AVIF-Specific Structures and Constants
AvifPixelFormat,AvifRGBFormat,AvifResult, etc.) and constants inNativeEnums.csandNativeConstants.csto support detailed configuration and error handling for AVIF image processing.AV1 Video Codec Support for Screen Recording
libaom-av1andlibsvtav1with optimized presetsav1_nvenc) for NVIDIA GPUs with Ada Lovelace architecture and newerav1_qsv) for supported Intel hardwareav1_amf) for compatible AMD GPUsUtility Methods
AvifDecoderGetImageinNativeMethods_Helpers.csto safely extract the image pointer from an AVIF decoder instance, with error handling for struct layout mismatches.Miscellaneous
CopyMemoryfromkernel32.dllto facilitate low-level memory operations, which may be used in image processing routines.Apologies in advance for copilots attempt at writing this PR description, but hey it's better than an empty one!