diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 5a35074c1c..86560d47fe 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -152,6 +152,7 @@ struct format_hack { bool no_pcm_seek : 1; bool no_seek_on_no_duration : 1; bool readall_on_no_streamseek : 1; + bool first_frame_only : 1; }; #define BLACKLIST(fmt) {fmt, .ignore = true} @@ -190,6 +191,10 @@ static const struct format_hack format_hacks[] = { // reset timestamps, which causes all sorts of problems. {"ogg", .linearize_audio_ts = true, .use_stream_ids = true}, + // Ignore additional metadata as frames from some single frame JPEGs + // (e.g. gain map) + {"jpeg_pipe", .first_frame_only = true}, + // At some point, FFmpeg lost the ability to read gif from unseekable // streams. {"gif", .readall_on_no_streamseek = true}, @@ -1255,8 +1260,8 @@ 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) { + // Never send additional frames for streams that are a single frame. + if (stream->image && priv->format_hack.first_frame_only && pkt->pos != 0) { av_packet_unref(pkt); return true; }