40 #define VALIDATE_INDEX_TS_THRESH 2500
67 d[3] < 5 && d[5] == 0 &&
70 int is_live = !memcmp(d + offset + 40,
"NGINX RTMP", 10);
115 switch (flv_codecid) {
118 codec_id = bits_per_coded_sample == 8
125 return codec_id == acodec->
codec_id;
127 codec_id = bits_per_coded_sample == 8
130 return codec_id == acodec->
codec_id;
157 switch (flv_codecid) {
221 switch (flv_codecid) {
240 int flv_codecid,
int read)
243 switch (flv_codecid) {
289 if (length >= buffsize) {
305 unsigned int timeslen = 0, fileposlen = 0, i;
307 int64_t *times = NULL;
308 int64_t *filepositions = NULL;
322 int64_t **current_array;
323 unsigned int arraylen;
334 current_array = ×
338 current_array = &filepositions;
339 fileposlen = arraylen;
345 if (!(*current_array =
av_mallocz(
sizeof(**current_array) * arraylen))) {
350 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++) {
355 if (times && filepositions) {
363 if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) {
364 for (i = 0; i < fileposlen; i++) {
412 if ((vstream || astream) && key &&
445 unsigned int arraylen, i;
448 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++)
464 acodec = astream ? astream->
codec : NULL;
465 vcodec = vstream ? vstream->
codec : NULL;
469 if (!strcmp(key,
"duration"))
471 else if (!strcmp(key,
"videodatarate") && vcodec &&
472 0 <= (
int)(num_val * 1024.0))
473 vcodec->
bit_rate = num_val * 1024.0;
474 else if (!strcmp(key,
"audiodatarate") && acodec &&
475 0 <= (
int)(num_val * 1024.0))
476 acodec->
bit_rate = num_val * 1024.0;
477 else if (!strcmp(key,
"datastream")) {
483 if (!strcmp(key,
"videocodecid") && vcodec) {
485 }
else if (!strcmp(key,
"audiocodecid") && acodec) {
488 }
else if (!strcmp(key,
"audiosamplerate") && acodec) {
490 }
else if (!strcmp(key,
"audiosamplesize") && acodec) {
492 }
else if (!strcmp(key,
"stereo") && acodec) {
497 }
else if (!strcmp(key,
"width") && vcodec) {
498 vcodec->
width = num_val;
499 }
else if (!strcmp(key,
"height") && vcodec) {
507 ((!acodec && !strcmp(key,
"audiocodecid")) ||
508 (!vcodec && !strcmp(key,
"videocodecid"))))
511 if (!strcmp(key,
"duration") ||
512 !strcmp(key,
"filesize") ||
513 !strcmp(key,
"width") ||
514 !strcmp(key,
"height") ||
515 !strcmp(key,
"videodatarate") ||
516 !strcmp(key,
"framerate") ||
517 !strcmp(key,
"videocodecid") ||
518 !strcmp(key,
"audiodatarate") ||
519 !strcmp(key,
"audiosamplerate") ||
520 !strcmp(key,
"audiosamplesize") ||
521 !strcmp(key,
"stereo") ||
522 !strcmp(key,
"audiocodecid") ||
523 !strcmp(key,
"datastream"))
528 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
532 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
544 AVStream *stream, *astream, *vstream;
563 if (!strcmp(buffer,
"onTextData"))
566 if (strcmp(buffer,
"onMetaData") && strcmp(buffer,
"onCuePoint"))
649 "Found invalid index entries, clearing the index.\n");
663 int nb = -1,
ret, parse_name = 1;
703 int64_t dts, int64_t next)
771 int64_t next, pos, meta_pos;
784 av_dlog(s,
"type:%d, size:%d, dts:%"PRId64
" pos:%"PRId64
"\n", type, size, dts,
avio_tell(s->
pb));
792 if (pos == validate_pos) {
800 }
else if (pos > validate_pos) {
823 if (size > 13 + 1 + 4 && dts == 0) {
832 "Skipping flv packet: type %d, size %d, flags %d.\n",
898 else if (fsize >= 8 && fsize - 8 >= size) {
909 int bits_per_coded_sample;
952 "Negative cts, previous timestamps might be wrong.\n");
954 }
else if (
FFABS(dts - pts) > 1000*60*15) {
956 "invalid timestamps %"PRId64
" %"PRId64
"\n", dts, pts);
989 av_dlog(s,
"mp4a config channels %d sample rate %d\n",
1040 int64_t ts,
int flags)
1047 #define OFFSET(x) offsetof(FLVContext, x)
1048 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1050 {
"flv_metadata",
"Allocate streams according to the onMetaData array",
OFFSET(trust_metadata),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VD },
1070 .extensions =
"flv",
1071 .priv_class = &flv_class,
1090 .extensions =
"flv",
1091 .priv_class = &live_flv_class,