52 #include "libavutil/ffversion.h"
70 return FFMPEG_CONFIGURATION;
75 #define LICENSE_PREFIX "libavformat license: "
89 #define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
107 timestamp < st->internal->pts_wrap_reference)
116 #if FF_API_FORMAT_GET_SET
118 #if FF_API_LAVF_FFSERVER
130 #if FF_API_OLD_OPEN_CALLBACKS
153 s->internal->inject_global_side_data = 1;
154 for (
i = 0;
i <
s->nb_streams;
i++) {
166 dst-> codec_whitelist =
av_strdup(
src->codec_whitelist);
170 if ( (
src-> codec_whitelist && !dst-> codec_whitelist)
171 || (
src-> format_whitelist && !dst-> format_whitelist)
182 #if FF_API_LAVF_AVCTX
184 if (st->codec->codec)
185 return st->codec->codec;
191 if (
s->video_codec)
return s->video_codec;
194 if (
s->audio_codec)
return s->audio_codec;
197 if (
s->subtitle_codec)
return s->subtitle_codec;
208 #if CONFIG_H264_DECODER
234 #if FF_API_FORMAT_GET_SET
237 return s->probe_score;
242 #define SANE_CHUNK_SIZE (50000000)
246 if (
s->maxsize>= 0) {
248 int64_t remaining=
s->maxsize -
pos;
249 if (remaining <
size) {
251 if (!
s->maxsize ||
s->maxsize<newsize)
252 s->maxsize = newsize - !newsize;
253 if (
pos >
s->maxsize &&
s->maxsize >= 0)
256 remaining =
s->maxsize -
pos;
259 if (
s->maxsize >= 0 && remaining < size && size > 1) {
261 "Truncating packet of size %d to %"PRId64
"\n",
262 size, remaining + !remaining);
263 size = remaining + !remaining;
295 if (
ret != read_size) {
312 #if FF_API_INIT_PACKET
343 static const struct {
371 "Probe with size=%d, packets=%d detected %s with score=%d\n",
374 for (
i = 0; fmt_id_type[
i].name;
i++) {
375 if (!strcmp(fmt->
name, fmt_id_type[
i].name)) {
385 #if FF_API_LAVF_AVCTX
401 #if FF_API_DEMUXER_OPEN
434 s, 0,
s->format_probesize);
437 "will be ignored with AVFMT_NOFILE format.\n");
451 s, 0,
s->format_probesize);
457 for (
i = 0;
i <
s->nb_streams;
i++)
460 if (
s->streams[
i]->attached_pic.size <= 0) {
462 "Attached picture on stream %d has invalid size, "
468 &
s->internal->raw_packet_buffer_end,
469 &
s->streams[
i]->attached_pic,
480 for (
i = 0;
i <
s->nb_streams;
i++) {
497 #if FF_API_LAVF_AVCTX
523 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
538 if (!(
s->url =
av_strdup(filename ? filename :
""))) {
543 #if FF_API_FORMAT_FILENAME
545 av_strlcpy(
s->filename, filename ? filename :
"",
sizeof(
s->filename));
550 s->probe_score =
ret;
552 if (!
s->protocol_whitelist &&
s->pb &&
s->pb->protocol_whitelist) {
553 s->protocol_whitelist =
av_strdup(
s->pb->protocol_whitelist);
554 if (!
s->protocol_whitelist) {
560 if (!
s->protocol_blacklist &&
s->pb &&
s->pb->protocol_blacklist) {
561 s->protocol_blacklist =
av_strdup(
s->pb->protocol_blacklist);
562 if (!
s->protocol_blacklist) {
568 if (
s->format_whitelist &&
av_match_list(
s->iformat->name,
s->format_whitelist,
',') <= 0) {
587 if (
s->iformat->priv_data_size > 0) {
588 if (!(
s->priv_data =
av_mallocz(
s->iformat->priv_data_size))) {
592 if (
s->iformat->priv_class) {
593 *(
const AVClass **)
s->priv_data =
s->iformat->priv_class;
604 #if FF_API_DEMUXER_OPEN
605 if (!(
s->flags&AVFMT_FLAG_PRIV_OPT) &&
s->iformat->read_header)
607 if (
s->iformat->read_header)
609 if ((
ret =
s->iformat->read_header(
s)) < 0)
613 s->metadata =
s->internal->id3v2_meta;
614 s->internal->id3v2_meta =
NULL;
615 }
else if (
s->internal->id3v2_meta) {
620 if (id3v2_extra_meta) {
621 if (!strcmp(
s->iformat->name,
"mp3") || !strcmp(
s->iformat->name,
"aac") ||
622 !strcmp(
s->iformat->name,
"tta") || !strcmp(
s->iformat->name,
"wav")) {
637 #if FF_API_DEMUXER_OPEN
638 if (!(
s->flags&AVFMT_FLAG_PRIV_OPT) &&
s->pb && !
s->internal->data_offset)
640 if (
s->pb && !
s->internal->data_offset)
648 for (
i = 0;
i <
s->nb_streams;
i++)
649 s->streams[
i]->internal->orig_codec_id =
s->streams[
i]->codecpar->codec_id;
659 if (
s->iformat->read_close)
660 s->iformat->read_close(
s);
677 if (
s->video_codec_id)
681 if (
s->audio_codec_id)
685 if (
s->subtitle_codec_id)
689 if (
s->data_codec_id)
707 "Failed to reallocate probe buffer for stream %d\n",
720 "nothing to probe for stream %d\n", st->
index);
724 end=
s->internal->raw_packet_buffer_remaining_size <= 0
748 int i, pts_wrap_behavior;
749 int64_t pts_wrap_reference;
767 if (!first_program) {
769 if (
s->streams[default_stream_index]->internal->pts_wrap_reference ==
AV_NOPTS_VALUE) {
770 for (
i = 0;
i <
s->nb_streams;
i++) {
773 s->streams[
i]->internal->pts_wrap_reference = pts_wrap_reference;
774 s->streams[
i]->internal->pts_wrap_behavior = pts_wrap_behavior;
786 pts_wrap_reference =
program->pts_wrap_reference;
787 pts_wrap_behavior =
program->pts_wrap_behavior;
796 if (
program->pts_wrap_reference != pts_wrap_reference) {
797 for (
i = 0;
i<
program->nb_stream_indexes;
i++) {
798 s->streams[
program->stream_index[
i]]->internal->pts_wrap_reference = pts_wrap_reference;
799 s->streams[
program->stream_index[
i]]->internal->pts_wrap_behavior = pts_wrap_behavior;
802 program->pts_wrap_reference = pts_wrap_reference;
803 program->pts_wrap_behavior = pts_wrap_behavior;
816 #if FF_API_INIT_PACKET
832 if (
s->internal->raw_packet_buffer_remaining_size <= 0)
837 &
s->internal->raw_packet_buffer_end,
pkt);
838 s->internal->raw_packet_buffer_remaining_size +=
pkt->
size;
843 ret =
s->iformat->read_packet(
s,
pkt);
854 for (
i = 0;
i <
s->nb_streams;
i++) {
872 "Packet corrupt (stream = %d, dts = %s)",
883 "Invalid stream index.\n");
903 if (
s->use_wallclock_as_timestamps)
910 &
s->internal->raw_packet_buffer_end,
916 pkt1 = &
s->internal->raw_packet_buffer_end->pkt;
917 s->internal->raw_packet_buffer_remaining_size -= pkt1->
size;
950 #if FF_API_LAVF_AVCTX
967 }
else if (codec_framerate.
den * 1000LL > codec_framerate.
num) {
1022 #if CONFIG_H264_DECODER
1039 if (pktl ==
s->internal->packet_buffer_end)
1040 return s->internal->parse_queue;
1053 int64_t best_score = INT64_MAX;
1054 for (
i = 0;
i<delay;
i++) {
1057 if (score < best_score) {
1059 dts = pts_buffer[
i];
1064 for (
i = 0;
i<delay;
i++) {
1081 dts = pts_buffer[0];
1093 AVStream *st =
s->streams[stream_index];
1102 for (; pkt_buffer; pkt_buffer =
get_next_pkt(
s, st, pkt_buffer)) {
1107 pts_buffer[0] = pkt_buffer->
pkt.
pts;
1108 for (
i = 0; i<delay && pts_buffer[i] > pts_buffer[
i + 1];
i++)
1109 FFSWAP(int64_t, pts_buffer[
i], pts_buffer[
i + 1]);
1119 AVStream *st =
s->streams[stream_index];
1120 PacketList *pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1140 for (pktl_it = pktl; pktl_it; pktl_it =
get_next_pkt(
s, st, pktl_it)) {
1170 int stream_index, int64_t
duration)
1172 PacketList *pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1190 av_log(
s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %"PRId64
") in the queue\n",
1198 pktl =
s->internal->packet_buffer ?
s->internal->packet_buffer :
s->internal->parse_queue;
1228 int64_t next_dts, int64_t next_pts)
1230 int num, den, presentation_delayed, delay,
i;
1245 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1271 presentation_delayed = 0;
1277 presentation_delayed = 1;
1295 if ( strcmp(
s->iformat->name,
"mov,mp4,m4a,3gp,3g2,mj2")
1296 && strcmp(
s->iformat->name,
"flv"))
1312 if (
pkt->
duration > 0 && (
s->internal->packet_buffer ||
s->internal->parse_queue))
1330 presentation_delayed = 1;
1334 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64
" delay:%d onein_oneout:%d\n",
1340 if ((delay == 0 || (delay == 1 && pc)) &&
1342 if (presentation_delayed) {
1360 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1361 next_dts != next_pts &&
1409 #if FF_API_CONVERGENCE_DURATION
1424 int stream_index,
int flush)
1426 AVPacket *out_pkt =
s->internal->parse_pkt;
1427 AVStream *st =
s->streams[stream_index];
1439 while (
size > 0 || (
flush && got_output)) {
1441 int64_t next_pts =
pkt->
pts;
1442 int64_t next_dts =
pkt->
dts;
1455 got_output = !!out_pkt->
size;
1466 if (!out_pkt->
buf) {
1489 (
AVRational) { 1, st->internal->avctx->sample_rate },
1515 &
s->internal->parse_queue_end,
1541 int ret,
i, got_packet = 0;
1544 while (!got_packet && !
s->internal->parse_queue) {
1553 for (
i = 0;
i <
s->nb_streams;
i++) {
1570 av_log(
s,
AV_LOG_DEBUG,
"Demuxer context update while decoder is open, closing and trying to re-open\n");
1587 #if FF_API_LAVF_AVCTX
1605 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1613 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64
", flags=%d\n",
1623 "%s, packets or times may be invalid.\n",
1665 if (!got_packet &&
s->internal->parse_queue)
1670 int discard_padding = 0;
1677 sample < st->internal->last_discard_sample)
1686 AV_WL32(p + 4, discard_padding);
1706 memcpy(dst_data, src_sd->
data, src_sd->
size);
1720 #if FF_API_LAVF_AVCTX
1726 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1727 "size=%d, duration=%"PRId64
", flags=%d\n",
1749 ret =
s->internal->packet_buffer
1751 &
s->internal->packet_buffer_end,
pkt)
1765 int wrap_bits =
s->streams[next_pkt->
stream_index]->pts_wrap_bits;
1768 int64_t last_dts = next_pkt->
dts;
1779 last_dts = pktl->
pkt.
dts;
1792 pktl =
s->internal->packet_buffer;
1800 &
s->internal->packet_buffer_end,
pkt);
1815 &
s->internal->packet_buffer_end,
1858 int best_stream = 0;
1859 int best_score = INT_MIN;
1861 if (
s->nb_streams <= 0)
1863 for (
i = 0;
i <
s->nb_streams;
i++) {
1883 if (score > best_score) {
1900 for (
i = 0;
i <
s->nb_streams;
i++) {
1920 if (
s->internal->inject_global_side_data)
1931 for (
i = 0;
i <
s->nb_streams;
i++) {
1943 AVStream *st =
s->streams[stream_index];
1944 unsigned int max_entries =
s->max_index_size /
sizeof(
AVIndexEntry);
1955 int *nb_index_entries,
1956 unsigned int *index_entries_allocated_size,
1957 int64_t
pos, int64_t timestamp,
1963 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
1969 if (size < 0 || size > 0x3FFFFFFF)
1976 index_entries_allocated_size,
1977 (*nb_index_entries + 1) *
1982 *index_entries = entries;
1988 index = (*nb_index_entries)++;
1989 ie = &entries[
index];
1992 ie = &entries[
index];
1996 memmove(entries +
index + 1, entries +
index,
1998 (*nb_index_entries)++;
1999 }
else if (ie->
pos ==
pos && distance < ie->min_distance)
2023 int64_t wanted_timestamp,
int flags)
2032 if (
b && entries[
b - 1].timestamp < wanted_timestamp)
2041 if (m ==
b && entries[m].timestamp >= wanted_timestamp) {
2048 if (timestamp >= wanted_timestamp)
2050 if (timestamp <= wanted_timestamp)
2056 while (m >= 0 && m < nb_entries &&
2060 if (m == nb_entries)
2068 int64_t pos_delta = 0;
2077 "Protocol name not provided, cannot determine if input is local or "
2078 "a network protocol, buffers and access patterns cannot be configured "
2079 "optimally without knowing the protocol\n");
2082 if (proto && !(strcmp(proto,
"file") && strcmp(proto,
"pipe") && strcmp(proto,
"cache")))
2085 for (ist1 = 0; ist1 <
s->nb_streams; ist1++) {
2087 for (ist2 = 0; ist2 <
s->nb_streams; ist2++) {
2102 if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
2113 if (
s->pb->buffer_size < pos_delta && pos_delta < (1<<24)) {
2122 s->pb->short_seek_threshold =
FFMAX(
s->pb->short_seek_threshold, pos_delta/2);
2125 if (skip < (1<<23)) {
2126 s->pb->short_seek_threshold =
FFMAX(
s->pb->short_seek_threshold, skip);
2133 wanted_timestamp,
flags);
2137 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
2139 int64_t ts = read_timestamp(
s, stream_index, ppos, pos_limit);
2140 if (stream_index >= 0)
2146 int64_t target_ts,
int flags)
2150 int64_t ts_min, ts_max, ts;
2155 if (stream_index < 0)
2164 st =
s->streams[stream_index];
2194 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
2214 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
2216 int64_t
step = 1024;
2217 int64_t limit, ts_max;
2219 int64_t pos_max = filesize - 1;
2224 &pos_max, limit, read_timestamp);
2231 int64_t tmp_pos = pos_max + 1;
2233 &tmp_pos, INT64_MAX, read_timestamp);
2239 if (tmp_pos >= filesize)
2252 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
2253 int64_t ts_min, int64_t ts_max,
2254 int flags, int64_t *ts_ret,
2256 int64_t *, int64_t))
2266 pos_min =
s->internal->data_offset;
2272 if (ts_min >= target_ts) {
2280 pos_limit = pos_max;
2283 if (ts_max <= target_ts) {
2291 while (pos_min < pos_limit) {
2293 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
2297 if (no_change == 0) {
2298 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2302 pos_min - approximate_keyframe_distance;
2303 }
else if (no_change == 1) {
2305 pos = (pos_min + pos_limit) >> 1;
2313 else if (
pos > pos_limit)
2324 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2325 pos_min,
pos, pos_max,
2327 pos_limit, start_pos, no_change);
2332 if (target_ts <= ts) {
2333 pos_limit = start_pos - 1;
2337 if (target_ts >= ts) {
2360 int64_t pos_min, pos_max;
2362 pos_min =
s->internal->data_offset;
2367 else if (
pos > pos_max)
2372 s->io_repositioned = 1;
2378 int64_t timestamp,
int flags)
2385 st =
s->streams[stream_index];
2389 if (index < 0 && st->nb_index_entries &&
2390 timestamp < st->index_entries[0].timestamp)
2393 if (index < 0 || index == st->nb_index_entries - 1) {
2404 if ((
ret =
avio_seek(
s->pb,
s->internal->data_offset, SEEK_SET)) < 0)
2412 }
while (read_status ==
AVERROR(EAGAIN));
2413 if (read_status < 0)
2421 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);
2434 if (
s->iformat->read_seek)
2435 if (
s->iformat->read_seek(
s, stream_index, timestamp,
flags) >= 0)
2446 int64_t timestamp,
int flags)
2458 if (stream_index < 0) {
2460 if (stream_index < 0)
2463 st =
s->streams[stream_index];
2470 if (
s->iformat->read_seek) {
2472 ret =
s->iformat->read_seek(
s, stream_index, timestamp,
flags);
2478 if (
s->iformat->read_timestamp &&
2490 int64_t timestamp,
int flags)
2494 if (
s->iformat->read_seek2 && !
s->iformat->read_seek) {
2495 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2513 int64_t ts, int64_t max_ts,
int flags)
2515 if (min_ts > ts || max_ts < ts)
2517 if (stream_index < -1 || stream_index >= (
int)
s->nb_streams)
2524 if (
s->iformat->read_seek2) {
2528 if (stream_index == -1 &&
s->nb_streams == 1) {
2540 ret =
s->iformat->read_seek2(
s, stream_index, min_ts,
2548 if (
s->iformat->read_timestamp) {
2554 if (
s->iformat->read_seek || 1) {
2557 if (
ret<0 && ts != min_ts && max_ts != ts) {
2604 int64_t
start_time, start_time1, start_time_text, end_time, end_time1, end_time_text;
2605 int64_t
duration, duration1, duration_text, filesize;
2610 start_time_text = INT64_MAX;
2611 end_time = INT64_MIN;
2612 end_time_text = INT64_MIN;
2614 duration_text = INT64_MIN;
2624 start_time_text =
FFMIN(start_time_text, start_time1);
2630 if (end_time1 !=
AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
2631 end_time1 += start_time1;
2633 end_time_text =
FFMAX(end_time_text, end_time1);
2635 end_time =
FFMAX(end_time, end_time1);
2648 duration_text =
FFMAX(duration_text, duration1);
2658 if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time <
AV_TIME_BASE))
2659 end_time = end_time_text;
2660 else if (end_time < end_time_text)
2670 if (end_time != INT64_MIN) {
2718 int i, show_warning = 0;
2723 int64_t bit_rate = 0;
2765 "Estimating duration from bitrate, this may be inaccurate\n");
2768 #define DURATION_MAX_READ_SIZE 250000LL
2769 #define DURATION_MAX_RETRY 6
2776 int num, den, read_size,
i,
ret;
2777 int found_duration = 0;
2791 "start time for stream %d is not set in estimate_timings_from_pts\n",
i);
2800 av_log(ic,
AV_LOG_INFO,
"Skipping duration calculation in estimate_timings_from_pts\n");
2801 goto skip_duration_calc;
2809 is_end = found_duration;
2925 file_size =
FFMAX(0, file_size);
2955 if (st->time_base.den)
2961 "format: start_time: %s duration: %s (estimate from %s) bitrate=%"PRId64
" kb/s\n",
2973 #define FAIL(errmsg) do { \
2975 *errmsg_ptr = errmsg; \
2981 FAIL(
"unknown codec");
2985 FAIL(
"unspecified frame size");
2988 FAIL(
"unspecified sample format");
2990 FAIL(
"unspecified sample rate");
2992 FAIL(
"unspecified number of channels");
2994 FAIL(
"no decodable DTS frames");
2998 FAIL(
"unspecified size");
3000 FAIL(
"unspecified pixel format");
3003 FAIL(
"no frame in rv30/40 and no sar");
3007 FAIL(
"unspecified size");
3022 int got_picture = 1,
ret = 0;
3026 int do_skip_frame = 0;
3052 if (
s->codec_whitelist)
3096 &got_picture, &
pkt);
3109 if (!
pkt.
data && !got_picture)
3113 if (do_skip_frame) {
3145 if (bps <= 0 || bps > 64)
3160 if (sflags & (1 << (
bps - 1))) {
3204 for (
i = 0; tags && tags[
i];
i++) {
3207 if (codec_tags->
id ==
id) {
3220 for (
i = 0; tags && tags[
i];
i++) {
3235 return (ch1 > ch2) - (ch1 < ch2);
3241 int64_t max_time = 0;
3247 if (
s->duration > 0 &&
s->start_time < INT64_MAX -
s->duration)
3248 max_time =
s->duration +
3251 for (
i = 0;
i <
s->nb_chapters;
i++)
3252 timetable[
i] =
s->chapters[
i];
3255 for (
i = 0;
i <
s->nb_chapters;
i++)
3262 if (
i + 1 <
s->nb_chapters) {
3266 if (next_start > ch->
start && next_start < end)
3269 ch->
end = (end == INT64_MAX || end < ch->
start) ? ch->
start : end;
3278 return (
i + 1) * 1001;
3282 return (
i + 31) * 1001 * 12;
3286 return ((
const int[]) { 80, 120, 240})[
i] * 1001 * 12;
3290 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[
i] * 1000 * 12;
3301 if (
c->time_base.den >= 101LL *
c->time_base.num ||
3302 c->time_base.den < 5LL *
c->time_base.num ||
3354 && ts - (uint64_t)last < INT64_MAX) {
3369 for (j= 0; j<2; j++) {
3370 int64_t ticks =
llrint(sdts+j*0.5);
3371 double error= sdts - ticks + j*0.5;
3390 if (error0 > 0.04 && error1 > 0.04) {
3426 double best_error= 0.01;
3441 for (k= 0; k<2; k++) {
3446 if (error < best_error && best_error> 0.000000001) {
3455 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3577 side_data->
size = 0;
3597 memcpy(dst_data, sd_src->
data, sd_src->
size);
3604 int i, count = 0,
ret = 0, j;
3614 int64_t max_stream_analyze_duration;
3615 int64_t max_subtitle_analyze_duration;
3617 int eof_reached = 0;
3620 flush_codecs = probesize > 0;
3624 max_stream_analyze_duration = max_analyze_duration;
3625 max_subtitle_analyze_duration = max_analyze_duration;
3626 if (!max_analyze_duration) {
3627 max_stream_analyze_duration =
3637 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d nb_streams:%d\n",
3655 #if FF_API_LAVF_AVCTX
3675 "%s, packets or times may be invalid.\n",
3685 goto find_stream_info_err;
3704 && codec && !avctx->
codec) {
3707 "Failed to open codec in %s\n",__FUNCTION__);
3712 if (codec && !avctx->
codec)
3715 "Failed to open codec in %s\n",__FUNCTION__);
3722 #if FF_API_R_FRAME_RATE
3732 int analyzed_all_streams;
3741 int fps_analyze_framecount = 20;
3751 fps_analyze_framecount *= 2;
3753 fps_analyze_framecount = 0;
3757 fps_analyze_framecount = 0;
3764 if (count < fps_analyze_framecount)
3783 analyzed_all_streams = 0;
3784 if (!missing_streams || !*missing_streams)
3786 analyzed_all_streams = 1;
3798 if (read_size >= probesize) {
3801 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3808 "Stream #%d: not enough frames to estimate rate; "
3809 "consider increasing probesize\n",
i);
3830 goto unref_then_goto_end;
3845 goto unref_then_goto_end;
3854 "Non-increasing DTS in stream %d: packet %d with DTS "
3855 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3871 "DTS discontinuity in stream %d: packet %d with DTS "
3872 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3905 if (analyzed_all_streams) limit = max_analyze_duration;
3907 else limit = max_stream_analyze_duration;
3910 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
3928 #if FF_API_R_FRAME_RATE
3937 goto unref_then_goto_end;
3961 for (stream_index = 0; stream_index < ic->
nb_streams; stream_index++) {
3962 st = ic->
streams[stream_index];
3966 if (codec && !avctx->
codec) {
3972 "Failed to open codec in %s\n",__FUNCTION__);
4004 "decoding for stream %d failed\n", st->
index);
4027 double best_error = 0.01;
4045 if (
error < best_error) {
4047 best_fps = std_fps.
num;
4053 if (
error < best_error) {
4055 best_fps = std_fps.
num;
4061 best_fps, 12 * 1001, INT_MAX);
4123 goto find_stream_info_err;
4129 "Could not find codec parameters for stream %d (%s): %s\n"
4130 "Consider increasing the value for the 'analyzeduration' (%"PRId64
") and 'probesize' (%"PRId64
") options\n",
4139 goto find_stream_info_err;
4148 goto find_stream_info_err;