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];
67 if (d[0] ==
'F' && d[1] ==
'L' && d[2] ==
'V' && d[3] < 5 && d[5]==0 &&
AV_RB32(d+5)>8) {
103 return codec_id == acodec->
codec_id;
106 return codec_id == acodec->
codec_id;
133 switch(flv_codecid) {
184 switch (flv_codecid) {
206 switch(flv_codecid) {
239 if(length >= buffsize) {
246 buffer[length] =
'\0';
253 unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i;
256 int64_t *times =
NULL;
257 int64_t *filepositions =
NULL;
265 int64_t* current_array;
280 if (!(times =
av_mallocz(
sizeof(*times) * arraylen))) {
285 current_array = times;
287 if (!(filepositions =
av_mallocz(
sizeof(*filepositions) * arraylen))) {
291 fileposlen = arraylen;
292 current_array = filepositions;
296 for (i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++) {
300 current_array[i] = num_val;
302 if (times && filepositions) {
310 if (!ret && timeslen == fileposlen) {
311 for (i = 0; i < fileposlen; i++) {
328 if (ret < 0 &&
avio_seek(ioc, initial_pos, SEEK_SET) > 0)
356 if ((vstream || astream) && key && !strcmp(
KEYFRAMES_TAG, key) && depth == 1)
383 unsigned int arraylen, i;
386 for(i = 0; i < arraylen &&
avio_tell(ioc) < max_pos - 1; i++) {
399 if(depth == 1 && key) {
400 acodec = astream ? astream->
codec :
NULL;
401 vcodec = vstream ? vstream->
codec :
NULL;
404 if (!strcmp(key,
"duration"))
406 else if (!strcmp(key,
"videodatarate") && vcodec && 0 <= (
int)(num_val * 1024.0))
407 vcodec->
bit_rate = num_val * 1024.0;
408 else if (!strcmp(key,
"audiodatarate") && acodec && 0 <= (
int)(num_val * 1024.0))
409 acodec->
bit_rate = num_val * 1024.0;
410 else if (!strcmp(key,
"datastream")) {
416 if (!strcmp(key,
"videocodecid") && vcodec) {
419 if (!strcmp(key,
"audiocodecid") && acodec) {
423 if (!strcmp(key,
"audiosamplerate") && acodec) {
425 }
else if (!strcmp(key,
"audiosamplesize") && acodec) {
427 }
else if (!strcmp(key,
"stereo") && acodec) {
433 if (!strcmp(key,
"width") && vcodec) {
434 vcodec->
width = num_val;
436 if (!strcmp(key,
"height") && vcodec) {
442 if (!strcmp(key,
"duration") ||
443 !strcmp(key,
"filesize") ||
444 !strcmp(key,
"width") ||
445 !strcmp(key,
"height") ||
446 !strcmp(key,
"videodatarate") ||
447 !strcmp(key,
"framerate") ||
448 !strcmp(key,
"videocodecid") ||
449 !strcmp(key,
"audiodatarate") ||
450 !strcmp(key,
"audiosamplerate") ||
451 !strcmp(key,
"audiosamplesize") ||
452 !strcmp(key,
"stereo") ||
453 !strcmp(key,
"audiocodecid"))
457 av_strlcpy(str_val, num_val > 0 ?
"true" :
"false",
sizeof(str_val));
460 snprintf(str_val,
sizeof(str_val),
"%.f", num_val);
471 AVStream *stream, *astream, *vstream;
486 if (!strcmp(buffer,
"onTextData"))
489 if (strcmp(buffer,
"onMetaData"))
588 int64_t dts, int64_t next)
651 int sample_rate = 0, channels = 0;
660 av_dlog(s,
"type:%d, size:%d, dts:%"PRId64
"\n", type, size, dts);
668 if (pos == validate_pos) {
676 }
else if (pos > validate_pos) {
695 if ((flags & 0xf0) == 0x50)
703 av_log(s,
AV_LOG_DEBUG,
"skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
761 int bits_per_coded_sample;
819 av_dlog(s,
"mp4a config channels %d sample rate %d\n",
870 int64_t ts,
int flags)
877 #define OFFSET(x) offsetof(FLVContext, x)
878 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
880 {
"flv_metadata",
"Allocate streams according the onMetaData array",
OFFSET(trust_metadata),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VD},
901 .priv_class = &
class,