]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '1ceb07eb313c2d51383408025e57a2fe50ccd164'
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>
Wed, 13 Apr 2016 14:36:55 +0000 (15:36 +0100)
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>
Wed, 13 Apr 2016 14:36:55 +0000 (15:36 +0100)
* commit '1ceb07eb313c2d51383408025e57a2fe50ccd164':
  avformat_find_stream_info: move duration guessing after updating codec parameters

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
1  2 
libavformat/utils.c

index d6aba5a237b16e85d5d1d67f92f7a3c0b6222496,31faa958a61b9273fd41dbaaafc70ac6e5ebed0c..bf4ea2bd42795e0e339a59e09acbf406b19d80c2
@@@ -3723,36 -2431,6 +3723,33 @@@ FF_ENABLE_DEPRECATION_WARNING
          }
      }
  
-     if (probesize)
-         estimate_timings(ic, old_offset);
 +    av_opt_set(ic, "skip_clear", "0", AV_OPT_SEARCH_CHILDREN);
 +
 +    if (ret >= 0 && ic->nb_streams)
 +        /* We could not have all the codec parameters before EOF. */
 +        ret = -1;
 +    for (i = 0; i < ic->nb_streams; i++) {
 +        const char *errmsg;
 +        st = ic->streams[i];
 +
 +        /* if no packet was ever seen, update context now for has_codec_parameters */
 +        if (!st->internal->avctx_inited) {
 +            ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
 +            if (ret < 0)
 +                goto find_stream_info_err;
 +        }
 +        if (!has_codec_parameters(st, &errmsg)) {
 +            char buf[256];
 +            avcodec_string(buf, sizeof(buf), st->internal->avctx, 0);
 +            av_log(ic, AV_LOG_WARNING,
 +                   "Could not find codec parameters for stream %d (%s): %s\n"
 +                   "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
 +                   i, buf, errmsg);
 +        } else {
 +            ret = 0;
 +        }
 +    }
 +
      compute_chapters_end(ic);
  
      /* update the stream parameters from the internal codec contexts */
@@@ -3806,16 -2463,12 +3803,19 @@@ FF_ENABLE_DEPRECATION_WARNING
          st->internal->avctx_inited = 0;
      }
  
 -    estimate_timings(ic, old_offset);
++    if (probesize)
++        estimate_timings(ic, old_offset);
  find_stream_info_err:
      for (i = 0; i < ic->nb_streams; i++) {
 +        st = ic->streams[i];
 +        if (st->info)
 +            av_freep(&st->info->duration_error);
          av_freep(&ic->streams[i]->info);
      }
 +    if (ic->pb)
 +        av_log(ic, AV_LOG_DEBUG, "After avformat_find_stream_info() pos: %"PRId64" bytes read:%"PRId64" seeks:%d frames:%d\n",
 +               avio_tell(ic->pb), ic->pb->bytes_read, ic->pb->seek_count, count);
      return ret;
  }