Upgrading Python, adding --quality command, use uv instead of pipenv, change Dockerfile slightly, update README.md with changes

This commit is contained in:
Amber McCloughan 2026-03-07 13:11:56 -05:00
parent d4573a72cb
commit 220e328da2
7 changed files with 30 additions and 18 deletions

1
.python-version Normal file
View File

@ -0,0 +1 @@
3.15

View File

@ -1,8 +1,8 @@
FROM python:3.13-slim-trixie FROM python:3.14-slim-trixie
VOLUME /home VOLUME /home
COPY video_to_gif.py /home/video_to_gif.py COPY video_to_gif.py pyproject.toml uv.lock .python-version /home/
WORKDIR /home WORKDIR /home
@ -13,6 +13,10 @@ RUN apt update -y && \
apt install curl -y && \ apt install curl -y && \
apt install build-essential -y apt install build-essential -y
RUN pip install --upgrade pip && \
pip install uv && \
uv sync
# https://stackoverflow.com/a/49676568 # https://stackoverflow.com/a/49676568
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}" ENV PATH="/root/.cargo/bin:${PATH}"
@ -20,4 +24,4 @@ ENV PATH="/root/.cargo/bin:${PATH}"
# https://crates.io/crates/gifski # https://crates.io/crates/gifski
RUN cargo install gifski RUN cargo install gifski
ENTRYPOINT ["python", "video_to_gif.py"] ENTRYPOINT ["uv", "run", "python", "video_to_gif.py"]

11
Pipfile
View File

@ -1,11 +0,0 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[requires]
python_version = "3.13"
[dev-packages]

View File

@ -1,7 +1,7 @@
# video-to-gif # video-to-gif
## video_to_gif.py usage ## video_to_gif.py usage
``` ```
usage: video_to_gif.py [-h] [-w WIDTH] [-r FRAMERATE] [-e] [--no_loop] [-t TAG] INPUT [INPUT ...] usage: video_to_gif.py [-h] [-w WIDTH] [-r FRAMERATE] [-q QUALITY] [-e] [--no_loop] [-t TAG] INPUT [INPUT ...]
Use ffmpeg and gifski to make GIFs from videos Use ffmpeg and gifski to make GIFs from videos
@ -13,6 +13,8 @@ options:
-w, --width WIDTH width of the GIF in pixels, respecting aspect ratio (default: 960) -w, --width WIDTH width of the GIF in pixels, respecting aspect ratio (default: 960)
-r, --framerate FRAMERATE -r, --framerate FRAMERATE
framerate of GIF (default: 12) framerate of GIF (default: 12)
-q, --quality QUALITY
lower values reduce file size; 100 automatically assigns --extra (default: 90)
-e, --extra increase quality at the expense of file size and encoding time -e, --extra increase quality at the expense of file size and encoding time
--no_loop don't loop the animated GIF --no_loop don't loop the animated GIF
-t, --tag TAG optional tag included in file name -t, --tag TAG optional tag included in file name

7
pyproject.toml Normal file
View File

@ -0,0 +1,7 @@
[project]
name = "video-to-gif"
version = "1.0.0"
description = "Use ffmpeg and gifski to make GIFs from videos"
readme = "README.md"
requires-python = ">=3.14"
dependencies = []

8
uv.lock generated Normal file
View File

@ -0,0 +1,8 @@
version = 1
revision = 3
requires-python = ">=3.14"
[[package]]
name = "video-to-gif"
version = "1.0.0"
source = { virtual = "." }

View File

@ -19,6 +19,8 @@ def get_args() -> Dict[str, Any]:
help='width of the GIF in pixels, respecting aspect ratio (default: 960)') help='width of the GIF in pixels, respecting aspect ratio (default: 960)')
parser.add_argument('-r', '--framerate', type=str, \ parser.add_argument('-r', '--framerate', type=str, \
default='12', help='framerate of GIF (default: 12)') default='12', help='framerate of GIF (default: 12)')
parser.add_argument('-q', '--quality', default='90', type=str, \
help='lower values reduce file size; 100 automatically assigns --extra (default: 90)')
parser.add_argument('-e', '--extra', default=False, action='store_true', \ parser.add_argument('-e', '--extra', default=False, action='store_true', \
help='increase quality at the expense of file size and encoding time') help='increase quality at the expense of file size and encoding time')
parser.add_argument('--no_loop', default=False, action='store_true', \ parser.add_argument('--no_loop', default=False, action='store_true', \
@ -54,10 +56,9 @@ def generate_gif_files(inputs: List[str], args: Dict[str, Any]) -> Dict[str, Tup
no_loop = args['no_loop'] no_loop = args['no_loop']
extra_cmd = '' extra_cmd = ''
quality = '90' quality = args['quality']
if extra: if quality == '100' or extra:
extra_cmd = '--extra' extra_cmd = '--extra'
quality = '100'
no_loop_cmd = '' no_loop_cmd = ''
if no_loop: no_loop_cmd = '--repeat -1' if no_loop: no_loop_cmd = '--repeat -1'