From 511498818f3372a911ca142ab25f59bbb10d7e3f Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 8 Apr 2011 02:47:02 +0300 Subject: [PATCH] demux_lavf: disable support for byte-based seeking libavformat returns nonsense per-stream bitrate values for some MPEG files (0 or many times higher than the overall bitrate of the file), which triggered the heuristic to enable byte-based seeking in demux_lavf and then made the byte-based seeks wildly inaccurate. Disable the support for byte-based seeks. This will avoid problems with files that have consistent timestamps, but on the other hand will completely break seeking in MPEG files that have timestamp resets. I'll probably add at least an option to manually enable byte-based seeking later. --- libmpdemux/demux_lavf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index ed8a3ddb69..3aca4b603c 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -615,6 +615,9 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){ demuxer->video->id=-2; // audio-only } //else if (best_video > 0 && demuxer->video->id == -1) demuxer->video->id = best_video; + // disabled because unreliable per-stream bitrate values returned + // by libavformat trigger this heuristic incorrectly and break things +#if 0 /* libavformat sets bitrate for mpeg based on pts at start and end * of file, which fails for files with pts resets. So calculate our * own bitrate estimate. */ @@ -630,6 +633,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){ if (!priv->bitrate) priv->bitrate = 1440000; } +#endif demuxer->accurate_seek = !priv->seek_by_bytes; return demuxer;