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++)
462 if (depth == 1 && key) {
463 acodec = astream ? astream->
codec : NULL;
464 vcodec = vstream ? vstream->
codec : NULL;
468 if (!strcmp(key,
"duration"))
470 else if (!strcmp(key,
"videodatarate") && vcodec &&
471 0 <= (
int)(num_val * 1024.0))
472 vcodec->
bit_rate = num_val * 1024.0;
473 else if (!strcmp(key,
"audiodatarate") && acodec &&
474 0 <= (
int)(num_val * 1024.0))
475 acodec->
bit_rate = num_val * 1024.0;
476 else if (!strcmp(key,
"datastream")) {
482 if (!strcmp(key,
"videocodecid") && vcodec) {
484 }
else if (!strcmp(key,
"audiocodecid") && acodec) {
487 }
else if (!strcmp(key,
"audiosamplerate") && acodec) {
489 }
else if (!strcmp(key,
"audiosamplesize") && acodec) {
491 }
else if (!strcmp(key,
"stereo") && acodec) {
496 }
else if (!strcmp(key,
"width") && vcodec) {
497 vcodec->
width = num_val;
498 }
else if (!strcmp(key,
"height") && vcodec) {
505 ((!acodec && !strcmp(key,
"audiocodecid")) ||
506 (!vcodec && !strcmp(key,
"videocodecid"))))
509 if (!strcmp(key,
"duration") ||
510 !strcmp(key,
"filesize") ||
511 !strcmp(key,
"width") ||
512 !strcmp(key,
"height") ||
513 !strcmp(key,
"videodatarate") ||
514 !strcmp(key,
"framerate") ||
515 !strcmp(key,
"videocodecid") ||
516 !strcmp(key,
"audiodatarate") ||
517 !strcmp(key,
"audiosamplerate") ||
518 !strcmp(key,
"audiosamplesize") ||
519 !strcmp(key,
"stereo") ||
520 !strcmp(key,
"audiocodecid") ||
521 !strcmp(key,
"datastream"))
525 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
529 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
541 AVStream *stream, *astream, *vstream;
560 if (!strcmp(buffer,
"onTextData"))
563 if (strcmp(buffer,
"onMetaData"))
646 "Found invalid index entries, clearing the index.\n");
660 int nb = -1,
ret, parse_name = 1;
700 int64_t dts, int64_t next)
768 int64_t next, pos, meta_pos;
781 av_dlog(s,
"type:%d, size:%d, dts:%"PRId64
" pos:%"PRId64
"\n", type, size, dts,
avio_tell(s->
pb));
789 if (pos == validate_pos) {
797 }
else if (pos > validate_pos) {
820 if (size > 13 + 1 + 4 && dts == 0) {
829 "Skipping flv packet: type %d, size %d, flags %d.\n",
892 else if (fsize >= 8 && fsize - 8 >= size) {
903 int bits_per_coded_sample;
946 "Negative cts, previous timestamps might be wrong.\n");
948 }
else if (
FFABS(dts - pts) > 1000*60*15) {
950 "invalid timestamps %"PRId64
" %"PRId64
"\n", dts, pts);
982 av_dlog(s,
"mp4a config channels %d sample rate %d\n",
1033 int64_t ts,
int flags)
1040 #define OFFSET(x) offsetof(FLVContext, x)
1041 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1043 {
"flv_metadata",
"Allocate streams according to the onMetaData array",
OFFSET(trust_metadata),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VD },
1063 .extensions =
"flv",
1064 .priv_class = &flv_class,
1083 .extensions =
"flv",
1084 .priv_class = &live_flv_class,