X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffplay.c;h=6536e02c78fdd19fd8a5368a10408ef3707d7dc4;hb=d34841f1a8d907738b83b9b36c70eb6d236c2ef1;hp=41277a3cdd292c657302b8e4ec25b2c5f613fcc1;hpb=9fcfc0b763b73ba995e5acf050f4eda67f7750a3;p=ffmpeg diff --git a/ffplay.c b/ffplay.c index 41277a3cdd2..6536e02c78f 100644 --- a/ffplay.c +++ b/ffplay.c @@ -37,6 +37,9 @@ #undef exit +static const char program_name[] = "FFplay"; +static const int program_birth_year = 2003; + //#define DEBUG_SYNC #define MAX_VIDEOQ_SIZE (5 * 256 * 1024) @@ -865,7 +868,7 @@ static int video_open(VideoState *is){ w = 640; h = 480; } -#ifndef CONFIG_DARWIN +#ifndef __APPLE__ screen = SDL_SetVideoMode(w, h, 0, flags); #else /* setting bits_per_pixel = 0 or 32 causes blank video on OS X */ @@ -1012,7 +1015,7 @@ static void video_refresh_timer(void *opaque) /* compute nominal delay */ delay = vp->pts - is->frame_last_pts; - if (delay <= 0 || delay >= 1.0) { + if (delay <= 0 || delay >= 2.0) { /* if incorrect delay, use previous one */ delay = is->frame_last_delay; } @@ -1871,7 +1874,7 @@ static int decode_thread(void *arg) { VideoState *is = arg; AVFormatContext *ic; - int err, i, ret, video_index, audio_index, use_play; + int err, i, ret, video_index, audio_index; AVPacket pkt1, *pkt = &pkt1; AVFormatParameters params, *ap = ¶ms; @@ -1885,8 +1888,6 @@ static int decode_thread(void *arg) url_set_interrupt_cb(decode_interrupt_cb); memset(ap, 0, sizeof(*ap)); - ap->initial_pause = 1; /* we force a pause when starting an RTSP - stream */ ap->width = frame_width; ap->height= frame_height; @@ -1900,24 +1901,17 @@ static int decode_thread(void *arg) goto fail; } is->ic = ic; -#ifdef CONFIG_RTSP_DEMUXER - use_play = (ic->iformat == &rtsp_demuxer); -#else - use_play = 0; -#endif if(genpts) ic->flags |= AVFMT_FLAG_GENPTS; - if (!use_play) { - err = av_find_stream_info(ic); - if (err < 0) { - fprintf(stderr, "%s: could not find codec parameters\n", is->filename); - ret = -1; - goto fail; - } - ic->pb.eof_reached= 0; //FIXME hack, ffplay maybe should not use url_feof() to test for the end + err = av_find_stream_info(ic); + if (err < 0) { + fprintf(stderr, "%s: could not find codec parameters\n", is->filename); + ret = -1; + goto fail; } + ic->pb.eof_reached= 0; //FIXME hack, ffplay maybe should not use url_feof() to test for the end /* if seeking requested, we execute it */ if (start_time != AV_NOPTS_VALUE) { @@ -1934,18 +1928,6 @@ static int decode_thread(void *arg) } } - /* now we can begin to play (RTSP stream only) */ - av_read_play(ic); - - if (use_play) { - err = av_find_stream_info(ic); - if (err < 0) { - fprintf(stderr, "%s: could not find codec parameters\n", is->filename); - ret = -1; - goto fail; - } - } - for(i = 0; i < ic->nb_streams; i++) { AVCodecContext *enc = ic->streams[i]->codec; switch(enc->codec_type) { @@ -1995,7 +1977,7 @@ static int decode_thread(void *arg) av_read_play(ic); } #ifdef CONFIG_RTSP_DEMUXER - if (is->paused && ic->iformat == &rtsp_demuxer) { + if (is->paused && !strcmp(ic->iformat->name, "rtsp")) { /* wait 10 ms to avoid trying to get another packet */ /* XXX: horrible */ SDL_Delay(10); @@ -2217,9 +2199,9 @@ static void toggle_pause(void) static void step_to_next_frame(void) { if (cur_stream) { + /* if the stream is paused unpause it, then step */ if (cur_stream->paused) - cur_stream->paused=0; - cur_stream->video_current_pts = get_video_clock(cur_stream); + stream_pause(cur_stream); } step = 1; } @@ -2427,6 +2409,10 @@ static void opt_sync(const char *arg) static void opt_seek(const char *arg) { start_time = parse_date(arg, 1); + if (start_time == INT64_MIN) { + fprintf(stderr, "Invalid duration specification: %s\n", arg); + exit(1); + } } static void opt_debug(const char *arg) @@ -2493,8 +2479,7 @@ const OptionDef options[] = { void show_help(void) { - printf("ffplay version " FFMPEG_VERSION ", Copyright (c) 2003-2007 Fabrice Bellard, et al.\n" - "usage: ffplay [options] input_file\n" + printf("usage: ffplay [options] input_file\n" "Simple media player\n"); printf("\n"); show_help_options(options, "Main options:\n", @@ -2515,7 +2500,7 @@ void show_help(void) ); } -void parse_arg_file(const char *filename) +void opt_input_file(const char *filename) { if (!strcmp(filename, "-")) filename = "pipe:"; @@ -2530,7 +2515,9 @@ int main(int argc, char **argv) /* register all codecs, demux and protocols */ av_register_all(); - parse_options(argc, argv, options, parse_arg_file); + show_banner(program_name, program_birth_year); + + parse_options(argc, argv, options, opt_input_file); if (!input_filename) { show_help(); @@ -2541,8 +2528,8 @@ int main(int argc, char **argv) video_disable = 1; } flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; -#if !defined(__MINGW32__) && !defined(CONFIG_DARWIN) - flags |= SDL_INIT_EVENTTHREAD; /* Not supported on win32 or darwin */ +#if !defined(__MINGW32__) && !defined(__APPLE__) + flags |= SDL_INIT_EVENTTHREAD; /* Not supported on Windows or Mac OS X */ #endif if (SDL_Init (flags)) { fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());