Move to alpine edge for ffmpeg 6

This commit is contained in:
Neale Pickett 2023-04-02 17:30:02 -06:00
parent bf3bd35fdb
commit 3d3d93b687
2 changed files with 8 additions and 5 deletions

View File

@ -5,13 +5,14 @@ RUN go mod download -x
COPY cmd ./cmd/ COPY cmd ./cmd/
RUN go install ./... RUN go install ./...
FROM alpine AS runtime FROM alpine:edge AS runtime
WORKDIR /target WORKDIR /target
COPY web web COPY web web
COPY --from=build /go/bin/ . COPY --from=build /go/bin/ .
FROM alpine # Alpine edge has ffmpeg 6 with jpeg rotation bugfix
RUN apk --no-cache add ffmpeg ffprobe FROM alpine:edge
RUN apk --no-cache add ffmpeg
COPY --from=runtime /target / COPY --from=runtime /target /
WORKDIR /web WORKDIR /web
ENTRYPOINT ["/webfs"] ENTRYPOINT ["/webfs"]

View File

@ -61,7 +61,8 @@ func (h *Handler) makeThumbnail(reqPath, thumbnailPath string) error {
if err != nil { if err != nil {
return err 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 // Build up ffmpeg invocation
// XXX: some day soon you will want CommandContext // XXX: some day soon you will want CommandContext
@ -70,19 +71,20 @@ func (h *Handler) makeThumbnail(reqPath, thumbnailPath string) error {
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
if isVideo { if isVideo {
skipSeconds := ffdata.Format.StartTimeSeconds + (ffdata.Format.DurationSeconds * 0.25)
cmd.Args = append(cmd.Args, cmd.Args = append(cmd.Args,
"-ss", fmt.Sprintf("%f", skipSeconds), "-ss", fmt.Sprintf("%f", skipSeconds),
"-i", srcPath, "-i", srcPath,
"-frames:v", "5", "-frames:v", "5",
"-filter:v", h.filterVideo+",fps=2", "-filter:v", h.filterVideo+",fps=2",
"-loop", "0", "-loop", "0",
"-map_metadata", "0",
thumbnailPath, thumbnailPath,
) )
} else { } else {
cmd.Args = append(cmd.Args, cmd.Args = append(cmd.Args,
"-i", srcPath, "-i", srcPath,
"-filter:v", h.filterVideo, "-filter:v", h.filterVideo,
"-map_metadata", "0",
thumbnailPath, thumbnailPath,
) )
} }