Skip to content

Commit

Permalink
demux_lavf: drop jpeg frames that are at a nonzero pos
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dudemanguy committed Jun 13, 2024
1 parent a900d41 commit 4ef7931
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions demux/demux_lavf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ef7931

Please sign in to comment.