Version 1
This commit is contained in:
55
README.md
Normal file
55
README.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# GIF to WebM Converter
|
||||||
|
|
||||||
|
This script converts an animated GIF into a WebM format that's fully compatable with telegram animated stickers with options to adjust the playback speed (max allowed telegram animated sticker lenght is 3s).
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Converts GIF files into transparent WebM animations.
|
||||||
|
- Adjustable speed for the output animation.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- **ffmpeg**
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Don't forget to `chmod +x` it
|
||||||
|
|
||||||
|
### Command Syntax
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./gif2webm.sh input.gif [speedup_factor]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
- `input.gif`: The path to the input GIF file you want to convert.
|
||||||
|
- `[speedup_factor]`: (Optional) A factor to speed up the animation. Default is `1` (no speedup).
|
||||||
|
|
||||||
|
### Help
|
||||||
|
|
||||||
|
To display help information, run:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./gif2webm.sh --h
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
1. **Convert a GIF without speedup**:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./gif2webm.sh input.gif
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Convert with a specified speedup factor**:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./gif2webm.sh input.gif 0.5
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Display usage information**:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./gif2webm.sh --h
|
||||||
|
```
|
||||||
28
gif2webm.sh
Executable file
28
gif2webm.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Display usage information when requested or when no arguments are provided
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 input.gif [speedup_factor]"
|
||||||
|
echo " speedup_factor: Factor by which to speed up the animation (default is 1)."
|
||||||
|
echo " -h or --h: Display this help message."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if help is requested
|
||||||
|
if [[ $1 == "-h" || $1 == "--h" ]]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validate parameters
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
input_file="$1"
|
||||||
|
speedup="${2:-1}" # Default to 1 if not provided
|
||||||
|
output_file="${input_file%.gif}.webm"
|
||||||
|
|
||||||
|
# Run ffmpeg command with the specified parameters
|
||||||
|
ffmpeg -i "$input_file" -vf "scale=512:512:force_original_aspect_ratio=decrease,fps=30,setpts=${speedup}*PTS" -pix_fmt yuva420p -b:v 512k "$output_file"
|
||||||
|
|
||||||
|
echo "Converted $input_file to $output_file with a speedup factor of $speedup."
|
||||||
Reference in New Issue
Block a user