mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-02 20:35:37 +02:00
avformat/flvdec: parse keyframe before a\v stream was created add_keyframes_index() when stream created or keyframe parsed
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit ad14aab3b4f88cdb6c2a3f8877c578e5a8042f1d) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
88e3e6b943
commit
b4922daead
@ -128,6 +128,7 @@ static void add_keyframes_index(AVFormatContext *s)
|
|||||||
|
|
||||||
static AVStream *create_stream(AVFormatContext *s, int codec_type)
|
static AVStream *create_stream(AVFormatContext *s, int codec_type)
|
||||||
{
|
{
|
||||||
|
FLVContext *flv = s->priv_data;
|
||||||
AVStream *st = avformat_new_stream(s, NULL);
|
AVStream *st = avformat_new_stream(s, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -138,6 +139,8 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type)
|
|||||||
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
|
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
|
||||||
|
|
||||||
avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
|
avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
|
||||||
|
flv->last_keyframe_stream_index = s->nb_streams - 1;
|
||||||
|
add_keyframes_index(s);
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +416,6 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m
|
|||||||
flv->keyframe_count = timeslen;
|
flv->keyframe_count = timeslen;
|
||||||
times = NULL;
|
times = NULL;
|
||||||
filepositions = NULL;
|
filepositions = NULL;
|
||||||
add_keyframes_index(s);
|
|
||||||
} else {
|
} else {
|
||||||
invalid:
|
invalid:
|
||||||
av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
|
av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
|
||||||
@ -455,12 +457,14 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AMF_DATA_TYPE_OBJECT:
|
case AMF_DATA_TYPE_OBJECT:
|
||||||
if ((vstream || astream) && key &&
|
if (key &&
|
||||||
ioc->seekable &&
|
ioc->seekable &&
|
||||||
!strcmp(KEYFRAMES_TAG, key) && depth == 1)
|
!strcmp(KEYFRAMES_TAG, key) && depth == 1)
|
||||||
if (parse_keyframes_index(s, ioc,
|
if (parse_keyframes_index(s, ioc,
|
||||||
max_pos) < 0)
|
max_pos) < 0)
|
||||||
av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
|
av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
|
||||||
|
else
|
||||||
|
add_keyframes_index(s);
|
||||||
while (avio_tell(ioc) < max_pos - 2 &&
|
while (avio_tell(ioc) < max_pos - 2 &&
|
||||||
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
|
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
|
||||||
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
|
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user