X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffplay.c;h=6f3130e57efdf91964d74276fd871b82158ea97b;hb=ecaf5143282cc7a8335f5e19c750de66b1ee8389;hp=a8be6bea2df00a9ae84c44da4c563b46b021f439;hpb=2f56a97f2488146f209de415e3338f7e597c5719;p=ffmpeg diff --git a/ffplay.c b/ffplay.c index a8be6bea2df..6f3130e57ef 100644 --- a/ffplay.c +++ b/ffplay.c @@ -98,6 +98,7 @@ typedef struct PacketQueue { typedef struct VideoPicture { double pts; ///target_clock >= vp->target_clock); next_target= nextvp->target_clock; }else{ - next_target= vp->target_clock + is->video_clock - vp->pts; //FIXME pass durations cleanly + next_target= vp->target_clock + vp->duration; } if((framedrop>0 || (framedrop && is->audio_st)) && time > next_target){ is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR; @@ -1344,6 +1342,8 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_ vp = &is->pictq[is->pictq_windex]; + vp->duration = frame_delay; + /* alloc or resize hardware picture buffer */ if (!vp->bmp || #if CONFIG_AVFILTER @@ -1431,7 +1431,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacket *pkt) { - int len1 av_unused, got_picture, i; + int got_picture, i; if (packet_queue_get(&is->videoq, pkt, 1) < 0) return -1; @@ -1458,9 +1458,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke return 0; } - len1 = avcodec_decode_video2(is->video_st->codec, - frame, &got_picture, - pkt); + avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt); if (got_picture) { if (decoder_reorder_pts == -1) { @@ -1657,6 +1655,7 @@ static int input_config_props(AVFilterLink *link) link->w = c->width; link->h = c->height; + link->sample_aspect_ratio = priv->is->video_st->sample_aspect_ratio; link->time_base = priv->is->video_st->time_base; return 0; @@ -1692,10 +1691,10 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src", NULL, is, graph)) < 0) - goto the_end; + return ret; if ((ret = avfilter_graph_create_filter(&filt_out, avfilter_get_by_name("buffersink"), "out", NULL, pix_fmts, graph)) < 0) - goto the_end; + return ret; if(vfilters) { AVFilterInOut *outputs = avfilter_inout_alloc(); @@ -1712,18 +1711,18 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c inputs->next = NULL; if ((ret = avfilter_graph_parse(graph, vfilters, &inputs, &outputs, NULL)) < 0) - goto the_end; + return ret; av_freep(&vfilters); } else { if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0) - goto the_end; + return ret; } if ((ret = avfilter_graph_config(graph, NULL)) < 0) - goto the_end; + return ret; is->out_video_filter = filt_out; -the_end: + return ret; } @@ -1807,7 +1806,7 @@ static int subtitle_thread(void *arg) VideoState *is = arg; SubPicture *sp; AVPacket pkt1, *pkt = &pkt1; - int len1 av_unused, got_subtitle; + int got_subtitle; double pts; int i, j; int r, g, b, y, u, v, a; @@ -1831,7 +1830,7 @@ static int subtitle_thread(void *arg) SDL_UnlockMutex(is->subpq_mutex); if (is->subtitleq.abort_request) - goto the_end; + return 0; sp = &is->subpq[is->subpq_windex]; @@ -1841,9 +1840,9 @@ static int subtitle_thread(void *arg) if (pkt->pts != AV_NOPTS_VALUE) pts = av_q2d(is->subtitle_st->time_base)*pkt->pts; - len1 = avcodec_decode_subtitle2(is->subtitle_st->codec, - &sp->sub, &got_subtitle, - pkt); + avcodec_decode_subtitle2(is->subtitle_st->codec, &sp->sub, + &got_subtitle, pkt); + if (got_subtitle && sp->sub.format == 0) { sp->pts = pts; @@ -1868,7 +1867,6 @@ static int subtitle_thread(void *arg) } av_free_packet(pkt); } - the_end: return 0; } @@ -2114,11 +2112,15 @@ static int stream_component_open(VideoState *is, int stream_index) AVCodecContext *avctx; AVCodec *codec; SDL_AudioSpec wanted_spec, spec; + AVDictionary *opts; + AVDictionaryEntry *t = NULL; if (stream_index < 0 || stream_index >= ic->nb_streams) return -1; avctx = ic->streams[stream_index]->codec; + opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index]); + /* prepare audio output */ if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { if (avctx->channels > 0) { @@ -2144,13 +2146,16 @@ static int stream_component_open(VideoState *is, int stream_index) avctx->error_concealment= error_concealment; avctx->thread_count= thread_count; - set_context_opts(avctx, avcodec_opts[avctx->codec_type], 0, codec); - if(codec->capabilities & CODEC_CAP_DR1) avctx->flags |= CODEC_FLAG_EMU_EDGE; - if (avcodec_open(avctx, codec) < 0) + if (!codec || + avcodec_open2(avctx, codec, &opts) < 0) return -1; + if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key); + return AVERROR_OPTION_NOT_FOUND; + } /* prepare audio output */ if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { @@ -2304,6 +2309,8 @@ static int read_thread(void *arg) int eof=0; int pkt_in_play_range = 0; AVDictionaryEntry *t; + AVDictionary **opts; + int orig_nb_streams; memset(st_index, -1, sizeof(st_index)); is->video_stream = -1; @@ -2329,12 +2336,19 @@ static int read_thread(void *arg) if(genpts) ic->flags |= AVFMT_FLAG_GENPTS; - err = av_find_stream_info(ic); + opts = setup_find_stream_info_opts(ic, codec_opts); + orig_nb_streams = ic->nb_streams; + + err = avformat_find_stream_info(ic, opts); if (err < 0) { fprintf(stderr, "%s: could not find codec parameters\n", is->filename); ret = -1; goto fail; } + for (i = 0; i < orig_nb_streams; i++) + av_dict_free(&opts[i]); + av_freep(&opts); + if(ic->pb) ic->pb->eof_reached= 0; //FIXME hack, ffplay maybe should not use url_feof() to test for the end @@ -2800,15 +2814,8 @@ static void event_loop(void) static int opt_frame_size(const char *opt, const char *arg) { - if (av_parse_video_size(&frame_width, &frame_height, arg) < 0) { - fprintf(stderr, "Incorrect frame size\n"); - return AVERROR(EINVAL); - } - if ((frame_width % 2) != 0 || (frame_height % 2) != 0) { - fprintf(stderr, "Frame size must be a multiple of 2\n"); - return AVERROR(EINVAL); - } - return 0; + av_log(NULL, AV_LOG_WARNING, "Option -s is deprecated, use -video_size.\n"); + return opt_default("video_size", arg); } static int opt_width(const char *opt, const char *arg) @@ -2835,8 +2842,8 @@ static int opt_format(const char *opt, const char *arg) static int opt_frame_pix_fmt(const char *opt, const char *arg) { - frame_pix_fmt = av_get_pix_fmt(arg); - return 0; + av_log(NULL, AV_LOG_WARNING, "Option -pix_fmt is deprecated, use -pixel_format.\n"); + return opt_default("pixel_format", arg); } static int opt_sync(const char *opt, const char *arg) @@ -2947,7 +2954,7 @@ static const OptionDef options[] = { static void show_usage(void) { printf("Simple media player\n"); - printf("usage: ffplay [options] input_file\n"); + printf("usage: %s [options] input_file\n", program_name); printf("\n"); } @@ -3012,7 +3019,7 @@ int main(int argc, char **argv) if (!input_filename) { show_usage(); fprintf(stderr, "An input file must be specified\n"); - fprintf(stderr, "Use -h to get full help or, even better, run 'man ffplay'\n"); + fprintf(stderr, "Use -h to get full help or, even better, run 'man %s'\n", program_name); exit(1); } @@ -3027,6 +3034,7 @@ int main(int argc, char **argv) #endif if (SDL_Init (flags)) { fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError()); + fprintf(stderr, "(Did you set the DISPLAY variable?)\n"); exit(1); }