}
/* seek in the stream */
-static void stream_seek(VideoState *is, int64_t pos, int64_t rel)
+static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_bytes)
{
if (!is->seek_req) {
is->seek_pos = pos;
AVFormatParameters params, *ap = ¶ms;
int eof=0;
+ ic = avformat_alloc_context();
+
video_index = -1;
audio_index = -1;
subtitle_index = -1;
memset(ap, 0, sizeof(*ap));
+ ap->prealloced_context = 1;
ap->width = frame_width;
ap->height= frame_height;
ap->time_base= (AVRational){1, 25};
ap->pix_fmt = frame_pix_fmt;
+ set_context_opts(ic, avformat_opts, AV_OPT_FLAG_DECODING_PARAM);
+
err = av_open_input_file(&ic, is->filename, is->iformat, 0, ap);
if (err < 0) {
print_error(is->filename, err);
else
incr *= 180000.0;
pos += incr;
- stream_seek(cur_stream, pos, incr);
+ stream_seek(cur_stream, pos, incr, 1);
} else {
pos = get_master_clock(cur_stream);
pos += incr;
- stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE));
+ stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0);
}
}
break;
break;
case SDL_MOUSEBUTTONDOWN:
if (cur_stream) {
+ if(seek_by_bytes || cur_stream->ic->duration<=0){
+ uint64_t size= url_fsize(cur_stream->ic->pb);
+ stream_seek(cur_stream, size*(double)event.button.x/(double)cur_stream->width, 0, 1);
+ }else{
int64_t ts;
int ns, hh, mm, ss;
int tns, thh, tmm, tss;
ts = frac*cur_stream->ic->duration;
if (cur_stream->ic->start_time != AV_NOPTS_VALUE)
ts += cur_stream->ic->start_time;
- stream_seek(cur_stream, ts, 0);
+ stream_seek(cur_stream, ts, 0, 0);
+ }
}
break;
case SDL_VIDEORESIZE: