Skip to content

Convert mp4s to gifs for twitter using ffmpeg? #5613

Closed
@Azuriye

Description

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions