comparison libmpdemux/demux_lavf.c @ 36356:7bb6989c97b8

Add support for ffmpeg's demuxer-specific options.
author reimar
date Sat, 21 Sep 2013 15:43:45 +0000
parents 996d93a5ed1f
children 7dca7d4d4e54
comparison
equal deleted inserted replaced
36355:4593e5141d8e 36356:7bb6989c97b8
506 mp_msg(MSGT_DEMUX, MSGL_INFO, "\n"); 506 mp_msg(MSGT_DEMUX, MSGL_INFO, "\n");
507 } 507 }
508 } 508 }
509 509
510 static demuxer_t* demux_open_lavf(demuxer_t *demuxer){ 510 static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
511 AVDictionary *opts;
511 AVFormatContext *avfc; 512 AVFormatContext *avfc;
512 AVDictionaryEntry *t = NULL; 513 AVDictionaryEntry *t = NULL;
513 lavf_priv_t *priv= demuxer->priv; 514 lavf_priv_t *priv= demuxer->priv;
514 int i; 515 int i;
515 char mp_filename[256]="mp:"; 516 char mp_filename[256]="mp:";
533 if (av_opt_set_int(avfc, "analyzeduration", opt_analyzeduration * AV_TIME_BASE, 0) < 0) 534 if (av_opt_set_int(avfc, "analyzeduration", opt_analyzeduration * AV_TIME_BASE, 0) < 0)
534 mp_msg(MSGT_HEADER,MSGL_ERR, "demux_lavf, couldn't set option analyzeduration to %u\n", opt_analyzeduration); 535 mp_msg(MSGT_HEADER,MSGL_ERR, "demux_lavf, couldn't set option analyzeduration to %u\n", opt_analyzeduration);
535 } 536 }
536 537
537 if(opt_avopt){ 538 if(opt_avopt){
538 if(parse_avopts(avfc, opt_avopt) < 0){ 539 if(av_dict_parse_string(&opts, opt_avopt, "=", ",", 0) < 0){
539 mp_msg(MSGT_HEADER,MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", opt_avopt); 540 mp_msg(MSGT_HEADER,MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", opt_avopt);
540 return NULL; 541 return NULL;
541 } 542 }
542 } 543 }
543 544
561 if (!demuxer->stream->end_pos || (demuxer->stream->flags & MP_STREAM_SEEK) != MP_STREAM_SEEK) 562 if (!demuxer->stream->end_pos || (demuxer->stream->flags & MP_STREAM_SEEK) != MP_STREAM_SEEK)
562 priv->pb->seekable = 0; 563 priv->pb->seekable = 0;
563 avfc->pb = priv->pb; 564 avfc->pb = priv->pb;
564 } 565 }
565 566
566 if(avformat_open_input(&avfc, mp_filename, priv->avif, NULL)<0){ 567 if(avformat_open_input(&avfc, mp_filename, priv->avif, &opts)<0){
567 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_open_input_stream() failed\n"); 568 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_open_input_stream() failed\n");
568 return NULL; 569 return NULL;
569 } 570 }
571 if (av_dict_count(opts)) {
572 AVDictionaryEntry *e = NULL;
573 while ((e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)))
574 mp_msg(MSGT_HEADER,MSGL_ERR,"Unknown option %s\n", e->key);
575 return 0;
576 }
577 av_dict_free(&opts);
570 578
571 priv->avfc= avfc; 579 priv->avfc= avfc;
572 580
573 if(avformat_find_stream_info(avfc, NULL) < 0){ 581 if(avformat_find_stream_info(avfc, NULL) < 0){
574 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_find_stream_info() failed\n"); 582 mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_find_stream_info() failed\n");