From 3d3d93b687820d52ff6ca87919bd8e80861f5f38 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sun, 2 Apr 2023 17:30:02 -0600 Subject: [PATCH] Move to alpine edge for ffmpeg 6 --- Dockerfile | 7 ++++--- cmd/webfs/main.go | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index da96329..d714da1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,14 @@ RUN go mod download -x COPY cmd ./cmd/ RUN go install ./... -FROM alpine AS runtime +FROM alpine:edge AS runtime WORKDIR /target COPY web web COPY --from=build /go/bin/ . -FROM alpine -RUN apk --no-cache add ffmpeg ffprobe +# Alpine edge has ffmpeg 6 with jpeg rotation bugfix +FROM alpine:edge +RUN apk --no-cache add ffmpeg COPY --from=runtime /target / WORKDIR /web ENTRYPOINT ["/webfs"] diff --git a/cmd/webfs/main.go b/cmd/webfs/main.go index dd47751..aaf1fbb 100644 --- a/cmd/webfs/main.go +++ b/cmd/webfs/main.go @@ -61,7 +61,8 @@ func (h *Handler) makeThumbnail(reqPath, thumbnailPath string) error { if err != nil { return err } - isVideo := ffdata.Format.DurationSeconds > 0.0 + isVideo := ffdata.Format.DurationSeconds > 1.0 + skipSeconds := ffdata.Format.StartTimeSeconds + (ffdata.Format.DurationSeconds * 0.25) // Build up ffmpeg invocation // XXX: some day soon you will want CommandContext @@ -70,19 +71,20 @@ func (h *Handler) makeThumbnail(reqPath, thumbnailPath string) error { cmd.Stderr = os.Stderr if isVideo { - skipSeconds := ffdata.Format.StartTimeSeconds + (ffdata.Format.DurationSeconds * 0.25) cmd.Args = append(cmd.Args, "-ss", fmt.Sprintf("%f", skipSeconds), "-i", srcPath, "-frames:v", "5", "-filter:v", h.filterVideo+",fps=2", "-loop", "0", + "-map_metadata", "0", thumbnailPath, ) } else { cmd.Args = append(cmd.Args, "-i", srcPath, "-filter:v", h.filterVideo, + "-map_metadata", "0", thumbnailPath, ) }