[Libav-user] SEEK ISSUE
Yamusani Vinay
yamusanivinay at gmail.com
Tue Jan 21 08:11:53 CET 2014
Hi All,
Actually an android application for playing music I used ffmpeg.I am using
the following code for seeking the song in ffmpeg..
int defaultStreamIndex = av_find_default_stream_index(fmt_ctx);
int seekStreamIndex = (audio_stream_index != -1)? audio_stream_index :
defaultStreamIndex;
int64_t seekTime = av_rescale_q(seekValue*AV_TIME_BASE,
AV_TIME_BASE_Q,fmt_ctx->streams[seekStreamIndex]->time_base);
int64_t seekStreamDuration = fmt_ctx->streams[seekStreamIndex]->duration;
int flags = AVSEEK_FLAG_BACKWARD;
if (seekTime > 0 && seekTime < seekStreamDuration)
flags |= AVSEEK_FLAG_ANY;
int ret = av_seek_frame(fmt_ctx, seekStreamIndex, seekTime,flags);
if (ret < 0)
ret = av_seek_frame(fmt_ctx, seekStreamIndex, seekTime,AVSEEK_FLAG_ANY);
avcodec_flush_buffers(dec_ctx);
The length of the seek bar is total duration in milliseconds..for
ex:totalduration is 3:20
then seekbar length will be 200.
The above code is working for some of the songs..but for some songs If I
seek the song to for ex:3:00 or 2:40 then the song lasts for 3:50(actually
duration is 3:20).If I don't seek and play it normally it ends at correct
position.So please suggest me in solving this problem.
Thanks & Regards,
Bitfield.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20140121/131d752f/attachment.html>
More information about the Libav-user
mailing list