Fix playback with avi files missing PTS (#602)

This commit is contained in:
Zoe Roux 2024-08-22 17:43:18 +02:00 committed by GitHub
commit 4176bd0f0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 5 deletions

View File

@ -1,9 +1,9 @@
# FROM golang:1.22 as build
FROM debian:trixie-slim as build
FROM debian:trixie-slim AS build
# those were copied from https://github.com/docker-library/golang/blob/master/Dockerfile-linux.template
ENV GOTOOLCHAIN=local
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \

View File

@ -5,8 +5,8 @@
FROM debian:trixie-slim
# those were copied from https://github.com/docker-library/golang/blob/master/Dockerfile-linux.template
ENV GOTOOLCHAIN=local
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \

View File

@ -157,6 +157,8 @@ func getVideoKeyframes(path string, video_idx uint32, kf *Keyframe) error {
"-loglevel", "error",
"-select_streams", fmt.Sprintf("V:%d", video_idx),
"-show_entries", "packet=pts_time,flags",
// some avi files don't have pts, we use this to ask ffmpeg to generate them (it uses the dts under the hood)
"-fflags", "+genpts",
"-of", "csv=print_section=0",
path,
)

View File

@ -238,6 +238,11 @@ func (ts *Stream) run(start int32) error {
)
}
args = append(args,
// some avi files are missing pts, using this flag makes ffmpeg use dts as pts and prevents an error with
// -c:v copy. Only issue: pts is sometime wrong (+1fps than expected) and this leads to some clients refusing
// to play the file (they just switch back to the previous quality).
// since this is better than errorring or not supporting transmux at all, i'll keep it here for now.
"-fflags", "+genpts",
"-i", ts.file.Info.Path,
// this makes behaviors consistent between soft and hardware decodes.
// this also means that after a -ss 50, the output video will start at 50s