X Tutup
Skip to content

feat: add AV1/AVIF, WebP support for Images & Screen Recording (extends #7897)#8151

Open
cryptofyre wants to merge 17 commits intoShareX:developfrom
cryptofyre:develop
Open

feat: add AV1/AVIF, WebP support for Images & Screen Recording (extends #7897)#8151
cryptofyre wants to merge 17 commits intoShareX:developfrom
cryptofyre:develop

Conversation

@cryptofyre
Copy link

@cryptofyre cryptofyre commented Sep 19, 2025

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!)

  • Added WEBP and AVIF to the EImageFormat enum, and included their extensions in the ImageFileExtensions array in FileHelpers.cs to enable recognition and handling of these formats.
  • Updated IsImageMimeType logic and MIME type mappings to recognize image/webp and image/avif as valid image types.
  • Dynamic UI labeling - Changes "JPEG Quality" label to "Image Quality (IQ)" to better reflect AVIF's standardization naming.

Native Interop and Encoding/Decoding

  • Added P/Invoke bindings for libwebp.dll and avif.dll in NativeMethods.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

  • Introduced AVIF-specific enums (e.g., AvifPixelFormat, AvifRGBFormat, AvifResult, etc.) and constants in NativeEnums.cs and NativeConstants.cs to support detailed configuration and error handling for AVIF image processing.

AV1 Video Codec Support for Screen Recording

  • Enhanced video encoding quality settings with improved presets and configuration options for better screen recording quality across all codecs
  • Added comprehensive AV1 codec support to FFmpeg video encoding options:
    • Added software AV1 encoders: libaom-av1 and libsvtav1 with optimized presets
    • Added hardware-accelerated AV1 vendor-specific encoder support:
      • NVENC AV1 (av1_nvenc) for NVIDIA GPUs with Ada Lovelace architecture and newer
      • Intel QuickSync AV1 (av1_qsv) for supported Intel hardware
      • AMD AMF AV1 (av1_amf) for compatible AMD GPUs
    • Integrated AV1-specific encoding parameters including CPU usage settings, tile configurations, and quality modes
    • Added AV1 codec selection in video encoder dropdown menus across all supported encoders
    • Implemented AV1-optimized encoding arguments for screen recording scenarios with hardware acceleration support
  • Expanded codec compatibility to include AV1 alongside existing H.264, H.265, VP8, and VP9 options for comprehensive video format support with both software and hardware acceleration

Utility Methods

  • Added a helper method AvifDecoderGetImage in NativeMethods_Helpers.cs to safely extract the image pointer from an AVIF decoder instance, with error handling for struct layout mismatches.

Miscellaneous

  • Added a P/Invoke for CopyMemory from kernel32.dll to 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!

ooopus and others added 16 commits April 19, 2025 17:15
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.
@cryptofyre
Copy link
Author

Did notice a bug with the previewer where it cant read the image; Will look into it tomorrow.

@Mine181
Copy link

Mine181 commented Sep 19, 2025

Hey, would you be willing to add the tune iq option for avif?

@cryptofyre
Copy link
Author

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.
@cryptofyre
Copy link
Author

cryptofyre commented Sep 20, 2025

Did notice a bug with the previewer where it cant read the image; Will look into it tomorrow.

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.

@Mine181
Copy link

Mine181 commented Sep 20, 2025

What version of libaom is the avif part using? it would be nice if it's up to date
how about also adding a community fork alongside SVT? (SVT-AV1-HDR for example) especially since mainline has noticeable blocking on fast presets.

@koloved
Copy link

koloved commented Sep 30, 2025

waiting for the feature for 2 years, hope its not getting longer to get merged

@BrycensRanch
Copy link
Contributor

BrycensRanch commented Sep 30, 2025

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:

  • Where did you get the DLLs from?
  • Did you compile them on your local machine?
  • If so, what version of the libraries so others can verify these DLLs are safe?
  • They've all been scanned by Virustotal (all green for all of them); however, there are many questions about the authenticity of the DLLs.
  • They should be in the Libs folder.

args.Append($"-preset {FFmpeg.QSV_Preset} ");
args.Append($"-b:v {FFmpeg.QSV_Bitrate}k ");
break;
case FFmpegVideoCodec.av1_qsv:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing an option for AVIF. It supports animation too.

@NazmusSayad
Copy link

WebP for saving images will be cooool

@marioparaschiv
Copy link

Will this ever be merged? Seems like a no brainer.

@Knewest
Copy link

Knewest commented Dec 9, 2025

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.

@koloved
Copy link

koloved commented Dec 16, 2025

Guys, I got tired of waiting and made a build with this PR
Download build with this PR here

SVT AV1 video encoder, avif and webp screenshots not working, seems like something wrong with avif.dll and webp.dll idk

nvenc av1 is working for me
ShareX_m7mFpSNR4c

selected_image_5348458794722444465

@Lunascaped
Copy link

God I hope this gets merged I'm so sick of having to deal with gifs and their color banding

@Delphox
Copy link

Delphox commented Jan 24, 2026

@koloved I merged it on top of 19.0.1 and used the existing build workflow and everything seems to be working, its here if anyone needs.

@koloved
Copy link

koloved commented Jan 25, 2026

@Delphox avif screenshots is working for me now, thanks!

@jacklollz2
Copy link

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.

@BrycensRanch
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

X Tutup