Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress video, images and audio before sending #14047

Open
Tesla2k opened this issue Jun 15, 2020 · 11 comments
Open

Compress video, images and audio before sending #14047

Tesla2k opened this issue Jun 15, 2020 · 11 comments
Labels
A-File-Upload Attachments and file uploads A-Media O-Occasional Affects or can be seen by some users regularly or most users rarely T-Enhancement

Comments

@Tesla2k
Copy link

Tesla2k commented Jun 15, 2020

Users expect to be able to just drop a video in the chat and it gets send. Often this videos are to big and so they need to be recompressed.

It would be nice if there would be a message which let you choose to recompress the video at different quality levels (with a hint how large they will be) and also without recompression.
For Images there should be the same options when the image size exceeds a certain size.
Same goes for audio.

I think this is absolutely needed in all Matrix clients.

@t3chguy
Copy link
Member

t3chguy commented Jun 15, 2020

This is hard to implement on a web client for things other than images. For images it is easy using browser canvases but for Audio/Video it would mean importing very large libraries if at all possible for more than a couple of file types.

Images are already tracked in #4144

https://stackoverflow.com/questions/9635835/solutions-to-compress-audio-in-browser
Makes only one valid Suggestion for Audio which hasn't been updated in 6 years: https://github.com/jpemartins/speex.js

Cannot even find such a library for Video.

@Tesla2k
Copy link
Author

Tesla2k commented Jul 16, 2020

What about the desktop client? As far as I know it is just the web client with electron. But maybe there it should be easier to add.
I can not find a issue tracker for it that's why I posted it here.

@t3chguy
Copy link
Member

t3chguy commented Jul 16, 2020

Sure, it'd be more reasonable to add to the desktop client given that ability for native extensions. Could add an FFmpeg dependency or whatever

@aaronraimist aaronraimist added the A-File-Upload Attachments and file uploads label Jul 19, 2020
@flackr
Copy link

flackr commented Jul 27, 2020

FWIW, ffmpeg has been compiled to wasm: https://github.com/ffmpegwasm/ffmpeg.wasm

@t3chguy
Copy link
Member

t3chguy commented Jul 27, 2020

Lacks Safari and Firefox support seemingly according to the readme

@progserega
Copy link

Also, when resize image - please, save exif information (date of photo, geo-tags and etc.).

@Flam3z
Copy link

Flam3z commented Dec 14, 2021

Has there been any internal progress on this feature?

@thany
Copy link

thany commented Jul 5, 2022

Just noticed that for uploading an avatar, it supports a whole boatload of file formats. Including WebP. So modern file formats are absolutely supported, at least in "some" way.

Lacks Safari and Firefox support seemingly according to the readme

Then don't do it on those browsers? I don't see why you'd wait for that.

But also, there's some work done (or being done) on getting libvips to compile to WA so it doesn't need to only work in the desktop app.

Speaking of which, on the desktop app you could just include Sharp as it is today, and immediately start converting whatever image data to WebP. That way, you'll fix the problem for everybody that uses the desktop app (no idea how many % users that is, do we know this?)

@flackr
Copy link

flackr commented Jul 5, 2022

Lacks Safari and Firefox support seemingly according to the readme

I'm assuming this was due to the wasm port using SharedArrayBuffer? Support is much better these days :-) https://caniuse.com/sharedarraybuffer

But even if videos wouldn't work, I think even image compression would be quite useful. libSquoosh even goes as far as supporting many modern formats and parameters locally (in the client browser).

@SimonBrandner SimonBrandner added O-Occasional Affects or can be seen by some users regularly or most users rarely A-Media labels Jul 6, 2022
@vladh
Copy link

vladh commented Aug 31, 2022

Is there currently any kind of way to have Element compress images before sending them? If not, is there an alternative way to do this, e.g. on the server?

@thany
Copy link

thany commented Sep 1, 2022

@vladh Element on the desktop can already implement this perfectly fine. As it runs on Electron, by extension it must also run Node.js in the background, and therefor Sharp can be implemented without too much effort, I reckon.

The tricky bit is the web client. The good thing, at least in my mind, is there is no law that says the web client and desktop client have to be identical. The problem is purely in compressing images to a modern format. Displaying such images has been possible for years on every browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-File-Upload Attachments and file uploads A-Media O-Occasional Affects or can be seen by some users regularly or most users rarely T-Enhancement
Projects
None yet
Development

No branches or pull requests

9 participants