[FFmpeg-devel] [PATCH] seeking in asf files where audio stream is found before video
Michael Niedermayer
michaelni
Sat Jul 14 21:58:36 CEST 2007
Hi
On Sun, Jul 08, 2007 at 12:00:10AM +0200, elupus wrote:
> Hi,
>
> Currently asf demuxer reads the index provided in the file on first seek
> and adds it to the stream that the seek occured in. Any seeks on other
> streams in the file will then not use the provided index.
>
> This turns out to be an issue since av_find_stream_info will seek to pts 0
> for all available streams, if audio is found first, then index get's loaded
> on the audio stream. When a seek is tried later, the default stream seeked
> is the video stream wich doesn't have an index loaded.
>
> If an asf stream doesn't have a index, it defaults to binary seek, wich
> will then add some index points to the stream, on the next seek those will
> be used without interpolation.
>
> This patch changes the demuxer to only load index for the video stream, and
this is just wrong
> fall back to the general seeks in utils.c if its internal seek doesn't work.
good but why does this make a difference? it shouldnt, its a welcome cleanup
but i dont see how this would change anything
>
> Sadly seem to be a bug in av_gen_search, wich happens to search the whole
> damn file when av_find_stream_info tries to seeks to pts 0, so there is
> also a hack in this patch to handle seeks to time 0.
>
> On another note, shouldn't the demuxer set AVFormatContext->data_offset
> instead of just setting data_offset in ASFContext? If so i can provide a
> patch for that.
maybe
[...]
> Index: asf.c
> ===================================================================
> --- asf.c (revision 9451)
> +++ asf.c (working copy)
> @@ -989,6 +989,9 @@
> }
> asf->index_read= 1;
> }
> + else
> + asf->index_read= -1;
> +
> url_fseek(&s->pb, current_pos, SEEK_SET);
> }
ok but this belongs into a seperate patch with the related changes and
the } and else should be on the same line
> @@ -999,15 +1002,24 @@
> int64_t pos;
> int index;
>
> + if (pts == 0) {
> + // this is a hack since av_gen_search searches the entire file in this case
> + av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
> + url_fseek(&s->pb, s->data_offset, SEEK_SET);
> + return 0;
> + }
> +
indention is wrong and there is trailing whitespace
> if (asf->packet_size <= 0)
> return -1;
>
> + if (st->codec->codec_type != CODEC_TYPE_VIDEO)
> + return -1;
> +
why should we fail on all non video streams this is just a ugly
hack
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070714/c53c0b3e/attachment.pgp>
More information about the ffmpeg-devel
mailing list