[PATCH] support for flvtool2 "keyframes based" generated index in FLV format decoder
Hi, Attached patch parse flvtool2 metadata "keyframes (times/fileopstions)" tags and use this data as index at least for seek operations. It is required in case when mplayer which use this part of ffmpeg code attempts to play FLV file via HTTP for example. Existing implementation attempt to download ALL content up to seek point before it can play it, but it is unacceptable to download unneded data (whole file if you seek to the end) as in case of low bandwidth seek operation will 'never' end. With this patch 'mplayer' can seek fast in such situations using this index. Alexander
Kharkov Alexander wrote:
Hi,
Attached patch parse flvtool2 metadata "keyframes (times/fileopstions)" tags and use this data as index at least for seek operations. It is required in case when mplayer which use this part of ffmpeg code attempts to play FLV file via HTTP for example. Existing implementation attempt to download ALL content up to seek point before it can play it, but it is unacceptable to download unneded data (whole file if you seek to the end) as in case of low bandwidth seek operation will 'never' end. With this patch 'mplayer' can seek fast in such situations using this index.
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c (revision 26327) +++ libavformat/flvdec.c (working copy) @@ -30,10 +30,51 @@ #include "avformat.h" #include "flv.h"
+#define FLVTOOL2_KEYFRAMES_TAG "keyframes" +#define FLVTOOL2_TIMESTAMP_TAG "times" +#define FLVTOOL2_BYTEOFFSET_TAG "filepositions"
is this really FLVTOOL2 specific? does it have to end up in the tag/variable name?
+ typedef struct { + int64_t byte_offset; + int64_t time_offset; +} FLVTool2KeyframesIndex;
dito
+typedef struct { + int keyframes_object_parse; + + int filepositions_array_parse; + int fill_filepositions; + int num_filepositions_processed; + + int times_array_parse; + int fill_timestamps; + int num_timestamps_processed; + + int num_indexed_keyframes; + + FLVTool2KeyframesIndex *indexes; +} FLVTool2Index;
dito
+typedef struct { int wrong_dts; ///< wrong dts due to negative cts + FLVTool2Index *flvtool2_index; } FLVContext;
+static void init_flv_context(FLVContext* flv) +{ + // initialize flvtool2 "keyframes" based index + flv->flvtool2_index = av_malloc(sizeof(FLVTool2Index) * 1); + flv->flvtool2_index->keyframes_object_parse = 0; + flv->flvtool2_index->filepositions_array_parse = 0; + flv->flvtool2_index->fill_filepositions = 0; + flv->flvtool2_index->num_filepositions_processed = 0; + flv->flvtool2_index->times_array_parse = 0; + flv->flvtool2_index->fill_timestamps = 0; + flv->flvtool2_index->num_timestamps_processed = 0; + flv->flvtool2_index->num_indexed_keyframes = 0; + flv->flvtool2_index->indexes = NULL; +};
av_mallocz...
+ static int flv_probe(AVProbeData *p) { const uint8_t *d; @@ -130,6 +171,8 @@ AMFDataType amf_type; char str_val[256]; double num_val; + unsigned int index_iter; + FLVContext *flv = s->priv_data;
num_val = 0; ioc = s->pb; @@ -138,7 +181,16 @@
switch(amf_type) { case AMF_DATA_TYPE_NUMBER: - num_val = av_int2dbl(get_be64(ioc)); break; + num_val = av_int2dbl(get_be64(ioc)); + if (flv->flvtool2_index->times_array_parse&& depth == 3&& + flv->flvtool2_index->num_timestamps_processed< flv->flvtool2_index->num_indexed_keyframes) { + flv->flvtool2_index->indexes[flv->flvtool2_index->num_timestamps_processed++].time_offset = num_val; + } + if (flv->flvtool2_index->filepositions_array_parse&& depth == 3 +&& flv->flvtool2_index->num_filepositions_processed< flv->flvtool2_index->num_indexed_keyframes) { + flv->flvtool2_index->indexes[flv->flvtool2_index->num_filepositions_processed++].byte_offset = num_val; + } + break; case AMF_DATA_TYPE_BOOL: num_val = get_byte(ioc); break; case AMF_DATA_TYPE_STRING: @@ -149,9 +201,21 @@ unsigned int keylen;
while(url_ftell(ioc)< max_pos - 2&& (keylen = get_be16(ioc))) { - url_fskip(ioc, keylen); //skip key string + get_buffer(ioc, str_val, keylen); + str_val[keylen] = '\0'; + if (flv->flvtool2_index->keyframes_object_parse&& !strcmp(FLVTOOL2_TIMESTAMP_TAG, str_val)&& depth == 1) { + flv->flvtool2_index->times_array_parse = 1; + } + if (flv->flvtool2_index->keyframes_object_parse&& !strcmp(FLVTOOL2_BYTEOFFSET_TAG, str_val)&& depth == 1) { + flv->flvtool2_index->filepositions_array_parse = 1; + } + + //url_fskip(ioc, keylen); //skip key string if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< 0) return -1; //if we couldn't skip, bomb out. + + flv->flvtool2_index->times_array_parse = 0; + flv->flvtool2_index->filepositions_array_parse = 0;
} if(get_byte(ioc) != AMF_END_OF_OBJECT) return -1; @@ -164,9 +228,14 @@ case AMF_DATA_TYPE_MIXEDARRAY: url_fskip(ioc, 4); //skip 32-bit max array index while(url_ftell(ioc)< max_pos - 2&& amf_get_string(ioc, str_val, sizeof(str_val))> 0) { + if (!strcmp(FLVTOOL2_KEYFRAMES_TAG, str_val)&& depth == 0) { + flv->flvtool2_index->keyframes_object_parse = 1; + } //this is the only case in which we would want a nested parse to not skip over the object if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1)< 0) return -1; + + flv->flvtool2_index->keyframes_object_parse = 0; } if(get_byte(ioc) != AMF_END_OF_OBJECT) return -1; @@ -175,10 +244,28 @@ unsigned int arraylen, i;
arraylen = get_be32(ioc); + if (flv->flvtool2_index->filepositions_array_parse&& depth == 2) { + // allocate array to keep indexes + if (flv->flvtool2_index->indexes == NULL) { + flv->flvtool2_index->indexes = av_malloc(sizeof(FLVTool2KeyframesIndex) * arraylen); + flv->flvtool2_index->num_indexed_keyframes = arraylen; + } + flv->flvtool2_index->fill_filepositions = 1; + } + if (flv->flvtool2_index->times_array_parse&& depth == 2) { + // allocate array to keep indexes + if (flv->flvtool2_index->indexes == NULL) { + flv->flvtool2_index->indexes = av_malloc(sizeof(FLVTool2KeyframesIndex) * arraylen); + flv->flvtool2_index->num_indexed_keyframes = arraylen; + } + flv->flvtool2_index->fill_timestamps = 1; + } for(i = 0; i< arraylen&& url_ftell(ioc)< max_pos - 1; i++) { if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< 0) return -1; //if we couldn't skip, bomb out. } + flv->flvtool2_index->fill_filepositions = 0; + flv->flvtool2_index->fill_timestamps = 0; }
I don't like how this is spaced out all over the code, but I guess this more due to how the flv reader works...
break; case AMF_DATA_TYPE_DATE: @@ -205,6 +292,14 @@ acodec->bit_rate = num_val * 1024.0; } else if (amf_type == AMF_DATA_TYPE_STRING) av_metadata_set2(&s->metadata, key, str_val, 0); + + for (index_iter = 0; index_iter< flv->flvtool2_index->num_indexed_keyframes; ++index_iter) { + int64_t ts = flv->flvtool2_index->indexes[index_iter].time_offset; + int64_t byte_offset = flv->flvtool2_index->indexes[index_iter].byte_offset; + av_add_index_entry(vstream, byte_offset, ts*1000, 0, 0, AVINDEX_KEYFRAME); + av_log(s, AV_LOG_DEBUG, + "add flvtool2 index entry: timestamp: %16"PRIX64", byte offset: %16"PRIX64"\n", ts, byte_offset); + }
you could drop the indexes right after this step to free the mem, no?
}
return 0; @@ -214,8 +309,11 @@ AMFDataType type; AVStream *stream, *astream, *vstream; ByteIOContext *ioc; + int i; char buffer[11]; //only needs to hold the string "onMetaData". Anything longer is something we don't want. + FLVContext *flv = s->priv_data; + init_flv_context(flv);
astream = NULL; vstream = NULL; @@ -491,6 +589,15 @@ } #endif
+static int flv_read_close(AVFormatContext *s) +{ + FLVContext *flv = s->priv_data; + if (flv->flvtool2_index->indexes != NULL) + av_free(flv->flvtool2_index->indexes); + av_free(flv->flvtool2_index); + return 0; +} + AVInputFormat flv_demuxer = { "flv", NULL_IF_CONFIG_SMALL("FLV format"), @@ -498,6 +605,7 @@ flv_probe, flv_read_header, flv_read_packet, + flv_read_close, .read_seek = flv_read_seek, #if 0 .read_seek2 = flv_read_seek2,
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
Thanks for review, agree with all your points, will fix and resent. Details: * "keyframes" metatag does not stated in FLV specs but often recommeded, I found at least one more free tool which inject it FLVMDI * index data really can be free right after it is passed to av_add_index_entry * code spread all over just because I want to touch exsting metadata parser behavior minmal (all this recursion, loops, etc.) that is why I did not create separate function which simply parse keyframes object On 20 January 2011 23:23, Vladimir Pantelic <vladoman at gmail.com> wrote:
Kharkov Alexander wrote:
Hi,
Attached patch parse flvtool2 metadata "keyframes (times/fileopstions)" tags and use this data as index at least for seek operations. It is required in case when mplayer which use this part of ffmpeg code attempts to play FLV file via HTTP for example. Existing implementation attempt to download ALL content up to seek point before it can play it, but it is unacceptable to download unneded data (whole file if you seek to the end) as in case of low bandwidth seek operation will 'never' end. With this patch 'mplayer' can seek fast in such situations using this index.
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c ? ? ? ?(revision 26327) +++ libavformat/flvdec.c ? ? ? ?(working copy) @@ -30,10 +30,51 @@ ?#include "avformat.h" ?#include "flv.h"
+#define FLVTOOL2_KEYFRAMES_TAG "keyframes" +#define FLVTOOL2_TIMESTAMP_TAG "times" +#define FLVTOOL2_BYTEOFFSET_TAG "filepositions"
is this really FLVTOOL2 specific? does it have to end up in the tag/variable name?
+ ?typedef struct { + ? ?int64_t byte_offset; + ? ?int64_t time_offset; +} FLVTool2KeyframesIndex;
dito
+typedef struct { + ? ?int keyframes_object_parse; + + ? ?int filepositions_array_parse; + ? ?int fill_filepositions; + ? ?int num_filepositions_processed; + + ? ?int times_array_parse; + ? ?int fill_timestamps; + ? ?int num_timestamps_processed; + + ? ?int num_indexed_keyframes; + + ? ?FLVTool2KeyframesIndex *indexes; +} FLVTool2Index;
dito
+typedef struct { ? ? ?int wrong_dts; ///< ?wrong dts due to negative cts + ? ?FLVTool2Index *flvtool2_index; ?} FLVContext;
+static void init_flv_context(FLVContext* flv) +{ + ? ?// initialize flvtool2 "keyframes" based index + ? ?flv->flvtool2_index = av_malloc(sizeof(FLVTool2Index) * 1); + ? ?flv->flvtool2_index->keyframes_object_parse = 0; + ? ?flv->flvtool2_index->filepositions_array_parse = 0; + ? ?flv->flvtool2_index->fill_filepositions = 0; + ? ?flv->flvtool2_index->num_filepositions_processed = 0; + ? ?flv->flvtool2_index->times_array_parse = 0; + ? ?flv->flvtool2_index->fill_timestamps = 0; + ? ?flv->flvtool2_index->num_timestamps_processed = 0; + ? ?flv->flvtool2_index->num_indexed_keyframes = 0; + ? ?flv->flvtool2_index->indexes = NULL; +};
av_mallocz...
+ ?static int flv_probe(AVProbeData *p) ?{ ? ? ?const uint8_t *d; @@ -130,6 +171,8 @@ ? ? ?AMFDataType amf_type; ? ? ?char str_val[256]; ? ? ?double num_val; + ? ?unsigned int index_iter; + ? ?FLVContext *flv = s->priv_data;
? ? ?num_val = 0; ? ? ?ioc = s->pb; @@ -138,7 +181,16 @@
? ? ?switch(amf_type) { ? ? ? ? ?case AMF_DATA_TYPE_NUMBER: - ? ? ? ? ? ?num_val = av_int2dbl(get_be64(ioc)); break; + ? ? ? ? ? ?num_val = av_int2dbl(get_be64(ioc)); + ? ? ? ? ? ?if (flv->flvtool2_index->times_array_parse&& ?depth == 3&& + ? ? ? ? ? ? ? ?flv->flvtool2_index->num_timestamps_processed< ?flv->flvtool2_index->num_indexed_keyframes) { + ?flv->flvtool2_index->indexes[flv->flvtool2_index->num_timestamps_processed++].time_offset = num_val; + ? ? ? ? ? ?} + ? ? ? ? ? ?if (flv->flvtool2_index->filepositions_array_parse&& ?depth == 3 +&& ?flv->flvtool2_index->num_filepositions_processed< ?flv->flvtool2_index->num_indexed_keyframes) { + ?flv->flvtool2_index->indexes[flv->flvtool2_index->num_filepositions_processed++].byte_offset = num_val; + ? ? ? ? ? ?} + ? ? ? ? ? ?break; ? ? ? ? ?case AMF_DATA_TYPE_BOOL: ? ? ? ? ? ? ?num_val = get_byte(ioc); break; ? ? ? ? ?case AMF_DATA_TYPE_STRING: @@ -149,9 +201,21 @@ ? ? ? ? ? ? ?unsigned int keylen;
? ? ? ? ? ? ?while(url_ftell(ioc)< ?max_pos - 2&& ?(keylen = get_be16(ioc))) { - ? ? ? ? ? ? ? ?url_fskip(ioc, keylen); //skip key string + ? ? ? ? ? ? ? ?get_buffer(ioc, str_val, keylen); + ? ? ? ? ? ? ? ?str_val[keylen] = '\0'; + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->keyframes_object_parse&& ?!strcmp(FLVTOOL2_TIMESTAMP_TAG, str_val)&& ?depth == 1) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->times_array_parse = 1; + ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->keyframes_object_parse&& ?!strcmp(FLVTOOL2_BYTEOFFSET_TAG, str_val)&& ?depth == 1) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->filepositions_array_parse = 1; + ? ? ? ? ? ? ? ?} + + ? ? ? ? ? ? ? ?//url_fskip(ioc, keylen); //skip key string ? ? ? ? ? ? ? ? ?if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< ?0) ? ? ? ? ? ? ? ? ? ? ?return -1; //if we couldn't skip, bomb out. + + ? ? ? ? ? ? ? ?flv->flvtool2_index->times_array_parse = 0; + ? ? ? ? ? ? ? ?flv->flvtool2_index->filepositions_array_parse = 0;
? ? ? ? ? ? ?} ? ? ? ? ? ? ?if(get_byte(ioc) != AMF_END_OF_OBJECT) ? ? ? ? ? ? ? ? ?return -1; @@ -164,9 +228,14 @@ ? ? ? ? ?case AMF_DATA_TYPE_MIXEDARRAY: ? ? ? ? ? ? ?url_fskip(ioc, 4); //skip 32-bit max array index ? ? ? ? ? ? ?while(url_ftell(ioc)< ?max_pos - 2&& ?amf_get_string(ioc, str_val, sizeof(str_val))> ?0) { + ? ? ? ? ? ? ? ?if (!strcmp(FLVTOOL2_KEYFRAMES_TAG, str_val)&& ?depth == 0) { + ? ? ? ? ? ? ? ? ? ? flv->flvtool2_index->keyframes_object_parse = 1; + ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ?//this is the only case in which we would want a nested parse to not skip over the object ? ? ? ? ? ? ? ? ?if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1)< ?0) ? ? ? ? ? ? ? ? ? ? ?return -1; + + ? ? ? ? ? ? ? ?flv->flvtool2_index->keyframes_object_parse = 0; ? ? ? ? ? ? ?} ? ? ? ? ? ? ?if(get_byte(ioc) != AMF_END_OF_OBJECT) ? ? ? ? ? ? ? ? ?return -1; @@ -175,10 +244,28 @@ ? ? ? ? ? ? ?unsigned int arraylen, i;
? ? ? ? ? ? ?arraylen = get_be32(ioc); + ? ? ? ? ? ?if (flv->flvtool2_index->filepositions_array_parse&& ?depth == 2) { + ? ? ? ? ? ? ? ?// allocate array to keep indexes + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->indexes == NULL) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->indexes = av_malloc(sizeof(FLVTool2KeyframesIndex) * arraylen); + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->num_indexed_keyframes = arraylen; + ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? ?flv->flvtool2_index->fill_filepositions = 1; + ? ? ? ? ? } + ? ? ? ? ? ?if (flv->flvtool2_index->times_array_parse&& ?depth == 2) { + ? ? ? ? ? ? ? ?// allocate array to keep indexes + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->indexes == NULL) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->indexes = av_malloc(sizeof(FLVTool2KeyframesIndex) * arraylen); + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->num_indexed_keyframes = arraylen; + ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? ?flv->flvtool2_index->fill_timestamps = 1; + ? ? ? ? ? } ? ? ? ? ? ? ?for(i = 0; i< ?arraylen&& ?url_ftell(ioc)< ?max_pos - 1; i++) { ? ? ? ? ? ? ? ? ?if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< ?0) ? ? ? ? ? ? ? ? ? ? ?return -1; //if we couldn't skip, bomb out. ? ? ? ? ? ? ?} + ? ? ? ? ? ?flv->flvtool2_index->fill_filepositions = 0; + ? ? ? ? ? ?flv->flvtool2_index->fill_timestamps = 0; ? ? ? ? ?}
I don't like how this is spaced out all over the code, but I guess this more due to how the flv reader works...
? ? ? ? ? ? ?break; ? ? ? ? ?case AMF_DATA_TYPE_DATE: @@ -205,6 +292,14 @@ ? ? ? ? ? ? ? ? ?acodec->bit_rate = num_val * 1024.0; ? ? ? ? ?} else if (amf_type == AMF_DATA_TYPE_STRING) ? ? ? ? ? ? ?av_metadata_set2(&s->metadata, key, str_val, 0); + + ? ? ? ?for (index_iter = 0; index_iter< ?flv->flvtool2_index->num_indexed_keyframes; ++index_iter) { + ? ? ? ? ? ?int64_t ts = flv->flvtool2_index->indexes[index_iter].time_offset; + ? ? ? ? ? ?int64_t byte_offset = flv->flvtool2_index->indexes[index_iter].byte_offset; + ? ? ? ? ? ?av_add_index_entry(vstream, byte_offset, ts*1000, 0, 0, AVINDEX_KEYFRAME); + ? ? ? ? ? ?av_log(s, AV_LOG_DEBUG, + ? ? ? ? ? ? ? ?"add flvtool2 index entry: timestamp: %16"PRIX64", byte offset: %16"PRIX64"\n", ts, byte_offset); + ? ? ? ?}
you could drop the indexes right after this step to free the mem, no?
? ? ?}
? ? ?return 0; @@ -214,8 +309,11 @@ ? ? ?AMFDataType type; ? ? ?AVStream *stream, *astream, *vstream; ? ? ?ByteIOContext *ioc; + ? ? ?int i; ? ? ?char buffer[11]; //only needs to hold the string "onMetaData". Anything longer is something we don't want. + ? ?FLVContext *flv = s->priv_data; + ? ?init_flv_context(flv);
? ? ?astream = NULL; ? ? ?vstream = NULL; @@ -491,6 +589,15 @@ ?} ?#endif
+static int flv_read_close(AVFormatContext *s) +{ + ? ?FLVContext *flv = s->priv_data; + ? ?if (flv->flvtool2_index->indexes != NULL) + ? ? ? ?av_free(flv->flvtool2_index->indexes); + ? ?av_free(flv->flvtool2_index); + ? ?return 0; +} + ?AVInputFormat flv_demuxer = { ? ? ?"flv", ? ? ?NULL_IF_CONFIG_SMALL("FLV format"), @@ -498,6 +605,7 @@ ? ? ?flv_probe, ? ? ?flv_read_header, ? ? ?flv_read_packet, + ? ?flv_read_close, ? ? ?.read_seek = flv_read_seek, ?#if 0 ? ? ?.read_seek2 = flv_read_seek2,
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
New patch attached, after processing comments. Changes: * structures, types, constants renamed to not mention flvtool2 * use av_mallocz for allocation to avoid unnecessary initialization * free metadata index data when it is no longer required On 21 January 2011 07:34, Kharkov Alexander <kharkovalexander at gmail.com> wrote:
Thanks for review, agree with all your points, will fix and resent. Details: * "keyframes" metatag does not stated in FLV specs but often recommeded, I found at least one more free tool which inject it FLVMDI * index data really can be free right after it is passed to av_add_index_entry * code spread all over just because I want to touch exsting metadata parser behavior minmal (all this recursion, loops, etc.) that is why I did not create separate function which simply parse keyframes object
On 20 January 2011 23:23, Vladimir Pantelic <vladoman at gmail.com> wrote:
Kharkov Alexander wrote:
Hi,
Attached patch parse flvtool2 metadata "keyframes (times/fileopstions)" tags and use this data as index at least for seek operations. It is required in case when mplayer which use this part of ffmpeg code attempts to play FLV file via HTTP for example. Existing implementation attempt to download ALL content up to seek point before it can play it, but it is unacceptable to download unneded data (whole file if you seek to the end) as in case of low bandwidth seek operation will 'never' end. With this patch 'mplayer' can seek fast in such situations using this index.
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c ? ? ? ?(revision 26327) +++ libavformat/flvdec.c ? ? ? ?(working copy) @@ -30,10 +30,51 @@ ?#include "avformat.h" ?#include "flv.h"
+#define FLVTOOL2_KEYFRAMES_TAG "keyframes" +#define FLVTOOL2_TIMESTAMP_TAG "times" +#define FLVTOOL2_BYTEOFFSET_TAG "filepositions"
is this really FLVTOOL2 specific? does it have to end up in the tag/variable name?
+ ?typedef struct { + ? ?int64_t byte_offset; + ? ?int64_t time_offset; +} FLVTool2KeyframesIndex;
dito
+typedef struct { + ? ?int keyframes_object_parse; + + ? ?int filepositions_array_parse; + ? ?int fill_filepositions; + ? ?int num_filepositions_processed; + + ? ?int times_array_parse; + ? ?int fill_timestamps; + ? ?int num_timestamps_processed; + + ? ?int num_indexed_keyframes; + + ? ?FLVTool2KeyframesIndex *indexes; +} FLVTool2Index;
dito
+typedef struct { ? ? ?int wrong_dts; ///< ?wrong dts due to negative cts + ? ?FLVTool2Index *flvtool2_index; ?} FLVContext;
+static void init_flv_context(FLVContext* flv) +{ + ? ?// initialize flvtool2 "keyframes" based index + ? ?flv->flvtool2_index = av_malloc(sizeof(FLVTool2Index) * 1); + ? ?flv->flvtool2_index->keyframes_object_parse = 0; + ? ?flv->flvtool2_index->filepositions_array_parse = 0; + ? ?flv->flvtool2_index->fill_filepositions = 0; + ? ?flv->flvtool2_index->num_filepositions_processed = 0; + ? ?flv->flvtool2_index->times_array_parse = 0; + ? ?flv->flvtool2_index->fill_timestamps = 0; + ? ?flv->flvtool2_index->num_timestamps_processed = 0; + ? ?flv->flvtool2_index->num_indexed_keyframes = 0; + ? ?flv->flvtool2_index->indexes = NULL; +};
av_mallocz...
+ ?static int flv_probe(AVProbeData *p) ?{ ? ? ?const uint8_t *d; @@ -130,6 +171,8 @@ ? ? ?AMFDataType amf_type; ? ? ?char str_val[256]; ? ? ?double num_val; + ? ?unsigned int index_iter; + ? ?FLVContext *flv = s->priv_data;
? ? ?num_val = 0; ? ? ?ioc = s->pb; @@ -138,7 +181,16 @@
? ? ?switch(amf_type) { ? ? ? ? ?case AMF_DATA_TYPE_NUMBER: - ? ? ? ? ? ?num_val = av_int2dbl(get_be64(ioc)); break; + ? ? ? ? ? ?num_val = av_int2dbl(get_be64(ioc)); + ? ? ? ? ? ?if (flv->flvtool2_index->times_array_parse&& ?depth == 3&& + ? ? ? ? ? ? ? ?flv->flvtool2_index->num_timestamps_processed< ?flv->flvtool2_index->num_indexed_keyframes) { + ?flv->flvtool2_index->indexes[flv->flvtool2_index->num_timestamps_processed++].time_offset = num_val; + ? ? ? ? ? ?} + ? ? ? ? ? ?if (flv->flvtool2_index->filepositions_array_parse&& ?depth == 3 +&& ?flv->flvtool2_index->num_filepositions_processed< ?flv->flvtool2_index->num_indexed_keyframes) { + ?flv->flvtool2_index->indexes[flv->flvtool2_index->num_filepositions_processed++].byte_offset = num_val; + ? ? ? ? ? ?} + ? ? ? ? ? ?break; ? ? ? ? ?case AMF_DATA_TYPE_BOOL: ? ? ? ? ? ? ?num_val = get_byte(ioc); break; ? ? ? ? ?case AMF_DATA_TYPE_STRING: @@ -149,9 +201,21 @@ ? ? ? ? ? ? ?unsigned int keylen;
? ? ? ? ? ? ?while(url_ftell(ioc)< ?max_pos - 2&& ?(keylen = get_be16(ioc))) { - ? ? ? ? ? ? ? ?url_fskip(ioc, keylen); //skip key string + ? ? ? ? ? ? ? ?get_buffer(ioc, str_val, keylen); + ? ? ? ? ? ? ? ?str_val[keylen] = '\0'; + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->keyframes_object_parse&& ?!strcmp(FLVTOOL2_TIMESTAMP_TAG, str_val)&& ?depth == 1) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->times_array_parse = 1; + ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->keyframes_object_parse&& ?!strcmp(FLVTOOL2_BYTEOFFSET_TAG, str_val)&& ?depth == 1) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->filepositions_array_parse = 1; + ? ? ? ? ? ? ? ?} + + ? ? ? ? ? ? ? ?//url_fskip(ioc, keylen); //skip key string ? ? ? ? ? ? ? ? ?if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< ?0) ? ? ? ? ? ? ? ? ? ? ?return -1; //if we couldn't skip, bomb out. + + ? ? ? ? ? ? ? ?flv->flvtool2_index->times_array_parse = 0; + ? ? ? ? ? ? ? ?flv->flvtool2_index->filepositions_array_parse = 0;
? ? ? ? ? ? ?} ? ? ? ? ? ? ?if(get_byte(ioc) != AMF_END_OF_OBJECT) ? ? ? ? ? ? ? ? ?return -1; @@ -164,9 +228,14 @@ ? ? ? ? ?case AMF_DATA_TYPE_MIXEDARRAY: ? ? ? ? ? ? ?url_fskip(ioc, 4); //skip 32-bit max array index ? ? ? ? ? ? ?while(url_ftell(ioc)< ?max_pos - 2&& ?amf_get_string(ioc, str_val, sizeof(str_val))> ?0) { + ? ? ? ? ? ? ? ?if (!strcmp(FLVTOOL2_KEYFRAMES_TAG, str_val)&& ?depth == 0) { + ? ? ? ? ? ? ? ? ? ? flv->flvtool2_index->keyframes_object_parse = 1; + ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ?//this is the only case in which we would want a nested parse to not skip over the object ? ? ? ? ? ? ? ? ?if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1)< ?0) ? ? ? ? ? ? ? ? ? ? ?return -1; + + ? ? ? ? ? ? ? ?flv->flvtool2_index->keyframes_object_parse = 0; ? ? ? ? ? ? ?} ? ? ? ? ? ? ?if(get_byte(ioc) != AMF_END_OF_OBJECT) ? ? ? ? ? ? ? ? ?return -1; @@ -175,10 +244,28 @@ ? ? ? ? ? ? ?unsigned int arraylen, i;
? ? ? ? ? ? ?arraylen = get_be32(ioc); + ? ? ? ? ? ?if (flv->flvtool2_index->filepositions_array_parse&& ?depth == 2) { + ? ? ? ? ? ? ? ?// allocate array to keep indexes + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->indexes == NULL) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->indexes = av_malloc(sizeof(FLVTool2KeyframesIndex) * arraylen); + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->num_indexed_keyframes = arraylen; + ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? ?flv->flvtool2_index->fill_filepositions = 1; + ? ? ? ? ? } + ? ? ? ? ? ?if (flv->flvtool2_index->times_array_parse&& ?depth == 2) { + ? ? ? ? ? ? ? ?// allocate array to keep indexes + ? ? ? ? ? ? ? ?if (flv->flvtool2_index->indexes == NULL) { + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->indexes = av_malloc(sizeof(FLVTool2KeyframesIndex) * arraylen); + ? ? ? ? ? ? ? ? ? ?flv->flvtool2_index->num_indexed_keyframes = arraylen; + ? ? ? ? ? ? ? ?} + ? ? ? ? ? ? ? ?flv->flvtool2_index->fill_timestamps = 1; + ? ? ? ? ? } ? ? ? ? ? ? ?for(i = 0; i< ?arraylen&& ?url_ftell(ioc)< ?max_pos - 1; i++) { ? ? ? ? ? ? ? ? ?if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< ?0) ? ? ? ? ? ? ? ? ? ? ?return -1; //if we couldn't skip, bomb out. ? ? ? ? ? ? ?} + ? ? ? ? ? ?flv->flvtool2_index->fill_filepositions = 0; + ? ? ? ? ? ?flv->flvtool2_index->fill_timestamps = 0; ? ? ? ? ?}
I don't like how this is spaced out all over the code, but I guess this more due to how the flv reader works...
? ? ? ? ? ? ?break; ? ? ? ? ?case AMF_DATA_TYPE_DATE: @@ -205,6 +292,14 @@ ? ? ? ? ? ? ? ? ?acodec->bit_rate = num_val * 1024.0; ? ? ? ? ?} else if (amf_type == AMF_DATA_TYPE_STRING) ? ? ? ? ? ? ?av_metadata_set2(&s->metadata, key, str_val, 0); + + ? ? ? ?for (index_iter = 0; index_iter< ?flv->flvtool2_index->num_indexed_keyframes; ++index_iter) { + ? ? ? ? ? ?int64_t ts = flv->flvtool2_index->indexes[index_iter].time_offset; + ? ? ? ? ? ?int64_t byte_offset = flv->flvtool2_index->indexes[index_iter].byte_offset; + ? ? ? ? ? ?av_add_index_entry(vstream, byte_offset, ts*1000, 0, 0, AVINDEX_KEYFRAME); + ? ? ? ? ? ?av_log(s, AV_LOG_DEBUG, + ? ? ? ? ? ? ? ?"add flvtool2 index entry: timestamp: %16"PRIX64", byte offset: %16"PRIX64"\n", ts, byte_offset); + ? ? ? ?}
you could drop the indexes right after this step to free the mem, no?
? ? ?}
? ? ?return 0; @@ -214,8 +309,11 @@ ? ? ?AMFDataType type; ? ? ?AVStream *stream, *astream, *vstream; ? ? ?ByteIOContext *ioc; + ? ? ?int i; ? ? ?char buffer[11]; //only needs to hold the string "onMetaData". Anything longer is something we don't want. + ? ?FLVContext *flv = s->priv_data; + ? ?init_flv_context(flv);
? ? ?astream = NULL; ? ? ?vstream = NULL; @@ -491,6 +589,15 @@ ?} ?#endif
+static int flv_read_close(AVFormatContext *s) +{ + ? ?FLVContext *flv = s->priv_data; + ? ?if (flv->flvtool2_index->indexes != NULL) + ? ? ? ?av_free(flv->flvtool2_index->indexes); + ? ?av_free(flv->flvtool2_index); + ? ?return 0; +} + ?AVInputFormat flv_demuxer = { ? ? ?"flv", ? ? ?NULL_IF_CONFIG_SMALL("FLV format"), @@ -498,6 +605,7 @@ ? ? ?flv_probe, ? ? ?flv_read_header, ? ? ?flv_read_packet, + ? ?flv_read_close, ? ? ?.read_seek = flv_read_seek, ?#if 0 ? ? ?.read_seek2 = flv_read_seek2,
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
Kharkov Alexander wrote:
New patch attached, after processing comments. Changes: * structures, types, constants renamed to not mention flvtool2 * use av_mallocz for allocation to avoid unnecessary initialization * free metadata index data when it is no longer required
On 21 January 2011 07:34, Kharkov Alexander<kharkovalexander at gmail.com> wrote:
Thanks for review, agree with all your points, will fix and resent. Details: * "keyframes" metatag does not stated in FLV specs but often recommeded, I found at least one more free tool which inject it FLVMDI * index data really can be free right after it is passed to av_add_index_entry * code spread all over just because I want to touch exsting metadata parser behavior minmal (all this recursion, loops, etc.) that is why I did not create separate function which simply parse keyframes object
Could you rewrite the patch to read all the index stuff in one single function, that should allow you to drop a lot of your temporary variables and flags and will also make it much easier to understand.
flvdec.c.diff
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c (revision 26327) +++ libavformat/flvdec.c (working copy) @@ -30,8 +30,34 @@ #include "avformat.h" #include "flv.h"
+#define METADATA_KEYFRAMES_TAG "keyframes" +#define METADATA_KEYFRAMES_TIMESTAMP_TAG "times" +#define METADATA_KEYFRAMES_BYTEOFFSET_TAG "filepositions" + typedef struct { + int64_t byte_offset; + int64_t time_offset; +} MedatadataKeyframeIndex; + +typedef struct { + int keyframes_object_parse; + + int filepositions_array_parse; + int fill_filepositions; + int num_filepositions_processed; + + int times_array_parse; + int fill_timestamps; + int num_timestamps_processed; + + int num_indexed_keyframes; + + MedatadataKeyframeIndex *keyframe_index; +} MetadataKeyframesIndex; + +typedef struct { int wrong_dts; ///< wrong dts due to negative cts + MetadataKeyframesIndex *metadata_keyframes_index; } FLVContext;
static int flv_probe(AVProbeData *p) @@ -130,6 +156,8 @@ AMFDataType amf_type; char str_val[256]; double num_val; + unsigned int index_iter; + FLVContext *flv = s->priv_data;
num_val = 0; ioc = s->pb; @@ -138,7 +166,16 @@
switch(amf_type) { case AMF_DATA_TYPE_NUMBER: - num_val = av_int2dbl(get_be64(ioc)); break; + num_val = av_int2dbl(get_be64(ioc)); + if (flv->metadata_keyframes_index->times_array_parse&& depth == 3&& + flv->metadata_keyframes_index->num_timestamps_processed< flv->metadata_keyframes_index->num_indexed_keyframes) { + flv->metadata_keyframes_index->keyframe_index[flv->metadata_keyframes_index->num_timestamps_processed++].time_offset = num_val; + } + if (flv->metadata_keyframes_index->filepositions_array_parse&& depth == 3 +&& flv->metadata_keyframes_index->num_filepositions_processed< flv->metadata_keyframes_index->num_indexed_keyframes) { + flv->metadata_keyframes_index->keyframe_index[flv->metadata_keyframes_index->num_filepositions_processed++].byte_offset = num_val; + } + break;
as said
case AMF_DATA_TYPE_BOOL: num_val = get_byte(ioc); break; case AMF_DATA_TYPE_STRING: @@ -149,9 +186,21 @@ unsigned int keylen;
while(url_ftell(ioc)< max_pos - 2&& (keylen = get_be16(ioc))) { - url_fskip(ioc, keylen); //skip key string + get_buffer(ioc, str_val, keylen); + str_val[keylen] = '\0'; + if (flv->metadata_keyframes_index->keyframes_object_parse&& !strcmp(METADATA_KEYFRAMES_TIMESTAMP_TAG, str_val)&& depth == 1) { + flv->metadata_keyframes_index->times_array_parse = 1; + } + if (flv->metadata_keyframes_index->keyframes_object_parse&& !strcmp(METADATA_KEYFRAMES_BYTEOFFSET_TAG, str_val)&& depth == 1) { + flv->metadata_keyframes_index->filepositions_array_parse = 1; + } + + //url_fskip(ioc, keylen); //skip key string if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< 0) return -1; //if we couldn't skip, bomb out. + + flv->metadata_keyframes_index->times_array_parse = 0; + flv->metadata_keyframes_index->filepositions_array_parse = 0;
this index reading
} if(get_byte(ioc) != AMF_END_OF_OBJECT) return -1; @@ -164,10 +213,25 @@ case AMF_DATA_TYPE_MIXEDARRAY: url_fskip(ioc, 4); //skip 32-bit max array index while(url_ftell(ioc)< max_pos - 2&& amf_get_string(ioc, str_val, sizeof(str_val))> 0) { + if (!strcmp(METADATA_KEYFRAMES_TAG, str_val)&& depth == 0) { + flv->metadata_keyframes_index->keyframes_object_parse = 1; + }
is in
//this is the only case in which we would want a nested parse to not skip over the object if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1)< 0) return -1; - } + + if (flv->metadata_keyframes_index->keyframes_object_parse&& depth == 0) { + // we fnish 'keyframes' metadata tag parsing, modify AV index based on this data + for (index_iter = 0; index_iter< flv->metadata_keyframes_index->num_indexed_keyframes; ++index_iter) { + int64_t ts = flv->metadata_keyframes_index->keyframe_index[index_iter].time_offset; + int64_t byte_offset = flv->metadata_keyframes_index->keyframe_index[index_iter].byte_offset; + av_add_index_entry(vstream, byte_offset, ts*1000, 0, 0, AVINDEX_KEYFRAME); + } + // cleanup + av_freep(&flv->metadata_keyframes_index->keyframe_index); + } + flv->metadata_keyframes_index->keyframes_object_parse = 0; + }
too many
if(get_byte(ioc) != AMF_END_OF_OBJECT) return -1; break; @@ -175,10 +239,28 @@ unsigned int arraylen, i;
arraylen = get_be32(ioc); + if (flv->metadata_keyframes_index->filepositions_array_parse&& depth == 2) { + // allocate array to keep keyframe_index + if (flv->metadata_keyframes_index->keyframe_index == 0) { + flv->metadata_keyframes_index->keyframe_index = av_malloc(sizeof(MedatadataKeyframeIndex) * arraylen); + flv->metadata_keyframes_index->num_indexed_keyframes = arraylen; + } + flv->metadata_keyframes_index->fill_filepositions = 1; + } + if (flv->metadata_keyframes_index->times_array_parse&& depth == 2) { + // allocate array to keep keyframe_index + if (flv->metadata_keyframes_index->keyframe_index == 0) { + flv->metadata_keyframes_index->keyframe_index = av_malloc(sizeof(MedatadataKeyframeIndex) * arraylen); + flv->metadata_keyframes_index->num_indexed_keyframes = arraylen; + } + flv->metadata_keyframes_index->fill_timestamps = 1; + } for(i = 0; i< arraylen&& url_ftell(ioc)< max_pos - 1; i++) { if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< 0) return -1; //if we couldn't skip, bomb out. } + flv->metadata_keyframes_index->fill_filepositions = 0; + flv->metadata_keyframes_index->fill_timestamps = 0; }
places
break; case AMF_DATA_TYPE_DATE: @@ -214,8 +296,10 @@ AMFDataType type; AVStream *stream, *astream, *vstream; ByteIOContext *ioc; + int i; char buffer[11]; //only needs to hold the string "onMetaData". Anything longer is something we don't want. + FLVContext *flv = s->priv_data;
astream = NULL; vstream = NULL; @@ -233,10 +317,17 @@ else if(stream->codec->codec_type == AVMEDIA_TYPE_VIDEO) vstream = stream; }
+ + // allocate "keyframes" based index + flv->metadata_keyframes_index = av_mallocz(sizeof(MetadataKeyframesIndex) * 1); + //parse the second object (we want a mixed array) if(amf_parse_object(s, astream, vstream, buffer, next_pos, 0)< 0) return -1;
+ // cleanup "keyframes" based index + av_freep(&flv->metadata_keyframes_index); + return 0; }
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
Could you rewrite the patch to read all the index stuff in one single function, that should allow you to drop a lot of your temporary variables and flags and will also make it much easier to understand. Ok, done. Patch rewritten now 'keyframes' based index filled in single function. 'keyframes' parser have strict requirement on structure of this part of metadata, if structure differ from required, parser just does not use such data for indexing purpose. For backward compatible behavior, old parser executed too. New patch attached.
Kharkov Alexander wrote:
Could you rewrite the patch to read all the index stuff in one single function, that should allow you to drop a lot of your temporary variables and flags and will also make it much easier to understand. Ok, done. Patch rewritten now 'keyframes' based index filled in single function. 'keyframes' parser have strict requirement on structure of this part of metadata, if structure differ from required, parser just does not use such data for indexing purpose.
ok
For backward compatible behavior, old parser executed too. New patch attached.
why do that? I can understand to seek back to the old position if the index parsing gave errors, but in case of success why read the same data again?
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c (revision 26402) +++ libavformat/flvdec.c (working copy) @@ -30,6 +30,10 @@ #include "avformat.h" #include "flv.h"
+#define METADATA_KEYFRAMES_TAG "keyframes" +#define METADATA_KEYFRAMES_TIMESTAMP_TAG "times" +#define METADATA_KEYFRAMES_BYTEOFFSET_TAG "filepositions" + typedef struct { int wrong_dts; ///< wrong dts due to negative cts } FLVContext; @@ -124,6 +128,64 @@ return length; }
+static void try_parse_keyframes_index(AVFormatContext *s, ByteIOContext *ioc, AVStream *vstream, int64_t max_pos) { + unsigned int keylen, arraylen = 0, timeslen = 0, fileposlen = 0, i; + double num_val; + AMFDataType amf_type; + char str_val[256]; + int64_t** current_array;
pointer to pointer not needed, just make current point to whatever times or pos point to. also current_array is local to the loop below, no?
+ int64_t *times = 0; + int64_t *filepositions = 0; + + while (url_ftell(ioc)< max_pos - 2&& (keylen = get_be16(ioc))) { + // Read array name from context + get_buffer(ioc, str_val, keylen); + str_val[keylen] = '\0'; + + // Expect array object in context + amf_type = get_byte(ioc); + if (amf_type != AMF_DATA_TYPE_ARRAY) + return; + + arraylen = get_be32(ioc); + /* + * Expect only 'times' or 'filepositions' sub-arrays in other case refuse to use such metadata + * for indexing + */ + if (!strcmp(METADATA_KEYFRAMES_TIMESTAMP_TAG, str_val)) { + times = av_mallocz(sizeof(int64_t) * arraylen); + timeslen = arraylen; + current_array =× + } else if (!strcmp(METADATA_KEYFRAMES_BYTEOFFSET_TAG, str_val)) { + filepositions = av_mallocz(sizeof(int64_t) * arraylen); + fileposlen = arraylen; + current_array =&filepositions; + } else + // unexpected metatag inside keyframes, will not use such metadata for indexing + return; + + for (i = 0; i< arraylen&& url_ftell(ioc)< max_pos - 1; i++) {
nit: please give operators room the breathe and drop the double spaces
+ amf_type = get_byte(ioc); + if (amf_type != AMF_DATA_TYPE_NUMBER) + return; + num_val = av_int2dbl(get_be64(ioc)); + (*current_array)[i] = num_val; + } + } + if (timeslen != fileposlen) + // times->filepositions arrays have different size, will not use such metadata for indexing
obvious, no?
+ return; + + for (i = 0; i< arraylen; ++i) { + int64_t ts = times[i]; + int64_t byte_offset = filepositions[i];
why these temp vars?
+ av_add_index_entry(vstream, byte_offset, ts*1000, 0, 0, AVINDEX_KEYFRAME); + } + + av_freep(×); + av_freep(&filepositions); +} + static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; ByteIOContext *ioc; @@ -148,6 +210,17 @@ case AMF_DATA_TYPE_OBJECT: { unsigned int keylen;
+ if (!strcmp(METADATA_KEYFRAMES_TAG, key)&& depth == 1) { + int64_t cur_ioc_pos = url_ftell(ioc); + /* + * Try parse keyframes metatag and fill AV index. + * Reset stream to initial state after that to run default parser + * to not break default parser behavior + */ + try_parse_keyframes_index(s, ioc, vstream, max_pos); + url_fseek(ioc, cur_ioc_pos, SEEK_SET);
as said, i'd prefer to not seek back in case of success
+ } + while(url_ftell(ioc)< max_pos - 2&& (keylen = get_be16(ioc))) { url_fskip(ioc, keylen); //skip key string if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1)< 0)
Regards,
why do that? I can understand to seek back to the old position if the index parsing gave errors, but in case of success why read the same data again?
Actually I do that just to allow future patches which can wait this data too and do smth else with it. Of cause in current situation this index parser can return success or failure and this result can be be used as indicator to reset stream back to initial position, but as I said I prefer to make changes which affect existing behavior as less as possible. So should I change it and reset stream to initial state only in case of failure (unexpected index structure etc.)?
why do that? I can understand to seek back to the old position if the index parsing gave errors, but in case of success why read the same data again?
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c ? ? ? ?(revision 26402) +++ libavformat/flvdec.c ? ? ? ?(working copy) + + ? ? ? ?for (i = 0; i< ?arraylen&& ?url_ftell(ioc)< ?max_pos - 1; i++) {
nit: please give operators room the breathe and drop the double spaces Actually my English is not good, so I do not understand what do you mean, I did not find any two sequential spaces in this line, but anyway I format this line to look the same as other lines in this .c file (so this line fit at least to this file "codestyle" now).
+ ? ? ? ? ? ?amf_type = get_byte(ioc); + ? ? ? ? ? ?if (amf_type != AMF_DATA_TYPE_NUMBER) + ? ? ? ? ? ? ? ?return; + ? ? ? ? ? ?num_val = av_int2dbl(get_be64(ioc)); + ? ? ? ? ? ?(*current_array)[i] = num_val; + ? ? ? ?} + ? ?} + ? ?if (timeslen != fileposlen) + ? ? ? ?// times->filepositions arrays have different size, will not use such metadata for indexing
obvious, no? Not obvious 'keyframes' metatag is not part of standart it is just convention to use such kind of metatag information for indexing, but nobody can prevent end user to create FLV file with keyframes metadata with it's own structure, for own purposed, in that case I try just ignore such data not coredump trying to access data which does not
Almost all comments processed new patch attached. Following not process: present. I want prevent crushed on expected structure. I compare two sizes because they packet in two different arrays in metadata, that is why they can have different sizes in case of bug in tool which insert metatags for example. JFYI strructure is following, it allows to have it inconsistent: keyframes: times (array): time0 (num) time1 (num) time2 (num) filepositions (array) position0 (num) position1 (num)
Kharkov Alexander wrote:
why do that? I can understand to seek back to the old position if the index parsing gave errors, but in case of success why read the same data again?
Almost all comments processed new patch attached. Following not process:
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c (revision 26402) +++ libavformat/flvdec.c (working copy) + + for (i = 0; i< arraylen&& url_ftell(ioc)< max_pos - 1; i++) {
nit: please give operators room the breathe and drop the double spaces Actually my English is not good, so I do not understand what do you mean, I did not find any two sequential spaces in this line, but anyway I format this line to look the same as other lines in this .c file (so this line fit at least to this file "codestyle" now).
forget it, I need to kill my mail client ... :)
+ amf_type = get_byte(ioc); + if (amf_type != AMF_DATA_TYPE_NUMBER) + return; + num_val = av_int2dbl(get_be64(ioc)); + (*current_array)[i] = num_val; + } + } + if (timeslen != fileposlen) + // times->filepositions arrays have different size, will not use such metadata for indexing
obvious, no?
Not obvious 'keyframes' metatag is not part of standart it is just convention to use such kind of metatag information for indexing, but nobody can prevent end user to create FLV file with keyframes metadata with it's own structure, for own purposed, in that case I try just ignore such data not coredump trying to access data which does not present. I want prevent crushed on expected structure. I compare two sizes because they packet in two different arrays in metadata, that is why they can have different sizes in case of bug in tool which insert metatags for example. JFYI strructure is following, it allows to have it inconsistent: keyframes: times (array): time0 (num) time1 (num) time2 (num) filepositions (array) position0 (num) position1 (num)
okok, leave the comment then
?obvious, no?
Not obvious 'keyframes' metatag is not part of standart it is just convention to use such kind of metatag information for indexing, but nobody can prevent end user to create FLV file with keyframes metadata with it's own structure, for own purposed, in that case I try just ignore such data not coredump trying to access data which does not present. I want prevent crushed on expected structure. I compare two sizes because they packet in two different arrays in metadata, that is why they can have different sizes in case of bug in tool which insert metatags for example. JFYI strructure is following, it allows to have it inconsistent: keyframes: ? ?times (array): ? ? ? ?time0 (num) ? ? ? ?time1 (num) ? ? ? ?time2 (num) ? ?filepositions (array) ? ? ? ?position0 (num) ? ? ? ?position1 (num)
okok, leave the comment then Comment added to source. Seems now all comments process, is there are any chance to have this patch committed?
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c (revision 26402) +++ libavformat/flvdec.c (working copy) @@ -30,6 +30,10 @@ #include "avformat.h" #include "flv.h"
+#define METADATA_KEYFRAMES_TAG "keyframes" +#define METADATA_KEYFRAMES_TIMESTAMP_TAG "times" +#define METADATA_KEYFRAMES_BYTEOFFSET_TAG "filepositions" + typedef struct { int wrong_dts; ///< wrong dts due to negative cts } FLVContext; @@ -124,6 +128,63 @@ return length; }
+static int try_parse_keyframes_index(AVFormatContext *s, ByteIOContext *ioc, AVStream *vstream, int64_t max_pos) {
nit: the 'try_' part carries no information, get rid of it.
+ unsigned int keylen, arraylen = 0, timeslen = 0, fileposlen = 0, i; + double num_val; + AMFDataType amf_type; + char str_val[256]; + int64_t *times = 0; + int64_t *filepositions = 0;
You mean NULL
+ + while (url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) { + int64_t* current_array; + // Read array name from context + get_buffer(ioc, str_val, keylen); + str_val[keylen] = '\0';
Buffer overflow.
+ + // Expect array object in context + amf_type = get_byte(ioc); + if (amf_type != AMF_DATA_TYPE_ARRAY)
This value isn't used anywhere else, so you can use if (get_byte() ...) and get rid of amf_type. Same below.
+ return -1; + + arraylen = get_be32(ioc); + /* + * Expect only 'times' or 'filepositions' sub-arrays in other case refuse to use such metadata + * for indexing + */ + if (!strcmp(METADATA_KEYFRAMES_TIMESTAMP_TAG, str_val)) { + times = av_mallocz(sizeof(int64_t) * arraylen);
Use sizeof(*times). Also you should check that malloc succeeded (it might easily fail with a corrupted file).
+ timeslen = arraylen; + current_array = times; + } else if (!strcmp(METADATA_KEYFRAMES_BYTEOFFSET_TAG, str_val)) { + filepositions = av_mallocz(sizeof(int64_t) * arraylen); + fileposlen = arraylen; + current_array = filepositions; + } else + // unexpected metatag inside keyframes, will not use such metadata for indexing + return -1; + + for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) { + amf_type = get_byte(ioc); + if (amf_type != AMF_DATA_TYPE_NUMBER) + return -1;
Memleak. Same below.
+ num_val = av_int2dbl(get_be64(ioc)); + current_array[i] = num_val; + } + } + if(timeslen != fileposlen) + // times->filepositions arrays have different size, will not use such metadata for indexing + return -1; + + for(i = 0; i < arraylen; ++i) { + av_add_index_entry(vstream, filepositions[i], times[i]*1000, 0, 0, AVINDEX_KEYFRAME); + } + + av_freep(×); + av_freep(&filepositions); + return 0; +} + static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { AVCodecContext *acodec, *vcodec; ByteIOContext *ioc; @@ -148,6 +209,17 @@ case AMF_DATA_TYPE_OBJECT: { unsigned int keylen;
+ if (!strcmp(METADATA_KEYFRAMES_TAG, key) && depth == 1) { + int64_t cur_ioc_pos = url_ftell(ioc); + /* + * Try parse keyframes metatag and fill AV index. + * Reset stream to initial state after that to run default parser + * to not break default parser behavior + */ + if(try_parse_keyframes_index(s, ioc, vstream, max_pos) < 0) + url_fseek(ioc, cur_ioc_pos, SEEK_SET); + } + while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) { url_fskip(ioc, keylen); //skip key string if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
-- Anton Khirnov
On 10 February 2011 01:15, Anton Khirnov <anton at khirnov.net> wrote:
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c ? ? ?(revision 26402) +++ libavformat/flvdec.c ? ? ?(working copy) @@ -30,6 +30,10 @@ ?#include "avformat.h" ?#include "flv.h"
+#define METADATA_KEYFRAMES_TAG "keyframes" +#define METADATA_KEYFRAMES_TIMESTAMP_TAG "times" +#define METADATA_KEYFRAMES_BYTEOFFSET_TAG "filepositions" + ?typedef struct { ? ? ?int wrong_dts; ///< wrong dts due to negative cts ?} FLVContext; @@ -124,6 +128,63 @@ ? ? ?return length; ?}
+static int try_parse_keyframes_index(AVFormatContext *s, ByteIOContext *ioc, AVStream *vstream, int64_t max_pos) {
nit: the 'try_' part carries no information, get rid of it.
+ ? ?unsigned int keylen, arraylen = 0, timeslen = 0, fileposlen = 0, i; + ? ?double num_val; + ? ?AMFDataType amf_type; + ? ?char str_val[256]; + ? ?int64_t *times = 0; + ? ?int64_t *filepositions = 0;
You mean NULL
+ + ? ?while (url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) { + ? ? ? ?int64_t* current_array; + ? ? ? ?// Read array name from context + ? ? ? ?get_buffer(ioc, str_val, keylen); + ? ? ? ?str_val[keylen] = '\0';
Buffer overflow.
+ + ? ? ? ?// Expect array object in context + ? ? ? ?amf_type = get_byte(ioc); + ? ? ? ?if (amf_type != AMF_DATA_TYPE_ARRAY)
This value isn't used anywhere else, so you can use if (get_byte() ...) and get rid of amf_type. Same below.
+ ? ? ? ? ? ?return -1; + + ? ? ? ?arraylen = get_be32(ioc); + ? ? ? ?/* + ? ? ? ? * Expect only 'times' or 'filepositions' sub-arrays in other case refuse to use such metadata + ? ? ? ? * for indexing + ? ? ? ? */ + ? ? ? ?if (!strcmp(METADATA_KEYFRAMES_TIMESTAMP_TAG, str_val)) { + ? ? ? ? ? ?times = av_mallocz(sizeof(int64_t) * arraylen);
Use sizeof(*times). Also you should check that malloc succeeded (it might easily fail with a corrupted file).
+ ? ? ? ? ? ?timeslen = arraylen; + ? ? ? ? ? ?current_array = times; + ? ? ? ?} else if (!strcmp(METADATA_KEYFRAMES_BYTEOFFSET_TAG, str_val)) { + ? ? ? ? ? ?filepositions = av_mallocz(sizeof(int64_t) * arraylen); + ? ? ? ? ? ?fileposlen = arraylen; + ? ? ? ? ? ?current_array = filepositions; + ? ? ? ?} else + ? ? ? ? ? ?// unexpected metatag inside keyframes, will not use such metadata for indexing + ? ? ? ? ? ?return -1; + + ? ? ? ?for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) { + ? ? ? ? ? ?amf_type = get_byte(ioc); + ? ? ? ? ? ?if (amf_type != AMF_DATA_TYPE_NUMBER) + ? ? ? ? ? ? ? ?return -1;
Memleak. Same below.
+ ? ? ? ? ? ?num_val = av_int2dbl(get_be64(ioc)); + ? ? ? ? ? ?current_array[i] = num_val; + ? ? ? ?} + ? ?} + ? ?if(timeslen != fileposlen) + ? ? ? ?// times->filepositions arrays have different size, will not use such metadata for indexing + ? ? ? ?return -1; + + ? ?for(i = 0; i < arraylen; ++i) { + ? ? ? ?av_add_index_entry(vstream, filepositions[i], times[i]*1000, 0, 0, AVINDEX_KEYFRAME); + ? ?} + + ? ?av_freep(×); + ? ?av_freep(&filepositions); + ? ?return 0; +} + ?static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) { ? ? ?AVCodecContext *acodec, *vcodec; ? ? ?ByteIOContext *ioc; @@ -148,6 +209,17 @@ ? ? ? ? ?case AMF_DATA_TYPE_OBJECT: { ? ? ? ? ? ? ?unsigned int keylen;
+ ? ? ? ? ? ?if (!strcmp(METADATA_KEYFRAMES_TAG, key) && depth == 1) { + ? ? ? ? ? ? ? ?int64_t cur_ioc_pos = url_ftell(ioc); + ? ? ? ? ? ? ? ?/* + ? ? ? ? ? ? ? ? * Try parse keyframes metatag and fill AV index. + ? ? ? ? ? ? ? ? * Reset stream to initial state after that to run default parser + ? ? ? ? ? ? ? ? * to not break default parser behavior + ? ? ? ? ? ? ? ? */ + ? ? ? ? ? ? ? ?if(try_parse_keyframes_index(s, ioc, vstream, max_pos) < 0) + ? ? ? ? ? ? ? ? ? ?url_fseek(ioc, cur_ioc_pos, SEEK_SET); + ? ? ? ? ? ?} + ? ? ? ? ? ? ?while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) { ? ? ? ? ? ? ? ? ?url_fskip(ioc, keylen); //skip key string ? ? ? ? ? ? ? ? ?if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
-- Anton Khirnov
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk1S57cACgkQtQoSQcBnB6sR7ACdFEYox18J3IzMMeQP22yIs1Sa ci0AnR2e/SRMmgQBqirI/8x9ZpN1j2j2 =eGpz -----END PGP SIGNATURE-----
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
All pointed issues resolved. New patch attached. Thank you for review.
First of all, could you please get rid of tabs and use git-formatted patches?
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c (revision 26402) +++ libavformat/flvdec.c (working copy) @@ -30,6 +30,10 @@ #include "avformat.h" #include "flv.h"
+#define METADATA_KEYFRAMES_TAG "keyframes" +#define METADATA_KEYFRAMES_TIMESTAMP_TAG "times" +#define METADATA_KEYFRAMES_BYTEOFFSET_TAG "filepositions" + typedef struct { int wrong_dts; ///< wrong dts due to negative cts } FLVContext; @@ -124,6 +128,97 @@ return length; }
+static int parse_keyframes_index(AVFormatContext *s, ByteIOContext *ioc, AVStream *vstream, int64_t max_pos) { + unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i; + double num_val; + char str_val[256]; + int64_t *times = NULL; + int64_t *filepositions = NULL; + + while (url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { + int64_t* current_array; + + // Expect array object in context + if (get_byte(ioc) != AMF_DATA_TYPE_ARRAY) { + av_freep(×); + av_freep(&filepositions); + return -1; + } + + arraylen = get_be32(ioc); + /* + * Expect only 'times' or 'filepositions' sub-arrays in other case refuse to use such metadata + * for indexing + */ + if (!strcmp(METADATA_KEYFRAMES_TIMESTAMP_TAG, str_val)) { + times = av_mallocz(sizeof(*times) * arraylen);
This will leak memory if the index contains more than one array of each type. Change to realloc maybe? -- Anton Khirnov
All comments processed, more info inline. On 17 February 2011 01:52, Anton Khirnov <anton at khirnov.net> wrote:
First of all, could you please get rid of tabs and use git-formatted patches?
attached patch done via git diff, tabs removed
Index: libavformat/flvdec.c =================================================================== --- libavformat/flvdec.c ? ? ?(revision 26402) +++ libavformat/flvdec.c ? ? ?(working copy) @@ -30,6 +30,10 @@ ?#include "avformat.h" ?#include "flv.h"
+#define METADATA_KEYFRAMES_TAG "keyframes" +#define METADATA_KEYFRAMES_TIMESTAMP_TAG "times" +#define METADATA_KEYFRAMES_BYTEOFFSET_TAG "filepositions" + ?typedef struct { ? ? ?int wrong_dts; ///< wrong dts due to negative cts ?} FLVContext; @@ -124,6 +128,97 @@ ? ? ?return length; ?}
+static int parse_keyframes_index(AVFormatContext *s, ByteIOContext *ioc, AVStream *vstream, int64_t max_pos) { + ? ?unsigned int arraylen = 0, timeslen = 0, fileposlen = 0, i; + ? ?double num_val; + ? ?char str_val[256]; + ? ?int64_t *times = NULL; + ? ?int64_t *filepositions = NULL; + + ? ?while (url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { + ? ? ? ?int64_t* current_array; + + ? ? ? ?// Expect array object in context + ? ? ? ?if (get_byte(ioc) != AMF_DATA_TYPE_ARRAY) { + ? ? ? ? ? ?av_freep(×); + ? ? ? ? ? ?av_freep(&filepositions); + ? ? ? ? ? ?return -1; + ? ? } + + ? ? ? ?arraylen = get_be32(ioc); + ? ? ? ?/* + ? ? ? ? * Expect only 'times' or 'filepositions' sub-arrays in other case refuse to use such metadata + ? ? ? ? * for indexing + ? ? ? ? */ + ? ? ? ?if (!strcmp(METADATA_KEYFRAMES_TIMESTAMP_TAG, str_val)) { + ? ? ? ? ? ?times = av_mallocz(sizeof(*times) * arraylen);
This will leak memory if the index contains more than one array of each type. Change to realloc maybe?
No, I think unsutable metadata structure (two arrays which you point) should be skipped and not used for indexing at all, as it is suspicious that structure does not conform recommendations. But I fix the mem leaks in cases when parser return because of unsuitable metadata structure
-- Anton Khirnov
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk1cKu4ACgkQtQoSQcBnB6uLogCdETgpAHrZc0C3uTNRqbQuBJKK aT8AniQkZ5ElBtPsnt8rPsnHsZl3p2jD =n/wX -----END PGP SIGNATURE-----
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
Can someone review and probably apply the patch?
Hi On Thu, Mar 03, 2011 at 11:35:27AM +0600, Kharkov Alexander wrote:
Can someone review and probably apply the patch?
Iam sorry for the delay, the patch has been applied with cleanups to ffmpeg. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides
Thanks, Michael I just checkout this changes. Actually committed patch have rare noticeable but very unpleasant bug which were not present in original sent patch. Current keyframes data parser unconditionally rewind metadata to the end at the end of function. As result ALL metadata located after keyframes index not parsed, and as metadata object can have ANY placement inside metadata it can lead to unpredictable result (bitrate can not be found, etc.). As result FLV movie will not play at all in such situation. static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream *vstream, int64_t max_pos) { ... avio_seek(ioc, max_pos, SEEK_SET); } Here max pos is the END of all metadata not keyframes object. There are no normal way in FLV format to determine where object end is located except loop over all embeded object (this is default metadata parser behavior in flvdec.c). To fix it I suggest following: rewind metadata stream to initial keyframes position after this object is parsed and default parser will continue parse all metadata as usual. So proposed fix will looks like following: static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream *vstream, int64_t max_pos) { int64_t initial_pos = url_ftell(ioc); ... avio_seek(ioc, initial_pos, SEEK_SET); ^^^^^^^^^^^^^ } I've attached patch just in case. On 1 April 2011 19:00, Michael Niedermayer <michaelni@gmx.at> wrote:
Hi
On Thu, Mar 03, 2011 at 11:35:27AM +0600, Kharkov Alexander wrote:
Can someone review and probably apply the patch?
Iam sorry for the delay, the patch has been applied with cleanups to ffmpeg.
[...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk2Vvm8ACgkQYR7HhwQLD6t4sQCgkzLMBEyqIb1gpwG62yz0b11g vLUAoItL9VMR/OiziQqM9/LqOhaAZP4A =Mkf+ -----END PGP SIGNATURE-----
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Fri, Apr 08, 2011 at 04:20:45PM +0700, Kharkov Alexander wrote:
Thanks, Michael I just checkout this changes. Actually committed patch have rare noticeable but very unpleasant bug which were not present in original sent patch.
Current keyframes data parser unconditionally rewind metadata to the end at the end of function. As result ALL metadata located after keyframes index not parsed, and as metadata object can have ANY placement inside metadata it can lead to unpredictable result (bitrate can not be found, etc.). As result FLV movie will not play at all in such situation.
static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream *vstream, int64_t max_pos) { ... avio_seek(ioc, max_pos, SEEK_SET); } Here max pos is the END of all metadata not keyframes object. There are no normal way in FLV format to determine where object end is located except loop over all embeded object (this is default metadata parser behavior in flvdec.c). To fix it I suggest following: rewind metadata stream to initial keyframes position after this object is parsed and default parser will continue parse all metadata as usual. So proposed fix will looks like following:
static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream *vstream, int64_t max_pos) { int64_t initial_pos = url_ftell(ioc); ... avio_seek(ioc, initial_pos, SEEK_SET); ^^^^^^^^^^^^^ } I've attached patch just in case.
thanks patch applied i also added a seekable check as the seek back could cause problems otherwise [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
Kharkov Alexander wrote:
Could you rewrite the patch to read all the index stuff in one single function, that should allow you to drop a lot of your temporary variables and flags and will also make it much easier to understand. Ok, done. Patch rewritten now 'keyframes' based index filled in single function.
is there a sample that has this kind of index in the sample collection, if not could you upload one?
is there a sample that has this kind of index in the sample collection, if not could you upload one?
I did not find such sample at samples.mplayerhq.hu, so I upload my as described in instruction http://www.ffmpeg.org/bugreports.html to ftp://upload.ffmpeg.org, directory /MPlayer/incoming/flv_keyframes_index there are flv file and description: has_keyframes.txt has_keyframes.flv Actually you did not notice anything valuable on small file, to see the purpose of the patch it is required to stream big FLV (100Mb for example) start play this file over HTTP and then seek to the end. By default mplayer will try to download all file to required position, with patch it will use keyframes index to determine nearest to required time remote file postion and perform HTTP range request.
participants (5)
-
anton@khirnov.net -
Kharkov Alexander -
kharkovalexander@gmail.com -
Michael Niedermayer -
vladoman@gmail.com