From 4ef7931266759560a860e66e01b75622a0a3996b Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Thu, 13 Jun 2024 13:23:35 -0500 Subject: [PATCH] demux_lavf: drop jpeg frames that are at a nonzero pos There are jpg files out there that have extra embedded metadata (pictures from smartphones commonly have an embedded gain map). ffmpeg doesn't currently support this, so mpv currently sees the extra metadata as essentially another frame. This results in weird video-like behavior. Until ffmpeg support this more properly, we can work around this by simply discarding extra packets and not sending the new frame to the internal playloop. If demux_lavf detects that the stream is a single-frame jpg, then we only accepts the packet at pos 0. Anything else is discarded. Ref #13192. --- demux/demux_lavf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index d70cfd0040..442f5abcb6 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -1255,6 +1255,12 @@ static bool demux_lavf_read_packet(struct demuxer *demux, struct sh_stream *stream = info->sh; AVStream *st = priv->avfc->streams[pkt->stream_index]; + // Never send additional frames for streams that are a single frame jpeg. + if (stream->image && !strcmp(priv->avif->name, "jpeg_pipe") && pkt->pos != 0) { + av_packet_unref(pkt); + return true; + } + if (!demux_stream_is_selected(stream)) { av_packet_unref(pkt); return true; // don't signal EOF if skipping a packet