mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
Fix seeking by bytes with the mouse and do so by default if the duration is
nonsense. Originally committed as revision 21563 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
c55806e3a2
commit
2ef4605373
13
ffplay.c
13
ffplay.c
@ -971,7 +971,7 @@ static double get_master_clock(VideoState *is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* seek in the stream */
|
/* 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) {
|
if (!is->seek_req) {
|
||||||
is->seek_pos = pos;
|
is->seek_pos = pos;
|
||||||
@ -2319,11 +2319,11 @@ static void event_loop(void)
|
|||||||
else
|
else
|
||||||
incr *= 180000.0;
|
incr *= 180000.0;
|
||||||
pos += incr;
|
pos += incr;
|
||||||
stream_seek(cur_stream, pos, incr);
|
stream_seek(cur_stream, pos, incr, 1);
|
||||||
} else {
|
} else {
|
||||||
pos = get_master_clock(cur_stream);
|
pos = get_master_clock(cur_stream);
|
||||||
pos += incr;
|
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;
|
||||||
@ -2333,6 +2333,10 @@ static void event_loop(void)
|
|||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
if (cur_stream) {
|
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;
|
int64_t ts;
|
||||||
int ns, hh, mm, ss;
|
int ns, hh, mm, ss;
|
||||||
int tns, thh, tmm, tss;
|
int tns, thh, tmm, tss;
|
||||||
@ -2350,7 +2354,8 @@ static void event_loop(void)
|
|||||||
ts = frac*cur_stream->ic->duration;
|
ts = frac*cur_stream->ic->duration;
|
||||||
if (cur_stream->ic->start_time != AV_NOPTS_VALUE)
|
if (cur_stream->ic->start_time != AV_NOPTS_VALUE)
|
||||||
ts += cur_stream->ic->start_time;
|
ts += cur_stream->ic->start_time;
|
||||||
stream_seek(cur_stream, ts, 0);
|
stream_seek(cur_stream, ts, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_VIDEORESIZE:
|
case SDL_VIDEORESIZE:
|
||||||
|
Loading…
Reference in New Issue
Block a user