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

Convert mp4s to gifs for twitter using ffmpeg? #5613

Open
Azuriye opened this issue May 19, 2024 · 0 comments
Open

Convert mp4s to gifs for twitter using ffmpeg? #5613

Azuriye opened this issue May 19, 2024 · 0 comments

Comments

@Azuriye
Copy link

Azuriye commented May 19, 2024

Hello, I've already seen these two issues regarding the exact issue I am facing

#5043
#2691

But I am using ffmpeg with these queries to achieve a somewhat 1:1 recreation of how twitter displays gifs on their website.

Currently this is my config file

{
    "extractor": {
        "twitter": {
			"archive-prefix": "",
			"archive": "%APPDATA%/gallery-dl/archive.sqlite3",
			"archive-format": "{retweet_id|tweet_id}_{num}",
			"retries": 1,
			"retry-codes": [404, 429, 430],
			"conversations": "accessible",
			"retweets": "original",
			"replies": "self",
            "filename": "{date:%d.%m.%Y}.{retweet_id|tweet_id}_{num}.{extension}",
            "base-directory": "D:/TScrpImg/",
            "directory": ["{author[name]}.1"],
            "cookies": {
                "auth_token": ""
            }
        }
    },
	"output":
	{
		"mode": "auto",
		"progress": true,
		"shorten": true,
        "log": "[{name}][{levelname}] {message}",
        "logfile": {
            "path": "D:/Documents/gallery-dl/logfile.txt",
            "mode": "a",
            "format": {
                "debug"  : "[{asctime}][{levelname}] {message}",
                "info"   : "[{asctime}][{levelname}] {message}",
                "warning": "[{asctime}][{levelname}] {message} [Source URL: {extractor.url}]",
                "error"  : "[{asctime}][{levelname}] {message} [Source URL: {extractor.url}]"
            },
            "format-date": "%Y-%m-%dT%H:%M:%S",
            "level": "info"
        },
		"unsupportedfile": null
	}
}

I would like to run this ffmpeg command every time a gif image is found and store the gif extension instead of mp4 in archive.sqlite3 as well.

Currently I've found this ffmpeg command to work best when converting mp4s to gifs.

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

No branches or pull requests

1 participant