mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
add "seek by bytes" support to ffplay
Patch by Steve Lhomme % slhomme A divxcorp P com % Orginal thread: Date: Nov 6, 2006 5:58 PM Subject: Re: [Ffmpeg-devel] [Bad news]: MPEG Seek has failed to work in FFmpeg SVN Originally committed as revision 6937 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
1d1be919ce
commit
94b594c68a
20
ffplay.c
20
ffplay.c
@ -192,6 +192,7 @@ static int screen_width = 640;
|
|||||||
static int screen_height = 480;
|
static int screen_height = 480;
|
||||||
static int audio_disable;
|
static int audio_disable;
|
||||||
static int video_disable;
|
static int video_disable;
|
||||||
|
static int seek_by_bytes;
|
||||||
static int display_disable;
|
static int display_disable;
|
||||||
static int show_status;
|
static int show_status;
|
||||||
static int av_sync_type = AV_SYNC_AUDIO_MASTER;
|
static int av_sync_type = AV_SYNC_AUDIO_MASTER;
|
||||||
@ -918,6 +919,8 @@ static void stream_seek(VideoState *is, int64_t pos, int rel)
|
|||||||
if (!is->seek_req) {
|
if (!is->seek_req) {
|
||||||
is->seek_pos = pos;
|
is->seek_pos = pos;
|
||||||
is->seek_flags = rel < 0 ? AVSEEK_FLAG_BACKWARD : 0;
|
is->seek_flags = rel < 0 ? AVSEEK_FLAG_BACKWARD : 0;
|
||||||
|
if (seek_by_bytes)
|
||||||
|
is->seek_flags |= AVSEEK_FLAG_BYTE;
|
||||||
is->seek_req = 1;
|
is->seek_req = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2222,9 +2225,19 @@ static void event_loop(void)
|
|||||||
incr = -60.0;
|
incr = -60.0;
|
||||||
do_seek:
|
do_seek:
|
||||||
if (cur_stream) {
|
if (cur_stream) {
|
||||||
pos = get_master_clock(cur_stream);
|
if (seek_by_bytes) {
|
||||||
pos += incr;
|
pos = url_ftell(&cur_stream->ic->pb);
|
||||||
stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), incr);
|
if (cur_stream->ic->bit_rate)
|
||||||
|
incr *= cur_stream->ic->bit_rate / 60.0;
|
||||||
|
else
|
||||||
|
incr *= 180000.0;
|
||||||
|
pos += incr;
|
||||||
|
stream_seek(cur_stream, pos, incr);
|
||||||
|
} else {
|
||||||
|
pos = get_master_clock(cur_stream);
|
||||||
|
pos += incr;
|
||||||
|
stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), incr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2344,6 +2357,7 @@ const OptionDef options[] = {
|
|||||||
{ "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
|
{ "an", OPT_BOOL, {(void*)&audio_disable}, "disable audio" },
|
||||||
{ "vn", OPT_BOOL, {(void*)&video_disable}, "disable video" },
|
{ "vn", OPT_BOOL, {(void*)&video_disable}, "disable video" },
|
||||||
{ "ss", HAS_ARG, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
|
{ "ss", HAS_ARG, {(void*)&opt_seek}, "seek to a given position in seconds", "pos" },
|
||||||
|
{ "bytes", OPT_BOOL, {(void*)&seek_by_bytes}, "seek by bytes" },
|
||||||
{ "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
|
{ "nodisp", OPT_BOOL, {(void*)&display_disable}, "disable graphical display" },
|
||||||
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
|
{ "f", HAS_ARG, {(void*)opt_format}, "force format", "fmt" },
|
||||||
{ "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
|
{ "stats", OPT_BOOL | OPT_EXPERT, {(void*)&show_status}, "show status", "" },
|
||||||
|
Loading…
Reference in New Issue
Block a user