Upgrading Python, adding --quality command, use uv instead of pipenv, change Dockerfile slightly, update README.md with changes
This commit is contained in:
parent
d4573a72cb
commit
10899a30e8
1
.python-version
Normal file
1
.python-version
Normal file
@ -0,0 +1 @@
|
||||
3.15
|
||||
10
Dockerfile
10
Dockerfile
@ -1,8 +1,8 @@
|
||||
FROM python:3.13-slim-trixie
|
||||
FROM python:3.14-slim-trixie
|
||||
|
||||
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
|
||||
|
||||
@ -13,6 +13,10 @@ RUN apt update -y && \
|
||||
apt install curl -y && \
|
||||
apt install build-essential -y
|
||||
|
||||
RUN pip install --upgrade pip && \
|
||||
pip install uv && \
|
||||
uv sync --frozen --no-dev
|
||||
|
||||
# https://stackoverflow.com/a/49676568
|
||||
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
@ -20,4 +24,4 @@ ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
# https://crates.io/crates/gifski
|
||||
RUN cargo install gifski
|
||||
|
||||
ENTRYPOINT ["python", "video_to_gif.py"]
|
||||
ENTRYPOINT ["uv", "run", "python", "video_to_gif.py"]
|
||||
11
Pipfile
11
Pipfile
@ -1,11 +0,0 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.13"
|
||||
|
||||
[dev-packages]
|
||||
@ -1,7 +1,7 @@
|
||||
# video-to-gif
|
||||
## 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
|
||||
|
||||
@ -13,6 +13,8 @@ options:
|
||||
-w, --width WIDTH width of the GIF in pixels, respecting aspect ratio (default: 960)
|
||||
-r, --framerate FRAMERATE
|
||||
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
|
||||
--no_loop don't loop the animated GIF
|
||||
-t, --tag TAG optional tag included in file name
|
||||
|
||||
7
pyproject.toml
Normal file
7
pyproject.toml
Normal 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
8
uv.lock
generated
Normal file
@ -0,0 +1,8 @@
|
||||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.14"
|
||||
|
||||
[[package]]
|
||||
name = "video-to-gif"
|
||||
version = "1.0.0"
|
||||
source = { virtual = "." }
|
||||
@ -19,6 +19,8 @@ def get_args() -> Dict[str, Any]:
|
||||
help='width of the GIF in pixels, respecting aspect ratio (default: 960)')
|
||||
parser.add_argument('-r', '--framerate', type=str, \
|
||||
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', \
|
||||
help='increase quality at the expense of file size and encoding time')
|
||||
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']
|
||||
|
||||
extra_cmd = ''
|
||||
quality = '90'
|
||||
if extra:
|
||||
quality = args['quality']
|
||||
if quality == '100' or extra:
|
||||
extra_cmd = '--extra'
|
||||
quality = '100'
|
||||
|
||||
no_loop_cmd = ''
|
||||
if no_loop: no_loop_cmd = '--repeat -1'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user