On Wed, Jul 27, 2016 at 10:17 AM, Michael Niedermayer <mich...@niedermayer.cc> wrote: > On Wed, Jul 27, 2016 at 09:56:02AM +0800, XinZheng Zhang wrote: >> On Wed, Jul 27, 2016 at 7:25 AM, Michael Niedermayer >> <mich...@niedermayer.cc> wrote: >> > On Wed, Jul 27, 2016 at 01:31:29AM +0800, XinZheng Zhang wrote: >> >> On Wed, Jul 27, 2016 at 1:12 AM, Michael Niedermayer >> >> <mich...@niedermayer.cc> wrote: >> >> > On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote: >> > [...] >> >> >> + >> >> >> + AVStream *streams[2] = {vstream, astream}; >> >> >> + for (i = 0; i < 2; i++) { >> >> >> + current_stream = streams[i]; >> >> >> + if (current_stream && current_stream->nb_index_entries==0) { >> >> >> + for (j = 0; j < flv->keyframe_count; j++) { >> >> >> + av_add_index_entry(current_stream, >> >> >> flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000, >> >> >> + 0, 0, AVINDEX_KEYFRAME); >> >> >> + } >> >> >> + } >> >> >> + } >> >> >> + >> >> >> + // free keyframe index only if all expected streams have been >> >> >> created >> >> >> + if (((vstream && vstream->nb_index_entries>0) || >> >> >> !flv->vhead_exists) && >> >> >> + ((astream && astream->nb_index_entries>0) || >> >> >> !flv->ahead_exists)) { >> >> >> + av_freep(&flv->keyframe_times); >> >> >> + av_freep(&flv->keyframe_filepositions); >> >> >> + flv->keyframe_count = 0; >> >> >> + } >> >> >> +} >> >> > >> >> > spliting add_keyframes_index() out must be in a seperate patch >> >> > >> >> > also i would not trust the *head_exists flags, IIRC they can be >> >> > wrong and they are not needed >> >> > the function should just take the table load it with >> >> > av_add_index_entry() and free the table. >> >> > The rest should not be needed >> >> > should be much simpler unless iam missing something >> >> > >> >> > >> >> >> >> If I don't trust the head_exists flags, when should I free the index >> >> table? >> >> Should I keep the index util both a\v stream have been loaded or keep >> >> it util the flv_read_close(). >> > >> > the table was freed after av_add_index_entry() >> > that should still work fine unless i miss somethig >> > >> >> [meta]-[v]-[v]..........................[a] >> In this case both video and audio stream share the same index table. >> I am not know whether the audio stream exists until the first audio >> packet parsed. >> I thought that I should keep the index until all the streams have been >> loaded. > > in the example above the video key frame table would be loaded > and added into the video stream once it has been created, and > freed afterwards > nothing is done with audio (currently or after the change) > > if the audio table is prior the video one its loaded and freed once > the video table is encountered > > do i miss something ? >
Now I understand it. Before that I thought that both streams have to install the index table. > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > There will always be a question for which you do not know the correct answer. > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel