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++) {
414 if ((vstream || astream) && key &&
451 unsigned int arraylen, i;
454 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++)
469 acodec = astream ? astream->
codec :
NULL;
470 vcodec = vstream ? vstream->
codec :
NULL;
476 if (!strcmp(key,
"duration"))
478 else if (!strcmp(key,
"videodatarate") && vcodec &&
479 0 <= (
int)(num_val * 1024.0))
480 vcodec->
bit_rate = num_val * 1024.0;
481 else if (!strcmp(key,
"audiodatarate") && acodec &&
482 0 <= (
int)(num_val * 1024.0))
483 acodec->
bit_rate = num_val * 1024.0;
484 else if (!strcmp(key,
"datastream")) {
490 if (!strcmp(key,
"videocodecid") && vcodec) {
492 }
else if (!strcmp(key,
"audiocodecid") && acodec) {
495 }
else if (!strcmp(key,
"audiosamplerate") && acodec) {
497 }
else if (!strcmp(key,
"audiosamplesize") && acodec) {
499 }
else if (!strcmp(key,
"stereo") && acodec) {
504 }
else if (!strcmp(key,
"width") && vcodec) {
505 vcodec->
width = num_val;
506 }
else if (!strcmp(key,
"height") && vcodec) {
514 ((!acodec && !strcmp(key,
"audiocodecid")) ||
515 (!vcodec && !strcmp(key,
"videocodecid"))))
518 if (!strcmp(key,
"duration") ||
519 !strcmp(key,
"filesize") ||
520 !strcmp(key,
"width") ||
521 !strcmp(key,
"height") ||
522 !strcmp(key,
"videodatarate") ||
523 !strcmp(key,
"framerate") ||
524 !strcmp(key,
"videocodecid") ||
525 !strcmp(key,
"audiodatarate") ||
526 !strcmp(key,
"audiosamplerate") ||
527 !strcmp(key,
"audiosamplesize") ||
528 !strcmp(key,
"stereo") ||
529 !strcmp(key,
"audiocodecid") ||
530 !strcmp(key,
"datastream"))
535 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
539 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
548 #define TYPE_ONTEXTDATA 1
549 #define TYPE_UNKNOWN 2
554 AVStream *stream, *astream, *vstream;
573 if (!strcmp(buffer,
"onTextData"))
576 if (strcmp(buffer,
"onMetaData") && strcmp(buffer,
"onCuePoint"))
659 "Found invalid index entries, clearing the index.\n");
673 int nb = -1,
ret, parse_name = 1;
713 int64_t dts, int64_t next)
781 int64_t next, pos, meta_pos;
794 av_dlog(s,
"type:%d, size:%d, dts:%"PRId64
" pos:%"PRId64
"\n", type, size, dts,
avio_tell(s->
pb));
802 if (pos == validate_pos) {
810 }
else if (pos > validate_pos) {
833 if (size > 13 + 1 + 4 && dts == 0) {
842 "Skipping flv packet: type %d, size %d, flags %d.\n",
912 else if (fsize >= 8 && fsize - 8 >= size) {
923 int bits_per_coded_sample;
967 "Negative cts, previous timestamps might be wrong.\n");
969 }
else if (
FFABS(dts - pts) > 1000*60*15) {
971 "invalid timestamps %"PRId64
" %"PRId64
"\n", dts, pts);
1004 av_dlog(s,
"mp4a config channels %d sample rate %d\n",
1055 int64_t ts,
int flags)
1062 #define OFFSET(x) offsetof(FLVContext, x)
1063 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1065 {
"flv_metadata",
"Allocate streams according to the onMetaData array",
OFFSET(trust_metadata),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VD },
1085 .extensions =
"flv",
1086 .priv_class = &flv_class,
1105 .extensions =
"flv",
1106 .priv_class = &live_flv_class,