40 #define KEYFRAMES_TAG "keyframes"
41 #define KEYFRAMES_TIMESTAMP_TAG "times"
42 #define KEYFRAMES_BYTEOFFSET_TAG "filepositions"
44 #define VALIDATE_INDEX_TS_THRESH 2500
51 int new_extradata_size[2];
70 d[3] < 5 && d[5] == 0 &&
99 switch (flv_codecid) {
102 codec_id = bits_per_coded_sample == 8
109 return codec_id == acodec->
codec_id;
111 codec_id = bits_per_coded_sample == 8
114 return codec_id == acodec->
codec_id;
141 switch (flv_codecid) {
205 switch (flv_codecid) {
224 int flv_codecid,
int read)
227 switch (flv_codecid) {
268 if (length >= buffsize) {
275 buffer[length] =
'\0';
284 unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i;
287 int64_t *times =
NULL;
288 int64_t *filepositions =
NULL;
297 int64_t *current_array;
310 if (!(times =
av_mallocz(
sizeof(*times) * arraylen))) {
315 current_array = times;
318 if (!(filepositions =
av_mallocz(
sizeof(*filepositions) * arraylen))) {
322 fileposlen = arraylen;
323 current_array = filepositions;
329 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++) {
333 current_array[i] = num_val;
335 if (times && filepositions) {
343 if (!ret && timeslen == fileposlen) {
344 for (i = 0; i < fileposlen; i++) {
361 if (ret < 0 &&
avio_seek(ioc, initial_pos, SEEK_SET) > 0)
393 if ((vstream || astream) && key &&
425 unsigned int arraylen, i;
428 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++)
442 if (depth == 1 && key) {
443 acodec = astream ? astream->
codec :
NULL;
444 vcodec = vstream ? vstream->
codec :
NULL;
448 if (!strcmp(key,
"duration"))
450 else if (!strcmp(key,
"videodatarate") && vcodec &&
451 0 <= (
int)(num_val * 1024.0))
452 vcodec->
bit_rate = num_val * 1024.0;
453 else if (!strcmp(key,
"audiodatarate") && acodec &&
454 0 <= (
int)(num_val * 1024.0))
455 acodec->
bit_rate = num_val * 1024.0;
456 else if (!strcmp(key,
"datastream")) {
462 if (!strcmp(key,
"videocodecid") && vcodec) {
464 }
else if (!strcmp(key,
"audiocodecid") && acodec) {
467 }
else if (!strcmp(key,
"audiosamplerate") && acodec) {
469 }
else if (!strcmp(key,
"audiosamplesize") && acodec) {
471 }
else if (!strcmp(key,
"stereo") && acodec) {
476 }
else if (!strcmp(key,
"width") && vcodec) {
477 vcodec->
width = num_val;
478 }
else if (!strcmp(key,
"height") && vcodec) {
484 if (!strcmp(key,
"duration") ||
485 !strcmp(key,
"filesize") ||
486 !strcmp(key,
"width") ||
487 !strcmp(key,
"height") ||
488 !strcmp(key,
"videodatarate") ||
489 !strcmp(key,
"framerate") ||
490 !strcmp(key,
"videocodecid") ||
491 !strcmp(key,
"audiodatarate") ||
492 !strcmp(key,
"audiosamplerate") ||
493 !strcmp(key,
"audiosamplesize") ||
494 !strcmp(key,
"stereo") ||
495 !strcmp(key,
"audiocodecid") ||
496 !strcmp(key,
"datastream"))
500 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
504 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
516 AVStream *stream, *astream, *vstream;
533 if (!strcmp(buffer,
"onTextData"))
536 if (strcmp(buffer,
"onMetaData"))
567 "Broken FLV file, which says no streams present, "
568 "this might fail\n");
625 "Found invalid index entries, clearing the index.\n");
639 int nb = -1, ret, parse_name = 1;
679 int64_t dts, int64_t next)
748 int sample_rate = 0, channels = 0;
758 av_dlog(s,
"type:%d, size:%d, dts:%"PRId64
"\n", type, size, dts);
766 if (pos == validate_pos) {
774 }
else if (pos > validate_pos) {
793 if ((flags & 0xf0) == 0x50)
801 "skipping flv packet: type %d, size %d, flags %d\n",
819 }
else if (!is_audio &&
860 int bits_per_coded_sample;
902 "negative cts, previous timestamps might be wrong\n");
921 if (t && !strcmp(t->
value,
"Omnia A/XE"))
932 av_dlog(s,
"mp4a config channels %d sample rate %d\n",
982 int64_t ts,
int flags)
989 #define OFFSET(x) offsetof(FLVContext, x)
990 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
992 {
"flv_metadata",
"Allocate streams according to the onMetaData array",
OFFSET(trust_metadata),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VD },
1012 .extensions =
"flv",
1013 .priv_class = &
class,