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

Ability to save gifs as .gif #1484

Open
chriseilander opened this issue Jan 8, 2016 · 62 comments
Open

Ability to save gifs as .gif #1484

chriseilander opened this issue Jan 8, 2016 · 62 comments

Comments

@chriseilander
Copy link

Great that Telegram now turns gifs in mp4's, they load faster. I really wished I could still save the original .gif though... Me and my friends loved to save them to our shared dropbox for easy use (even outside of Telegram).

@telegramdesktop
Copy link
Collaborator

@chriseilander Server does not save original gifs at all. Perhaps there could be a converter from mp4 to gif added to Telegram Desktop, but I don't think this will be done soon.

@ralesk
Copy link

ralesk commented Jan 11, 2016

Probably best to save the originals instead of converting back — though that might use a lot of space, not sure.

@telegramdesktop
Copy link
Collaborator

@ralesk The originals are not saved on the server, only the .mp4

@ralesk
Copy link

ralesk commented Jan 11, 2016

I read that, yes :) My comment says that maybe they should be, rather than to convert back on request.

@chriseilander
Copy link
Author

Converting back on request would be great. Now, when I right click on a "used to be gif but now mp4" it has an option saying "Save GIF" but as far as I know this doesn't do anything.

[edit]
I see they are now saved in the same place as emoji but since they aren't GIF's anymore, isn't this the wrong name for it?

@telegramdesktop
Copy link
Collaborator

@chriseilander It saves gif to a separate tab in stickers panel.

@mathifonseca
Copy link
Contributor

I also find this useful. Converting to MP4 makes the file great for in-app playback, but you should have the option to "export" it back to GIF to save it locally and share it to other apps. This could maybe be implemented by using an external tool like giflayer.com or similar.

@amiremami
Copy link

I came now to suggest a feature request about mp4 converter to gif, and I found this thread. So it would be great if you can add this converter. Because we want to save a lot of gifs but they are all in mp4. Thanks :)

@stek29
Copy link
Contributor

stek29 commented Apr 27, 2016

Telegram has beautiful bot platform for things like this one.

@ucay
Copy link

ucay commented May 4, 2016

what is the difference between sending gif as file and as photo ?
i tried both and got same result (coverted to mp4)
send as file should send original file format.

but, i think download as gif from mp4 is very cool

@chriseilander
Copy link
Author

@stek29 So I would send a .gif, telegram converts it to .mp4, and a bot would convert it back to .gif. Not really a good way to do things.

As @ucay suggested a way of sending the file should also matter. If I would send as a file it shouldn't change the fileformat. Or at least let us choose just like with photo's. I would be happy either way.

@ccrowles
Copy link

ccrowles commented Jul 9, 2016

I'd really love to be able to save my gifs as, well, gifs. Or at least have a bot to convert them. Sometimes I find I'd like to use on other social networks one of my telegram gifs, and I just can't.

@Cassolotl
Copy link

+1, I want to export my gifs as gifs!

@andlabs
Copy link

andlabs commented Oct 3, 2016

Even if we can't save GIFs as GIFs, I have two things to note:

  • The "Save GIF" menu option should at least be renamed to something more obvious, such as "Save GIF to Stickers"
  • On OS X, the file chooser still uses the .gif extension for the default filename, causing OS X to give a warning about incompatible file extensions; perhaps the file chooser should use a .mp4 extension for the default filename instead

This might at least make things less confusing.

@Draco18s
Copy link

I ended up here because on Desktop there is an option called "Save GIF"

It does nothing.

@john-preston
Copy link
Member

@Draco18s It saves gifs to a saved gifs tab in stickers panel.

@Draco18s
Copy link

@john-preston Ah, there they are. I even went looking for them when I saw the note to change the text to "save to stickers" and still couldn't find them. Rather than being where I expected (in the stickers list) it was in a semi-hidden "category" off where I'd mentally ignored the UI (because I give no foxes about popular sticker packs) that isn't accessible by scrolling.

@Nachtalb
Copy link

Nachtalb commented Oct 15, 2017

So will there ever be a function to save / download gifs as gifs on your file system and not to the gif tab in the sticker panel?

@Fabian42
Copy link

To everyone who is in favour of this feature request: Why do you want .gif files? They are the same as .mp4, but much bigger, because .gif wasn't developed as a video format. What advantage is there in having a .gif file compared to .mp4?

@Nachtalb
Copy link

Nachtalb commented Dec 26, 2018

@Fabian42

What advantage is there in having a .gif file compared to .mp4?

In my opinion it was a good choice of Telegram to use MP4's instead of GIFs. Because as you said it greatly decreases the file size, because not every frame is saved as an own image. But there is the problem. MP4s have more logic than GIFs behind them, which means GIFs are easier to display. That's why GIFs are much more common to be used on bulletin boards and other pages like 4chan. So it would be nice that we are able to save them as GIFs.

One further use case of GIFs is reverse search. You can't use most of reverse image search engines with videos. But almost all accept GIFs. Examples: Google, Yandex, Bing & IQDB

And for a more advanced use case. It is much easier (and faster) to edit or extract information of a GIF compared to other formats. Due to it being just a bunch of images in a sequence.

PS: even though I think it is a good way to use MP4s instead of GIFs in Telegram itself. The naming is to some extent misleading, because they are not actual GIFs.

@Draco18s
Copy link

What Nachtlab said.

Not to mention that if I save the file locally and try and open it, Windows opens mp4 as a video file (which does not loop automatically and I would not want my video player to remember to always loop due to other content that I would want to watch) while gifs open in the Photo Viewer (the same program every other image I view opens in) and loops automatically every time.

Also, Telegram is the only application that will embed and play an mp4 when it is posted. No other messaging or forum does this. Discord does not play mp4, no forum will let you use an img tag to link to an mp4, and you can't upload them to most image hosting websites (imgur I think is the only one).

Yes, the file size is smaller, and its fine for Telegram to use this format itself, but it's a right pain in the ass do deal with when trying to share it anywhere else.

@chriseilander
Copy link
Author

Like some other people say, mp4's are still recognized as mostly an video format, and because of that terrible to use anywhere else.

Even just opening a mp4 on your computer often fires up a big and slow mediaplayer, for just playing a 2 second video.

So an option to locally convert an mp4 to gif when wanting to save an animation would be great.

@waytootangled
Copy link

This is great and would be awesome. Is there any plan to do apply this functionality?

@mkg20001
Copy link

mkg20001 commented Jun 21, 2019

https://t.me/gif_export_bot should do just that
Because of a restriction that all .gif files are automatically converted to .mp4s, the resulting file will have a .gif_ file ending. Currently working on a fix.
Bot now offers URLs to download the file from, with a .gif ending. Storage is done entirely via telegram, so it's not a big deal for me.

@BasixKOR
Copy link

Hi, I was wondering if you could add this feature in Advanced -> Export Telegram data. Although I don't mind it's GIF or GIFV, I would be grateful for exporting all my GIFs stuck in Telegram.

@Nachtalb
Copy link

Nachtalb commented Jul 25, 2019

@BasixKOR

mind it's GIF or GIFV

GIFV is nothing but an MP4 or WEBM with a different extension name to inform the client it should be looped like a GIF so it wouldn't make much sense to save it as a GIFV. If you want a GIFV you can just use the normal MP4 that is downloaded and add .gifv.

But I don't think you should use it anyways because it is not widely used nor supported

@waytootangled
Copy link

waytootangled commented Jul 25, 2019 via email

@RememberTheAir
Copy link

RememberTheAir commented Jul 25, 2019

@waytootangled this is Telegram Desktop's github issues, you are receiving email notifications because you've contributed to it on May 3. The email itself you received told you that "you are receiving this because you commented", with a link to this issue. You can disable these emails from your GitHub's notifications preferences

@maxoku
Copy link

maxoku commented Jan 1, 2020

For opening files on computer maybe it could be saved with m4v extension by default instead of mp4 that should be reserved only for videos. The extension m4v is rather rarely used, so it can be associated with another application than video player like IrfanView. It for sure doesn't solve all problems, but would make it more comfortable to use on computers.

@Draco18s
Copy link

Draco18s commented Nov 2, 2020

If it doesn't work for all files, then its not really a solution.

@stale
Copy link

stale bot commented May 1, 2021

Hey there!

This issue was inactive for a long time and will be automatically closed in 30 days if there isn't any further activity. We therefore assume that the user has lost interest or resolved the problem on their own.

Don't worry though; if this is an error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

@stale stale bot added the stale label May 1, 2021
@Draco18s
Copy link

Draco18s commented May 1, 2021

This issue has not been addressed and is still an issue.

@stale stale bot removed the stale label May 1, 2021
@JohannesMP
Copy link

The issue has not been addressed and is still an issue.

1 similar comment
@mirodil1
Copy link

mirodil1 commented Jun 4, 2022

The issue has not been addressed and is still an issue.

@john-preston
Copy link
Member

@mirodil1 server provides .mp4 soundless videos, so saving those files to .gif can be done only by re-compressing. This is not planned.

@Draco18s
Copy link

@john-preston

server provides .mp4 soundless videos, so saving those files to .gif can be done only by re-compressing. This is not planned.

You know what would be really easy?
Adding an export option that would recompress the file, done entirely locally on the client.

Just because "its not planned" is not a reason why it can't be added to the plan.

@WebLeach
Copy link

For those who thinks telegram don't save gif file, here's a gift for you.
This was sent by my bot using pythin-telegram-bot
IMG_20221015_221842

@hyrious
Copy link

hyrious commented Dec 18, 2022

It's weird that "Save GIF" button does not do anything from my view.

In the end I made a tiny web app to convert mp4 to gif 😅 https://hyrious.me/tool/mp4-to-gif

@Bengerthelorf
Copy link

That's unbelievable that after over 7 years, it is still an issue. OMG 😰

@john-preston
Copy link
Member

@Bengerthelorf I doubt this will ever be implemented. When somebody sends a .gif the server usually auto-converts it to .mp4 and the app receives only .mp4, so for a .gif to be saved back it must be converted from .mp4 to .gif - this is a non-trivial thing to do and you won't get the original .gif file anyway, some similar one maybe. And due to amount of effort this requires I don't have any plans to implement that myself. If someone from the community needs this bad enough a PR can be reviewed.

@Draco18s
Copy link

@Bengerthelorf I doubt this will ever be implemented. When somebody sends a .gif the server usually auto-converts it to .mp4 and the app receives only .mp4, so for a .gif to be saved back it must be converted from .mp4 to .gif - this is a non-trivial thing to do and you won't get the original .gif file anyway, some similar one maybe. And due to amount of effort this requires I don't have any plans to implement that myself. If someone from the community needs this bad enough a PR can be reviewed.

Me, some time ago

You know what would be really easy? Adding an export option that would recompress the file, done entirely locally on the client.

Just because "its not planned" is not a reason why it can't be added to the plan.

@ilya-fedin
Copy link
Contributor

You know what would be really easy?

converted from .mp4 to .gif - this is a non-trivial thing to do

Just because "its not planned" is not a reason why it can't be added to the plan.

Being this non-trivial and definitely not easy is the reason.

@Draco18s
Copy link

Draco18s commented Apr 28, 2023

Being this non-trivial and definitely not easy is the reason.

So? There's plenty of existing converters, use one of them. Here, have an open source one. It took me less than 5 seconds to find. It's even cross-platform.

https://github.com/dudewheresmycode/giftuna (and it's licensed under CC0)

Both mp4 and gif are open formats, so I don't see what the issue is.

@ilya-fedin
Copy link
Contributor

There's plenty of existing converters, use one of them.

You probably misunderstand how it works. One application doesn't use other application to convert media data. It's done through libraries. tdesktop uses ffmpeg, a low-level library, so it has to implement a lot of code on top of it to be able to convert media data.

@Draco18s
Copy link

Uh huh. I know its done via libraries. Adding a library to a project and going "has someone built an implementation layer on top of this library in before? Let me ask google" and you can almost certainly find one. Hell, I wrote a C# api layer for Novel AI without any documentation and was still able to find a prior existing attempt in another language to crib from. The "actually hard part" was dissecting the authentication and encryption mess, which mostly involved me (1) having the correct Sodium library (2) calling the right methods with the right parameters (there were differences between the JS library and the C#).

Hell, I even figured out some things the other guy hadn't and let him know about what I'd found.

One application doesn't use other application to convert media data.

But... like... you could though... nothing stops an application from executing another application. The only requirement is that you can ship that other application with your own and what's this? GifTuna is open source CC0? Why, you could compile and ship that... Why, you could actually clone the GifTuna repo to a local temp directory and run that. 😲

What's this? ffmpeg has command line support? We don't even need GifTuna! We can just invoke ffmpeg console commands inside Telegram!

@ilya-fedin
Copy link
Contributor

nothing stops an application from executing another application.

It's considered a bad practice. Moreover, tdesktop likes to be a single binary application.

@Draco18s
Copy link

Nice goal post moving. 😎

And sure, it does like to be, and you already said that ffmpeg is already being used by telegram desktop, which means the solution is literally right there and all you have to do is tell it to do a slightly different thing than its already doing.

What's why libraries exist: the library is the hard part. The "a lot of code on top" is like, nothing, in comparison; in this case literally one or two lines to tell ffmpeg "hey here's an mp4, I want a gif plz" which is just the reverse of what the program is already doing when you send a gif.

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Apr 28, 2023

and you can almost certainly find one

I'm not really sure that covers ffmpeg. The only I can remember is QtAV which is deprecated in the sake of proprietary library. There are also things like libvlc and libmpv which don't use ffmpeg (they're built on top of codec libraries themselves, so more like an analogue to ffmpeg) but have more higher level API, the problem with them is they don't support MSVC. There's also QtMultimedia that sadly uses the concept of using system codecs (while tdesktop likes to not to depend on them) until Qt 6.5 and tdesktop still uses Qt 5 on Windows.

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Apr 28, 2023

Although I'm not sure any of those libraries support conversion, I believe they support only playback.

@ilya-fedin
Copy link
Contributor

which means the solution is literally right there and all you have to do is tell it to do a slightly different thing than its already doing.

That's really hard. Just look at ffmpeg API documentation.

@Draco18s
Copy link

Let me ask google... annnd....

ffmpeg -ss 30 -t 3 -i input.mp4 \
    -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
    -loop 0 output.gif

Done

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Apr 28, 2023

in this case literally one or two lines to tell ffmpeg "hey here's an mp4, I want a gif plz" which is just the reverse of what the program is already doing when you send a gif.

Oh lol, it's definitely not like you think it is. The code implementing the player on top of ffmpeg APIs consists of a few dozens of files and a few hundreds (if not a thousand) of lines of code.

@ilya-fedin
Copy link
Contributor

Let me ask google... annnd....

It's ffmpeg program. It's not library API.

@ilya-fedin
Copy link
Contributor

Here's the code implementing audio capture. It gets the raw audio data with OpenAL and encodes into Opus with ffmpeg (libavcodec): https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/SourceFiles/media/audio/media_audio_capture.cpp. As you can see, most of the code is the ffmpeg part and the file is of ~800 lines of code. It also uses various helper functions from other files, if counting them all, it would be way more. It's just audio, just encoding. You would have first to demux audio+video from container, then decode them, then encode them again and mux into a different container (which is the image one, not even the video one!). That would be WAY more lines of code and multiple times harder.

@ItzAmirreza
Copy link

Still, an issue, + the files are big after saving. needs a compressor as well

@vintdime
Copy link

We are still waiting

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

No branches or pull requests