56 #include "libavutil/ffversion.h"
74 return FFMPEG_CONFIGURATION;
79 #define LICENSE_PREFIX "libavformat license: "
93 #define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
111 timestamp < st->pts_wrap_reference)
120 #if FF_API_FORMAT_GET_SET
122 #if FF_API_LAVF_FFSERVER
134 #if FF_API_OLD_OPEN_CALLBACKS
157 s->internal->inject_global_side_data = 1;
158 for (
i = 0;
i <
s->nb_streams;
i++) {
170 dst-> codec_whitelist =
av_strdup(
src->codec_whitelist);
174 if ( (
src-> codec_whitelist && !dst-> codec_whitelist)
175 || (
src-> format_whitelist && !dst-> format_whitelist)
186 #if FF_API_LAVF_AVCTX
188 if (st->codec->codec)
189 return st->codec->codec;
195 if (
s->video_codec)
return s->video_codec;
198 if (
s->audio_codec)
return s->audio_codec;
201 if (
s->subtitle_codec)
return s->subtitle_codec;
212 #if CONFIG_H264_DECODER
237 #if FF_API_FORMAT_GET_SET
240 return s->probe_score;
245 #define SANE_CHUNK_SIZE (50000000)
249 if (
s->maxsize>= 0) {
251 int64_t remaining=
s->maxsize -
pos;
252 if (remaining <
size) {
254 if (!
s->maxsize ||
s->maxsize<newsize)
255 s->maxsize = newsize - !newsize;
256 if (
pos >
s->maxsize &&
s->maxsize >= 0)
259 remaining =
s->maxsize -
pos;
262 if (
s->maxsize>= 0 && remaining+1 <
size) {
274 int64_t orig_pos =
pkt->
pos;
297 if (
ret != read_size) {
340 static const struct {
368 "Probe with size=%d, packets=%d detected %s with score=%d\n",
371 for (
i = 0; fmt_id_type[
i].name;
i++) {
372 if (!strcmp(
fmt->name, fmt_id_type[
i].name)) {
382 #if FF_API_LAVF_AVCTX
430 s, 0,
s->format_probesize);
433 "will be ignored with AVFMT_NOFILE format.\n");
447 s, 0,
s->format_probesize);
473 (*plast_pktl)->next = pktl;
475 *packet_buffer = pktl;
485 for (
i = 0;
i <
s->nb_streams;
i++)
488 if (
s->streams[
i]->attached_pic.size <= 0) {
490 "Attached picture on stream %d has invalid size, "
496 &
s->internal->raw_packet_buffer_end,
497 &
s->streams[
i]->attached_pic,
508 for (
i = 0;
i <
s->nb_streams;
i++) {
525 #if FF_API_LAVF_AVCTX
551 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
566 if (!(
s->url =
av_strdup(filename ? filename :
""))) {
571 #if FF_API_FORMAT_FILENAME
573 av_strlcpy(
s->filename, filename ? filename :
"",
sizeof(
s->filename));
578 s->probe_score =
ret;
580 if (!
s->protocol_whitelist &&
s->pb &&
s->pb->protocol_whitelist) {
581 s->protocol_whitelist =
av_strdup(
s->pb->protocol_whitelist);
582 if (!
s->protocol_whitelist) {
588 if (!
s->protocol_blacklist &&
s->pb &&
s->pb->protocol_blacklist) {
589 s->protocol_blacklist =
av_strdup(
s->pb->protocol_blacklist);
590 if (!
s->protocol_blacklist) {
596 if (
s->format_whitelist &&
av_match_list(
s->iformat->name,
s->format_whitelist,
',') <= 0) {
615 if (
s->iformat->priv_data_size > 0) {
616 if (!(
s->priv_data =
av_mallocz(
s->iformat->priv_data_size))) {
620 if (
s->iformat->priv_class) {
621 *(
const AVClass **)
s->priv_data =
s->iformat->priv_class;
634 if ((
ret =
s->iformat->read_header(
s)) < 0)
638 s->metadata =
s->internal->id3v2_meta;
639 s->internal->id3v2_meta =
NULL;
640 }
else if (
s->internal->id3v2_meta) {
644 av_log(
s,
level,
"Discarding ID3 tags because more suitable tags were found.\n");
652 if (id3v2_extra_meta) {
653 if (!strcmp(
s->iformat->name,
"mp3") || !strcmp(
s->iformat->name,
"aac") ||
654 !strcmp(
s->iformat->name,
"tta") || !strcmp(
s->iformat->name,
"wav")) {
676 for (
i = 0;
i <
s->nb_streams;
i++)
677 s->streams[
i]->internal->orig_codec_id =
s->streams[
i]->codecpar->codec_id;
687 if (
s->iformat->read_close)
688 s->iformat->read_close(
s);
705 if (
s->video_codec_id)
709 if (
s->audio_codec_id)
713 if (
s->subtitle_codec_id)
717 if (
s->data_codec_id)
735 "Failed to reallocate probe buffer for stream %d\n",
748 "nothing to probe for stream %d\n", st->
index);
752 end=
s->internal->raw_packet_buffer_remaining_size <= 0
776 int i, pts_wrap_behavior;
777 int64_t pts_wrap_reference;
795 if (!first_program) {
797 if (
s->streams[default_stream_index]->pts_wrap_reference ==
AV_NOPTS_VALUE) {
798 for (
i = 0;
i <
s->nb_streams;
i++) {
801 s->streams[
i]->pts_wrap_reference = pts_wrap_reference;
802 s->streams[
i]->pts_wrap_behavior = pts_wrap_behavior;
814 pts_wrap_reference =
program->pts_wrap_reference;
815 pts_wrap_behavior =
program->pts_wrap_behavior;
824 if (
program->pts_wrap_reference != pts_wrap_reference) {
825 for (
i = 0;
i<
program->nb_stream_indexes;
i++) {
826 s->streams[
program->stream_index[
i]]->pts_wrap_reference = pts_wrap_reference;
827 s->streams[
program->stream_index[
i]]->pts_wrap_behavior = pts_wrap_behavior;
830 program->pts_wrap_reference = pts_wrap_reference;
831 program->pts_wrap_behavior = pts_wrap_behavior;
850 if (
s->internal->raw_packet_buffer_remaining_size <= 0)
854 s->internal->raw_packet_buffer = pktl->
next;
855 s->internal->raw_packet_buffer_remaining_size +=
pkt->
size;
864 ret =
s->iformat->read_packet(
s,
pkt);
873 for (
i = 0;
i <
s->nb_streams;
i++) {
892 "Dropped corrupted packet (stream = %d)\n",
921 if (
s->use_wallclock_as_timestamps)
928 &
s->internal->raw_packet_buffer_end,
934 s->internal->raw_packet_buffer_remaining_size -=
pkt->
size;
967 #if FF_API_LAVF_AVCTX
984 }
else if (codec_framerate.
den * 1000LL > codec_framerate.
num) {
1038 #if CONFIG_H264_DECODER
1055 if (pktl ==
s->internal->packet_buffer_end)
1056 return s->internal->parse_queue;
1069 int64_t best_score = INT64_MAX;
1070 for (
i = 0;
i<delay;
i++) {
1073 if (score < best_score) {
1075 dts = pts_buffer[
i];
1080 for (
i = 0;
i<delay;
i++) {
1097 dts = pts_buffer[0];
1109 AVStream *st =
s->streams[stream_index];
1118 for (; pkt_buffer; pkt_buffer =
get_next_pkt(
s, st, pkt_buffer)) {
1123 pts_buffer[0] = pkt_buffer->
pkt.
pts;
1124 for (
i = 0; i<delay && pts_buffer[i] > pts_buffer[
i + 1];
i++)
1125 FFSWAP(int64_t, pts_buffer[
i], pts_buffer[
i + 1]);
1135 AVStream *st =
s->streams[stream_index];
1136 AVPacketList *pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1156 for (pktl_it = pktl; pktl_it; pktl_it =
get_next_pkt(
s, st, pktl_it)) {
1188 AVPacketList *pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1206 av_log(
s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %"PRId64
") in the queue\n",
1214 pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1243 int64_t next_dts, int64_t next_pts)
1245 int num, den, presentation_delayed, delay,
i;
1260 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1286 presentation_delayed = 0;
1292 presentation_delayed = 1;
1310 if ( strcmp(
s->iformat->name,
"mov,mp4,m4a,3gp,3g2,mj2")
1311 && strcmp(
s->iformat->name,
"flv"))
1327 if (
pkt->
duration != 0 && (
s->internal->packet_buffer ||
s->internal->parse_queue))
1345 presentation_delayed = 1;
1349 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64
" delay:%d onein_oneout:%d\n",
1355 if ((delay == 0 || (delay == 1 && pc)) &&
1357 if (presentation_delayed) {
1375 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1376 next_dts != next_pts &&
1424 #if FF_API_CONVERGENCE_DURATION
1443 *pkt_buf_end =
NULL;
1454 AVStream *st =
s->streams[stream_index];
1457 int ret = 0, got_output = 0;
1470 int64_t next_pts =
pkt->
pts;
1471 int64_t next_dts =
pkt->
dts;
1484 got_output = !!out_pkt.
size;
1518 (
AVRational) { 1, st->internal->avctx->sample_rate },
1544 &
s->internal->parse_queue_end,
1571 *pkt_buffer = pktl->
next;
1573 *pkt_buffer_end =
NULL;
1585 int ret = 0,
i, got_packet = 0;
1590 while (!got_packet && !
s->internal->parse_queue) {
1600 for (
i = 0;
i <
s->nb_streams;
i++) {
1615 av_log(
s,
AV_LOG_DEBUG,
"Demuxer context update while decoder is open, closing and trying to re-open\n");
1632 #if FF_API_LAVF_AVCTX
1648 cur_pkt.
pts < cur_pkt.
dts) {
1650 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1658 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64
", flags=%d\n",
1668 "%s, packets or times may be invalid.\n",
1714 if (!got_packet &&
s->internal->parse_queue)
1719 int discard_padding = 0;
1726 sample < st->last_discard_sample)
1735 AV_WL32(p + 4, discard_padding);
1755 memcpy(dst_data, src_sd->
data, src_sd->
size);
1769 #if FF_API_LAVF_AVCTX
1775 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1776 "size=%d, duration=%"PRId64
", flags=%d\n",
1793 ret =
s->internal->packet_buffer
1795 &
s->internal->packet_buffer_end,
pkt)
1809 int wrap_bits =
s->streams[next_pkt->
stream_index]->pts_wrap_bits;
1812 int64_t last_dts = next_pkt->
dts;
1823 last_dts = pktl->
pkt.
dts;
1836 pktl =
s->internal->packet_buffer;
1844 &
s->internal->packet_buffer_end,
pkt);
1859 &
s->internal->packet_buffer_end,
1901 int best_stream = 0;
1902 int best_score = INT_MIN;
1904 if (
s->nb_streams <= 0)
1906 for (
i = 0;
i <
s->nb_streams;
i++) {
1926 if (score > best_score) {
1943 for (
i = 0;
i <
s->nb_streams;
i++) {
1963 if (
s->internal->inject_global_side_data)
1974 for (
i = 0;
i <
s->nb_streams;
i++) {
1986 AVStream *st =
s->streams[stream_index];
1987 unsigned int max_entries =
s->max_index_size /
sizeof(
AVIndexEntry);
1998 int *nb_index_entries,
1999 unsigned int *index_entries_allocated_size,
2000 int64_t pos, int64_t timestamp,
2006 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
2012 if (size < 0 || size > 0x3FFFFFFF)
2019 index_entries_allocated_size,
2020 (*nb_index_entries + 1) *
2025 *index_entries = entries;
2031 index = (*nb_index_entries)++;
2032 ie = &entries[
index];
2035 ie = &entries[
index];
2039 memmove(entries +
index + 1, entries +
index,
2041 (*nb_index_entries)++;
2042 }
else if (ie->
pos == pos && distance < ie->min_distance)
2066 int64_t wanted_timestamp,
int flags)
2075 if (
b && entries[
b - 1].timestamp < wanted_timestamp)
2084 if (m ==
b && entries[m].timestamp >= wanted_timestamp) {
2091 if (timestamp >= wanted_timestamp)
2093 if (timestamp <= wanted_timestamp)
2099 while (m >= 0 && m < nb_entries &&
2103 if (m == nb_entries)
2111 int64_t pos_delta = 0;
2120 "Protocol name not provided, cannot determine if input is local or "
2121 "a network protocol, buffers and access patterns cannot be configured "
2122 "optimally without knowing the protocol\n");
2125 if (proto && !(strcmp(proto,
"file") && strcmp(proto,
"pipe") && strcmp(proto,
"cache")))
2128 for (ist1 = 0; ist1 <
s->nb_streams; ist1++) {
2130 for (ist2 = 0; ist2 <
s->nb_streams; ist2++) {
2145 if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
2156 if (
s->pb->buffer_size < pos_delta && pos_delta < (1<<24)) {
2159 s->pb->short_seek_threshold =
FFMAX(
s->pb->short_seek_threshold, pos_delta/2);
2162 if (skip < (1<<23)) {
2163 s->pb->short_seek_threshold =
FFMAX(
s->pb->short_seek_threshold, skip);
2170 wanted_timestamp,
flags);
2174 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
2176 int64_t ts = read_timestamp(
s, stream_index, ppos, pos_limit);
2177 if (stream_index >= 0)
2183 int64_t target_ts,
int flags)
2187 int64_t ts_min, ts_max, ts;
2192 if (stream_index < 0)
2201 st =
s->streams[stream_index];
2231 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
2235 pos =
ff_gen_search(
s, stream_index, target_ts, pos_min, pos_max, pos_limit,
2251 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
2253 int64_t
step = 1024;
2254 int64_t limit, ts_max;
2256 int64_t pos_max = filesize - 1;
2261 &pos_max, limit, read_timestamp);
2268 int64_t tmp_pos = pos_max + 1;
2270 &tmp_pos, INT64_MAX, read_timestamp);
2276 if (tmp_pos >= filesize)
2289 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
2290 int64_t ts_min, int64_t ts_max,
2291 int flags, int64_t *ts_ret,
2293 int64_t *, int64_t))
2303 pos_min =
s->internal->data_offset;
2309 if (ts_min >= target_ts) {
2317 pos_limit = pos_max;
2320 if (ts_max <= target_ts) {
2328 while (pos_min < pos_limit) {
2330 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
2334 if (no_change == 0) {
2335 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2337 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
2339 pos_min - approximate_keyframe_distance;
2340 }
else if (no_change == 1) {
2342 pos = (pos_min + pos_limit) >> 1;
2350 else if (pos > pos_limit)
2361 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2362 pos_min, pos, pos_max,
2364 pos_limit, start_pos, no_change);
2369 if (target_ts <= ts) {
2370 pos_limit = start_pos - 1;
2374 if (target_ts >= ts) {
2395 int64_t pos,
int flags)
2397 int64_t pos_min, pos_max;
2399 pos_min =
s->internal->data_offset;
2404 else if (pos > pos_max)
2409 s->io_repositioned = 1;
2415 int64_t timestamp,
int flags)
2422 st =
s->streams[stream_index];
2426 if (index < 0 && st->nb_index_entries &&
2427 timestamp < st->index_entries[0].timestamp)
2430 if (index < 0 || index == st->nb_index_entries - 1) {
2441 if ((
ret =
avio_seek(
s->pb,
s->internal->data_offset, SEEK_SET)) < 0)
2448 }
while (read_status ==
AVERROR(EAGAIN));
2449 if (read_status < 0)
2457 av_log(
s,
AV_LOG_ERROR,
"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey);
2470 if (
s->iformat->read_seek)
2471 if (
s->iformat->read_seek(
s, stream_index, timestamp,
flags) >= 0)
2482 int64_t timestamp,
int flags)
2494 if (stream_index < 0) {
2496 if (stream_index < 0)
2499 st =
s->streams[stream_index];
2506 if (
s->iformat->read_seek) {
2508 ret =
s->iformat->read_seek(
s, stream_index, timestamp,
flags);
2514 if (
s->iformat->read_timestamp &&
2526 int64_t timestamp,
int flags)
2530 if (
s->iformat->read_seek2 && !
s->iformat->read_seek) {
2531 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2549 int64_t ts, int64_t max_ts,
int flags)
2551 if (min_ts > ts || max_ts < ts)
2553 if (stream_index < -1 || stream_index >= (
int)
s->nb_streams)
2560 if (
s->iformat->read_seek2) {
2564 if (stream_index == -1 &&
s->nb_streams == 1) {
2576 ret =
s->iformat->read_seek2(
s, stream_index, min_ts,
2584 if (
s->iformat->read_timestamp) {
2590 if (
s->iformat->read_seek || 1) {
2593 if (
ret<0 && ts != min_ts && max_ts != ts) {
2640 int64_t
start_time, start_time1, start_time_text, end_time, end_time1, end_time_text;
2641 int64_t
duration, duration1, duration_text, filesize;
2646 start_time_text = INT64_MAX;
2647 end_time = INT64_MIN;
2648 end_time_text = INT64_MIN;
2650 duration_text = INT64_MIN;
2660 start_time_text =
FFMIN(start_time_text, start_time1);
2666 if (end_time1 !=
AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
2667 end_time1 += start_time1;
2669 end_time_text =
FFMAX(end_time_text, end_time1);
2671 end_time =
FFMAX(end_time, end_time1);
2684 duration_text =
FFMAX(duration_text, duration1);
2694 if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time <
AV_TIME_BASE))
2695 end_time = end_time_text;
2696 else if (end_time < end_time_text)
2706 if (end_time != INT64_MIN) {
2754 int i, show_warning = 0;
2759 int64_t bit_rate = 0;
2801 "Estimating duration from bitrate, this may be inaccurate\n");
2804 #define DURATION_MAX_READ_SIZE 250000LL
2805 #define DURATION_MAX_RETRY 6
2812 int num, den, read_size,
i,
ret;
2813 int found_duration = 0;
2827 "start time for stream %d is not set in estimate_timings_from_pts\n",
i);
2836 av_log(ic,
AV_LOG_INFO,
"Skipping duration calculation in estimate_timings_from_pts\n");
2837 goto skip_duration_calc;
2845 is_end = found_duration;
2918 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n",
i);
2920 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n",
i);
2949 file_size =
FFMAX(0, file_size);
2975 if (st->time_base.den)
2977 (
double) st->start_time *
av_q2d(st->time_base),
2978 (
double) st->duration *
av_q2d(st->time_base));
2981 "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64
" kb/s\n",
2992 #define FAIL(errmsg) do { \
2994 *errmsg_ptr = errmsg; \
3000 FAIL(
"unknown codec");
3004 FAIL(
"unspecified frame size");
3007 FAIL(
"unspecified sample format");
3009 FAIL(
"unspecified sample rate");
3011 FAIL(
"unspecified number of channels");
3013 FAIL(
"no decodable DTS frames");
3017 FAIL(
"unspecified size");
3019 FAIL(
"unspecified pixel format");
3022 FAIL(
"no frame in rv30/40 and no sar");
3026 FAIL(
"unspecified size");
3041 int got_picture = 1,
ret = 0;
3045 int do_skip_frame = 0;
3067 if (
s->codec_whitelist)
3111 &got_picture, &
pkt);
3124 if (!
pkt.
data && !got_picture)
3128 if (do_skip_frame) {
3160 if (bps <= 0 || bps > 64)
3175 if (sflags & (1 << (
bps - 1))) {
3219 for (
i = 0; tags && tags[
i];
i++) {
3222 if (codec_tags->
id ==
id) {
3235 for (
i = 0; tags && tags[
i];
i++) {
3246 int64_t max_time = 0;
3248 if (
s->duration > 0 &&
s->start_time < INT64_MAX -
s->duration)
3249 max_time =
s->duration +
3252 for (
i = 0;
i <
s->nb_chapters;
i++)
3259 for (j = 0; j <
s->nb_chapters; j++) {
3263 if (j !=
i && next_start >
ch->start && next_start <
end)
3273 return (
i + 1) * 1001;
3277 return (
i + 31) * 1001 * 12;
3281 return ((
const int[]) { 80, 120, 240})[
i] * 1001 * 12;
3285 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[
i] * 1000 * 12;
3296 if (
c->time_base.den >= 101LL *
c->time_base.num ||
3297 c->time_base.den < 5LL *
c->time_base.num ||
3349 && ts - (uint64_t)last < INT64_MAX) {
3364 for (j= 0; j<2; j++) {
3365 int64_t ticks =
llrint(sdts+j*0.5);
3366 double error= sdts - ticks + j*0.5;
3385 if (error0 > 0.04 && error1 > 0.04) {
3420 double best_error= 0.01;
3435 for (k= 0; k<2; k++) {
3440 if (error < best_error && best_error> 0.000000001) {
3449 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3600 int64_t max_stream_analyze_duration;
3601 int64_t max_subtitle_analyze_duration;
3603 int eof_reached = 0;
3606 flush_codecs = probesize > 0;
3610 max_stream_analyze_duration = max_analyze_duration;
3611 max_subtitle_analyze_duration = max_analyze_duration;
3612 if (!max_analyze_duration) {
3613 max_stream_analyze_duration =
3623 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d nb_streams:%d\n",
3641 #if FF_API_LAVF_AVCTX
3661 "%s, packets or times may be invalid.\n",
3671 goto find_stream_info_err;
3686 && codec && !avctx->
codec) {
3689 "Failed to open codec in %s\n",__FUNCTION__);
3694 if (codec && !avctx->
codec)
3697 "Failed to open codec in %s\n",__FUNCTION__);
3704 #if FF_API_R_FRAME_RATE
3713 int analyzed_all_streams;
3722 int fps_analyze_framecount = 20;
3732 fps_analyze_framecount *= 2;
3734 fps_analyze_framecount = 0;
3738 fps_analyze_framecount = 0;
3745 if (
count < fps_analyze_framecount)
3764 analyzed_all_streams = 0;
3765 if (!missing_streams || !*missing_streams)
3767 analyzed_all_streams = 1;
3779 if (read_size >= probesize) {
3782 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3789 "Stream #%d: not enough frames to estimate rate; "
3790 "consider increasing probesize\n",
i);
3813 goto find_stream_info_err;
3824 goto find_stream_info_err;
3833 "Non-increasing DTS in stream %d: packet %d with DTS "
3834 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3850 "DTS discontinuity in stream %d: packet %d with DTS "
3851 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3882 if (analyzed_all_streams) limit = max_analyze_duration;
3884 else limit = max_stream_analyze_duration;
3887 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
3903 #if FF_API_R_FRAME_RATE
3912 goto find_stream_info_err;
3936 for (stream_index = 0; stream_index < ic->
nb_streams; stream_index++) {
3937 st = ic->
streams[stream_index];
3941 if (codec && !avctx->
codec) {
3947 "Failed to open codec in %s\n",__FUNCTION__);
3979 "decoding for stream %d failed\n", st->
index);
4002 double best_error = 0.01;
4020 if (
error < best_error) {
4022 best_fps = std_fps.
num;
4028 if (
error < best_error) {
4030 best_fps = std_fps.
num;
4036 best_fps, 12 * 1001, INT_MAX);
4098 goto find_stream_info_err;
4104 "Could not find codec parameters for stream %d (%s): %s\n"
4105 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
4123 goto find_stream_info_err;
4133 #if FF_API_LAVF_AVCTX
4137 goto find_stream_info_err;
4149 if (st->codec->codec_tag !=
MKTAG(
't',
'm',
'c',
'd')) {
4157 if (!st->codec->subtitle_header)
4158 goto find_stream_info_err;
4161 st->codec->subtitle_header_size);
4174 find_stream_info_err:
4185 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
4208 int wanted_stream_nb,
int related_stream,
4213 int best_count = -1, best_multiframe = -1, best_disposition = -1;
4214 int count, multiframe, disposition;
4215 int64_t best_bitrate = -1;
4220 if (related_stream >= 0 && wanted_stream_nb < 0) {
4233 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
<