1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-01 04:12:25 +00:00

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.
This commit is contained in:
Dudemanguy 2024-06-13 13:23:35 -05:00
parent a900d41b1e
commit 4ef7931266

View File

@ -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