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
129 MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
131 MAKE_ACCESSORS(AVFormatContext, format,
int, metadata_header_padding)
134 #if FF_API_OLD_OPEN_CALLBACKS
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;
210 const AVCodec *codec;
212 #if CONFIG_H264_DECODER
226 if (probe_codec->
id == codec_id &&
237 #if FF_API_FORMAT_GET_SET
238 int av_format_get_probe_score(
const AVFormatContext *
s)
245 #define SANE_CHUNK_SIZE (50000000)
251 if (remaining < size) {
254 s->
maxsize = newsize - !newsize;
256 remaining=
FFMAX(remaining, 0);
259 if (s->
maxsize>= 0 && remaining+1 < size) {
271 int64_t orig_pos = pkt->
pos;
272 int orig_size = pkt->
size;
276 int prev_size = pkt->
size;
294 if (ret != read_size) {
307 return pkt->
size > orig_size ? pkt->
size - orig_size : ret;
337 static const struct {
365 "Probe with size=%d, packets=%d detected %s with score=%d\n",
368 for (i = 0; fmt_id_type[i].name; i++) {
369 if (!strcmp(fmt->
name, fmt_id_type[i].name)) {
379 #if FF_API_LAVF_AVCTX
430 "will be ignored with AVFMT_NOFILE format.\n");
470 (*plast_pktl)->next = pktl;
472 *packet_buffer = pktl;
487 "Attached picture on stream %d has invalid size, "
522 #if FF_API_LAVF_AVCTX
540 AVFormatContext *
s = *ps;
548 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
568 #if FF_API_FORMAT_FILENAME
570 av_strlcpy(s->filename, filename ? filename :
"",
sizeof(s->filename));
573 if ((ret =
init_input(s, filename, &tmp)) < 0)
641 av_log(s, level,
"Discarding ID3 tags because more suitable tags were found.\n");
647 if (id3v2_extra_meta) {
727 "Failed to reallocate probe buffer for stream %d\n",
740 "nothing to probe for stream %d\n", st->
index);
768 int i, pts_wrap_behavior;
769 int64_t pts_wrap_reference;
787 if (!first_program) {
814 program = first_program;
863 if (!pktl || ret ==
AVERROR(EAGAIN))
882 "Dropped corrupted packet (stream = %d)\n",
955 #if FF_API_LAVF_AVCTX
957 if ((!codec_framerate.den || !codec_framerate.num) && st->codec->time_base.den && st->codec->time_base.num)
964 switch (st->codecpar->codec_type) {
966 if (st->r_frame_rate.num && !pc &&
s->iformat) {
967 *pnum = st->r_frame_rate.den;
968 *pden = st->r_frame_rate.num;
969 }
else if (st->time_base.num * 1000LL > st->time_base.den) {
970 *pnum = st->time_base.num;
971 *pden = st->time_base.den;
972 }
else if (codec_framerate.den * 1000LL > codec_framerate.num) {
973 av_assert0(st->internal->avctx->ticks_per_frame);
976 codec_framerate.num * (int64_t)st->internal->avctx->ticks_per_frame,
979 if (pc && pc->repeat_pict) {
982 (*pnum) * (1LL + pc->repeat_pict),
989 if (st->internal->avctx->ticks_per_frame > 1 && !pc)
994 if (st->internal->avctx_inited) {
996 sample_rate = st->internal->avctx->sample_rate;
999 sample_rate = st->codecpar->sample_rate;
1001 if (frame_size <= 0 || sample_rate <= 0)
1026 #if CONFIG_H264_DECODER
1057 int64_t best_score = INT64_MAX;
1058 for (i = 0; i<delay; i++) {
1061 if (score < best_score) {
1063 dts = pts_buffer[i];
1068 for (i = 0; i<delay; i++) {
1070 int64_t
diff =
FFABS(pts_buffer[i] - dts)
1085 dts = pts_buffer[0];
1106 for (; pkt_buffer; pkt_buffer =
get_next_pkt(s, st, pkt_buffer)) {
1111 pts_buffer[0] = pkt_buffer->
pkt.
pts;
1112 for (i = 0; i<delay && pts_buffer[i] > pts_buffer[i + 1]; i++)
1113 FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]);
1143 for (pktl_it = pktl; pktl_it; pktl_it =
get_next_pkt(s, st, pktl_it)) {
1147 pktl_it->
pkt.
pts += shift;
1150 pktl_it->
pkt.
dts += shift;
1165 st->start_time =
pts;
1168 st->start_time +=
av_rescale_q(st->skip_samples, (
AVRational){1, st->codecpar->sample_rate}, st->time_base);
1193 av_log(s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %"PRId64
") in the queue\n",
1230 int64_t next_dts, int64_t next_pts)
1232 int num, den, presentation_delayed, delay, i;
1247 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
1273 presentation_delayed = 0;
1279 presentation_delayed = 1;
1294 if (delay == 1 && pkt->
dts == pkt->
pts &&
1297 if ( strcmp(s->
iformat->
name,
"mov,mp4,m4a,3gp,3g2,mj2")
1332 presentation_delayed = 1;
1336 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64
" delay:%d onein_oneout:%d\n",
1342 if ((delay == 0 || (delay == 1 && pc)) &&
1344 if (presentation_delayed) {
1362 ((uint64_t)st->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1363 next_dts != next_pts &&
1365 pkt->
pts = next_dts;
1367 if ((uint64_t)pkt->
duration <= INT32_MAX)
1411 #if FF_API_CONVERGENCE_DURATION
1430 *pkt_buf_end =
NULL;
1444 int ret = 0, got_output = 0;
1455 while (size > 0 || (pkt == &
flush_pkt && got_output)) {
1457 int64_t next_pts = pkt->
pts;
1458 int64_t next_dts = pkt->
dts;
1462 &out_pkt.
data, &out_pkt.
size, data, size,
1471 got_output = !!out_pkt.
size;
1558 *pkt_buffer = pktl->
next;
1560 *pkt_buffer_end =
NULL;
1572 int ret = 0, i, got_packet = 0;
1602 av_log(s,
AV_LOG_DEBUG,
"Demuxer context update while decoder is open, closing and trying to re-open\n");
1617 #if FF_API_LAVF_AVCTX
1631 cur_pkt.
pts < cur_pkt.
dts) {
1633 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1641 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64
", flags=%d\n",
1651 "%s, packets or times may be invalid.\n",
1702 int discard_padding = 0;
1707 int64_t end_sample = sample +
duration;
1709 sample < st->last_discard_sample)
1718 AV_WL32(p + 4, discard_padding);
1738 memcpy(dst_data, src_sd->
data, src_sd->
size);
1752 #if FF_API_LAVF_AVCTX
1758 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1759 "size=%d, duration=%"PRId64
", flags=%d\n",
1795 int64_t last_dts = next_pkt->
dts;
1806 last_dts = pktl->
pkt.
dts;
1834 if (pktl && ret !=
AVERROR(EAGAIN)) {
1884 int best_stream = 0;
1885 int best_score = INT_MIN;
1909 if (score > best_score) {
1981 int *nb_index_entries,
1982 unsigned int *index_entries_allocated_size,
1983 int64_t pos, int64_t timestamp,
1989 if ((
unsigned) *nb_index_entries + 1 >= UINT_MAX /
sizeof(
AVIndexEntry))
2002 index_entries_allocated_size,
2003 (*nb_index_entries + 1) *
2008 *index_entries = entries;
2014 index = (*nb_index_entries)++;
2015 ie = &entries[
index];
2016 av_assert0(index == 0 || ie[-1].timestamp < timestamp);
2018 ie = &entries[
index];
2022 memmove(entries + index + 1, entries + index,
2024 (*nb_index_entries)++;
2025 }
else if (ie->
pos == pos && distance < ie->min_distance)
2045 timestamp, size, distance, flags);
2049 int64_t wanted_timestamp,
int flags)
2058 if (b && entries[b - 1].timestamp < wanted_timestamp)
2067 if (m == b && entries[m].timestamp >= wanted_timestamp) {
2074 if (timestamp >= wanted_timestamp)
2076 if (timestamp <= wanted_timestamp)
2082 while (m >= 0 && m < nb_entries &&
2086 if (m == nb_entries)
2094 int64_t pos_delta = 0;
2101 "Protocol name not provided, cannot determine if input is local or "
2102 "a network protocol, buffers and access patterns cannot be configured "
2103 "optimally without knowing the protocol\n");
2106 if (proto && !(strcmp(proto,
"file") && strcmp(proto,
"pipe") && strcmp(proto,
"cache")))
2109 for (ist1 = 0; ist1 < s->
nb_streams; ist1++) {
2111 for (ist2 = 0; ist2 < s->
nb_streams; ist2++) {
2126 if (e2_pts - e1_pts < time_tolerance)
2137 if (s->
pb->
buffer_size < pos_delta && pos_delta < (1<<24)) {
2143 if (skip < (1<<23)) {
2151 wanted_timestamp, flags);
2155 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
2157 int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
2158 if (stream_index >= 0)
2164 int64_t target_ts,
int flags)
2168 int64_t ts_min, ts_max, ts;
2173 if (stream_index < 0)
2182 st = s->
streams[stream_index];
2190 index =
FFMAX(index, 0);
2212 " dts_max=%s\n", pos_max, pos_limit,
av_ts2str(ts_max));
2216 pos =
ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
2232 int64_t (*read_timestamp)(
struct AVFormatContext *,
int , int64_t *, int64_t ))
2234 int64_t step = 1024;
2235 int64_t limit, ts_max;
2237 int64_t pos_max = filesize - 1;
2240 pos_max =
FFMAX(0, (pos_max) - step);
2242 &pos_max, limit, read_timestamp);
2249 int64_t tmp_pos = pos_max + 1;
2251 &tmp_pos, INT64_MAX, read_timestamp);
2257 if (tmp_pos >= filesize)
2270 int64_t pos_min, int64_t pos_max, int64_t pos_limit,
2271 int64_t ts_min, int64_t ts_max,
2272 int flags, int64_t *ts_ret,
2273 int64_t (*read_timestamp)(
struct AVFormatContext *,
int,
2274 int64_t *, int64_t))
2285 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2290 if (ts_min >= target_ts) {
2296 if ((ret =
ff_find_last_ts(s, stream_index, &ts_max, &pos_max, read_timestamp)) < 0)
2298 pos_limit = pos_max;
2301 if (ts_max <= target_ts) {
2309 while (pos_min < pos_limit) {
2311 "pos_min=0x%"PRIx64
" pos_max=0x%"PRIx64
" dts_min=%s dts_max=%s\n",
2315 if (no_change == 0) {
2316 int64_t approximate_keyframe_distance = pos_max - pos_limit;
2318 pos =
av_rescale(target_ts - ts_min, pos_max - pos_min,
2320 pos_min - approximate_keyframe_distance;
2321 }
else if (no_change == 1) {
2323 pos = (pos_min + pos_limit) >> 1;
2331 else if (pos > pos_limit)
2342 " target:%s limit:%"PRId64
" start:%"PRId64
" noc:%d\n",
2343 pos_min, pos, pos_max,
2345 pos_limit, start_pos, no_change);
2350 if (target_ts <= ts) {
2351 pos_limit = start_pos - 1;
2355 if (target_ts >= ts) {
2365 ts_min =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2367 ts_max =
ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
2376 int64_t pos,
int flags)
2378 int64_t pos_min, pos_max;
2385 else if (pos > pos_max)
2396 int64_t timestamp,
int flags)
2403 st = s->
streams[stream_index];
2407 if (index < 0 && st->nb_index_entries &&
2408 timestamp < st->index_entries[0].timestamp)
2411 if (index < 0 || index == st->nb_index_entries - 1) {
2429 }
while (read_status ==
AVERROR(EAGAIN));
2430 if (read_status < 0)
2438 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);
2463 int64_t timestamp,
int flags)
2475 if (stream_index < 0) {
2477 if (stream_index < 0)
2480 st = s->
streams[stream_index];
2507 int64_t timestamp,
int flags)
2512 int64_t min_ts = INT64_MIN, max_ts = INT64_MAX;
2518 flags & ~AVSEEK_FLAG_BACKWARD);
2530 int64_t ts, int64_t max_ts,
int flags)
2532 if (min_ts > ts || max_ts < ts)
2534 if (stream_index < -1 || stream_index >= (
int)s->
nb_streams)
2545 if (stream_index == -1 && s->
nb_streams == 1) {
2552 time_base.
num * (int64_t)AV_TIME_BASE,
2574 if (ret<0 && ts != min_ts && max_ts != ts) {
2575 ret =
av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
2621 int64_t
start_time, start_time1, start_time_text, end_time, end_time1, end_time_text;
2622 int64_t
duration, duration1, duration_text, filesize;
2626 start_time = INT64_MAX;
2627 start_time_text = INT64_MAX;
2628 end_time = INT64_MIN;
2629 end_time_text = INT64_MIN;
2630 duration = INT64_MIN;
2631 duration_text = INT64_MIN;
2641 start_time_text =
FFMIN(start_time_text, start_time1);
2643 start_time =
FFMIN(start_time, start_time1);
2647 if (end_time1 !=
AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
2648 end_time1 += start_time1;
2650 end_time_text =
FFMAX(end_time_text, end_time1);
2652 end_time =
FFMAX(end_time, end_time1);
2665 duration_text =
FFMAX(duration_text, duration1);
2667 duration =
FFMAX(duration, duration1);
2670 if (start_time == INT64_MAX || (start_time > start_time_text && start_time - (uint64_t)start_time_text <
AV_TIME_BASE))
2671 start_time = start_time_text;
2672 else if (start_time > start_time_text)
2675 if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time < AV_TIME_BASE))
2676 end_time = end_time_text;
2677 else if (end_time < end_time_text)
2678 av_log(ic,
AV_LOG_VERBOSE,
"Ignoring outlier non primary stream endtime %f\n", end_time_text / (
float)AV_TIME_BASE);
2680 if (duration == INT64_MIN || (duration < duration_text && duration_text - duration < AV_TIME_BASE))
2681 duration = duration_text;
2682 else if (duration < duration_text)
2683 av_log(ic,
AV_LOG_VERBOSE,
"Ignoring outlier non primary stream duration %f\n", duration_text / (
float)AV_TIME_BASE);
2685 if (start_time != INT64_MAX) {
2687 if (end_time != INT64_MIN) {
2696 }
else if (end_time >= start_time && end_time - (uint64_t)start_time <= INT64_MAX) {
2697 duration =
FFMAX(duration, end_time - start_time);
2706 double bitrate = (double) filesize * 8.0 * AV_TIME_BASE /
2708 if (bitrate >= 0 && bitrate <= INT64_MAX)
2735 int i, show_warning = 0;
2740 int64_t bit_rate = 0;
2782 "Estimating duration from bitrate, this may be inaccurate\n");
2785 #define DURATION_MAX_READ_SIZE 250000LL
2786 #define DURATION_MAX_RETRY 6
2793 int num, den, read_size, i, ret;
2794 int found_duration = 0;
2808 "start time for stream %d is not set in estimate_timings_from_pts\n", i);
2817 av_log(ic,
AV_LOG_INFO,
"Skipping duration calculation in estimate_timings_from_pts\n");
2818 goto skip_duration_calc;
2826 is_end = found_duration;
2839 }
while (ret ==
AVERROR(EAGAIN));
2842 read_size += pkt->
size;
2899 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no PTS found at end of file, duration not set\n", i);
2901 av_log(ic,
AV_LOG_DEBUG,
"stream %d : no TS found at start of file, duration not set\n", i);
2930 file_size =
FFMAX(0, file_size);
2957 (
double) st->start_time *
av_q2d(st->time_base),
2958 (
double) st->duration *
av_q2d(st->time_base));
2961 "format: start_time: %0.3f duration: %0.3f bitrate=%"PRId64
" kb/s\n",
2972 #define FAIL(errmsg) do { \
2974 *errmsg_ptr = errmsg; \
2980 FAIL(
"unknown codec");
2984 FAIL(
"unspecified frame size");
2987 FAIL(
"unspecified sample format");
2989 FAIL(
"unspecified sample rate");
2991 FAIL(
"unspecified number of channels");
2993 FAIL(
"no decodable DTS frames");
2997 FAIL(
"unspecified size");
2999 FAIL(
"unspecified pixel format");
3002 FAIL(
"no frame in rv30/40 and no sar");
3006 FAIL(
"unspecified size");
3020 const AVCodec *codec;
3021 int got_picture = 1, ret = 0;
3025 int do_skip_frame = 0;
3046 av_dict_set(options ? options : &thread_opt,
"threads",
"1", 0);
3049 ret =
avcodec_open2(avctx, codec, options ? options : &thread_opt);
3071 while ((pkt.
size > 0 || (!pkt.
data && got_picture)) &&
3091 &got_picture, &pkt);
3102 if (!pkt.
data && !got_picture)
3106 if (do_skip_frame) {
3128 if (tag == tags[i].tag)
3138 if (bps <= 0 || bps > 64)
3153 if (sflags & (1 << (bps - 1))) {
3197 for (i = 0; tags && tags[i]; i++) {
3200 if (codec_tags->
id ==
id) {
3201 *tag = codec_tags->
tag;
3213 for (i = 0; tags && tags[i]; i++) {
3224 int64_t max_time = 0;
3241 if (j != i && next_start > ch->
start && next_start < end)
3244 ch->
end = (end == INT64_MAX || end < ch->
start) ? ch->
start : end;
3251 return (i + 1) * 1001;
3255 return (i + 31) * 1001 * 12;
3259 return ((
const int[]) { 80, 120, 240})[i] * 1001 * 12;
3263 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[i] * 1000 * 12;
3327 && ts - (uint64_t)last < INT64_MAX) {
3341 double sdts = dts*framerate/(1001*12);
3342 for (j= 0; j<2; j++) {
3343 int64_t ticks =
llrint(sdts+j*0.5);
3344 double error= sdts - ticks + j*0.5;
3361 if (error0 > 0.04 && error1 > 0.04) {
3396 double best_error= 0.01;
3411 for (k= 0; k<2; k++) {
3416 if (error < best_error && best_error> 0.000000001) {
3425 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
3566 int i,
count = 0, ret = 0, j;
3576 int64_t max_stream_analyze_duration;
3577 int64_t max_subtitle_analyze_duration;
3579 int eof_reached = 0;
3582 flush_codecs = probesize > 0;
3586 max_stream_analyze_duration = max_analyze_duration;
3587 max_subtitle_analyze_duration = max_analyze_duration;
3588 if (!max_analyze_duration) {
3589 max_stream_analyze_duration =
3599 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d nb_streams:%d\n",
3603 const AVCodec *codec;
3617 #if FF_API_LAVF_AVCTX
3637 "%s, packets or times may be invalid.\n",
3647 goto find_stream_info_err;
3655 av_dict_set(options ? &options[i] : &thread_opt,
"threads",
"1", 0);
3662 && codec && !avctx->
codec) {
3663 if (
avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
3665 "Failed to open codec in %s\n",__FUNCTION__);
3670 if (codec && !avctx->
codec)
3671 if (
avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
3673 "Failed to open codec in %s\n",__FUNCTION__);
3680 #if FF_API_R_FRAME_RATE
3689 int analyzed_all_streams;
3698 int fps_analyze_framecount = 20;
3708 fps_analyze_framecount *= 2;
3710 fps_analyze_framecount = 0;
3714 fps_analyze_framecount = 0;
3721 if (count < fps_analyze_framecount)
3740 analyzed_all_streams = 0;
3741 if (!missing_streams || !*missing_streams)
3743 analyzed_all_streams = 1;
3755 if (read_size >= probesize) {
3758 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
3765 "Stream #%d: not enough frames to estimate rate; "
3766 "consider increasing probesize\n", i);
3789 goto find_stream_info_err;
3794 read_size += pkt->
size;
3800 goto find_stream_info_err;
3809 "Non-increasing DTS in stream %d: packet %d with DTS "
3810 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3826 "DTS discontinuity in stream %d: packet %d with DTS "
3827 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
3858 if (analyzed_all_streams) limit = max_analyze_duration;
3860 else limit = max_stream_analyze_duration;
3863 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
3879 #if FF_API_R_FRAME_RATE
3888 goto find_stream_info_err;
3901 (options && i < orig_nb_streams) ? &options[i] :
NULL);
3912 for (stream_index = 0; stream_index < ic->
nb_streams; stream_index++) {
3913 st = ic->
streams[stream_index];
3917 if (codec && !avctx->
codec) {
3921 if (
avcodec_open2(avctx, codec, (options && stream_index < orig_nb_streams) ? &options[stream_index] : &opts) < 0)
3923 "Failed to open codec in %s\n",__FUNCTION__);
3949 (options && i < orig_nb_streams)
3950 ? &options[i] :
NULL);
3955 "decoding for stream %d failed\n", st->
index);
3978 double best_error = 0.01;
3996 if (error < best_error) {
3998 best_fps = std_fps.
num;
4002 error = fabs(
av_q2d(codec_frame_rate) /
4004 if (error < best_error) {
4006 best_fps = std_fps.
num;
4012 best_fps, 12 * 1001, INT_MAX);
4074 goto find_stream_info_err;
4080 "Could not find codec parameters for stream %d (%s): %s\n"
4081 "Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
4099 goto find_stream_info_err;
4109 #if FF_API_LAVF_AVCTX
4113 goto find_stream_info_err;
4125 if (st->codec->codec_tag !=
MKTAG(
't',
'm',
'c',
'd')) {
4133 if (!st->codec->subtitle_header)
4134 goto find_stream_info_err;
4137 st->codec->subtitle_header_size);
4150 find_stream_info_err:
4161 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
4184 int wanted_stream_nb,
int related_stream,
4185 AVCodec **decoder_ret,
int flags)
4189 int best_count = -1, best_multiframe = -1, best_disposition = -1;
4190 int count, multiframe, disposition;
4191 int64_t best_bitrate = -1;
4193 unsigned *program =
NULL;
4196 if (related_stream >= 0 && wanted_stream_nb < 0) {
4204 int real_stream_index = program ? program[i] : i;
4209 if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
4224 multiframe =
FFMIN(5, count);
4225 if ((best_disposition > disposition) ||
4226 (best_disposition == disposition && best_multiframe > multiframe) ||
4227 (best_disposition == disposition && best_multiframe == multiframe && best_bitrate > bitrate) ||
4228 (best_disposition == disposition && best_multiframe == multiframe && best_bitrate == bitrate && best_count >= count))
4230 best_disposition = disposition;
4233 best_multiframe = multiframe;
4234 ret = real_stream_index;
4236 if (program && i == nb_streams - 1 && ret < 0) {
4244 *decoder_ret = (AVCodec*)best_decoder;
4314 #if FF_API_LAVF_FFSERVER
4316 av_freep(&dst->recommended_encoder_configuration);
4317 if (src->recommended_encoder_configuration) {
4318 const char *conf_str = src->recommended_encoder_configuration;
4319 dst->recommended_encoder_configuration =
av_strdup(conf_str);
4320 if (!dst->recommended_encoder_configuration)
4363 #if FF_API_LAVF_AVCTX
4372 #if FF_API_LAVF_FFSERVER
4374 av_freep(&st->recommended_encoder_configuration);
4463 av_log(s,
AV_LOG_ERROR,
"Number of streams exceeds max_streams parameter (%d), see the documentation if you wish to increase it\n", s->
max_streams);
4480 #if FF_API_LAVF_AVCTX
4504 #if FF_API_LAVF_AVCTX
4507 st->codec->bit_rate = 0;
4537 #if FF_API_R_FRAME_RATE
4584 int64_t
start, int64_t
end,
const char *title)
4590 av_log(s,
AV_LOG_ERROR,
"Chapter end time %"PRId64
" before start %"PRId64
"\n", end, start);
4648 uint64_t ntp_ts, frac_part, sec;
4652 sec = ntp_time_us / 1000000;
4653 usec = ntp_time_us % 1000000;
4656 frac_part = usec * 0xFFFFFFFFULL;
4657 frac_part /= 1000000;
4659 if (sec > 0xFFFFFFFFULL)
4663 ntp_ts |= frac_part;
4671 char *q, buf1[20],
c;
4672 int nd,
len, percentd_found;