Hi, If we try to extract audio from an .mp3 file starting from a point that is beyond its total duration with command: *./ffmpeg -ss 600 -i eye.mp3 -c:a libopus output.opus* We should hit this if statement in libavformat/seek.c: if (min_ts > ts || max_ts < ts) return -1; But if the file's metadata are corrupted then min_ts and max_ts will not be the correct ones. min_ts and max_ts take the values of the metadata durations of the file. By adding the following check, we make sure that we return an error even if the metadata is corrupted: if (ts > s->duration) { av_log(NULL, AV_LOG_ERROR, "Seek position (%d) is larger than file duration (%d). Exiting...\n", ts, s->duration); return AVERROR_INVALIDDATA; } This is my first patch submission. Please let me know if any modifications are needed. Thanks, bayesiandog