Message ID | 20161012101141.9933-1-lq@chinaffmpeg.org |
---|---|
State | Accepted |
Commit | 5702416c57afb2bb062eb69d60fc42c31c91b674 |
Headers | show |
On Wed, Oct 12, 2016 at 06:11:41PM +0800, Steven Liu wrote: > when living stream cannot seekable, don't write duration and > filesize in metadata, and donnot seek at the flv_write_trailer > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > --- > libavformat/flvenc.c | 49 ++++++++++++++++++++++++++++--------------------- > 1 files changed, 28 insertions(+), 21 deletions(-) This will also remove these fields from -f hds is that intended ? is this correct (that is according to hds specs) ? [...]
2016-10-13 4:08 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>: > On Wed, Oct 12, 2016 at 06:11:41PM +0800, Steven Liu wrote: > > when living stream cannot seekable, don't write duration and > > filesize in metadata, and donnot seek at the flv_write_trailer > > > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > > --- > > libavformat/flvenc.c | 49 ++++++++++++++++++++++++++++-- > ------------------- > > 1 files changed, 28 insertions(+), 21 deletions(-) > > This will also remove these fields from > -f hds > is that intended ? > if cannot seekable when living stream. the duration and the filesize value is 0, the value is wrong. so i think remove it is a right way, because there have no describe to the duration and the filesize for use, some media player will use the value to control play duration. yes! that's a shit media player, but i think it can fix by publish tools. is this correct (that is according to hds specs) ? > so i think it can use a flvflags to control is write the duration and filesize, for example FLV_RTMP FLV_HDS is that right? Thanks > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > I am the wisest man alive, for I know one thing, and that is that I know > nothing. -- Socrates > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >
On Thu, Oct 13, 2016 at 09:16:55AM +0800, Steven Liu wrote: > 2016-10-13 4:08 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>: > > > On Wed, Oct 12, 2016 at 06:11:41PM +0800, Steven Liu wrote: > > > when living stream cannot seekable, don't write duration and > > > filesize in metadata, and donnot seek at the flv_write_trailer > > > > > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > > > --- > > > libavformat/flvenc.c | 49 ++++++++++++++++++++++++++++-- > > ------------------- > > > 1 files changed, 28 insertions(+), 21 deletions(-) > > > > This will also remove these fields from > > -f hds > > is that intended ? > > > if cannot seekable when living stream. the duration and the filesize value > is 0, the value is wrong. > so i think remove it is a right way, because there have no describe to the > duration and the filesize for use, > some media player will use the value to control play duration. yes! that's > a shit media player, but i think it can fix by publish tools. patch applied thx [...]
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 99903f5..e50f8e4 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -234,16 +234,18 @@ static void write_metadata(AVFormatContext *s, unsigned int ts) metadata_count_pos = avio_tell(pb); metadata_count = 4 * !!flv->video_par + 5 * !!flv->audio_par + - 1 * !!flv->data_par + - 2; // +2 for duration and file size - + 1 * !!flv->data_par; + if (pb->seekable) { + metadata_count += 2; // +2 for duration and file size + } avio_wb32(pb, metadata_count); - put_amf_string(pb, "duration"); - flv->duration_offset = avio_tell(pb); - - // fill in the guessed duration, it'll be corrected later if incorrect - put_amf_double(pb, s->duration / AV_TIME_BASE); + if (pb->seekable) { + put_amf_string(pb, "duration"); + flv->duration_offset = avio_tell(pb); + // fill in the guessed duration, it'll be corrected later if incorrect + put_amf_double(pb, s->duration / AV_TIME_BASE); + } if (flv->video_par) { put_amf_string(pb, "width"); @@ -319,9 +321,11 @@ static void write_metadata(AVFormatContext *s, unsigned int ts) metadata_count++; } - put_amf_string(pb, "filesize"); - flv->filesize_offset = avio_tell(pb); - put_amf_double(pb, 0); // delayed write + if (pb->seekable) { + put_amf_string(pb, "filesize"); + flv->filesize_offset = avio_tell(pb); + put_amf_double(pb, 0); // delayed write + } put_amf_string(pb, ""); avio_w8(pb, AMF_END_OF_OBJECT); @@ -543,16 +547,19 @@ static int flv_write_trailer(AVFormatContext *s) file_size = avio_tell(pb); - /* update information */ - if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0) - av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n"); - else - put_amf_double(pb, flv->duration / (double)1000); - if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0) - av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n"); - else - put_amf_double(pb, file_size); - + if (pb->seekable) { + /* update information */ + if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0) { + av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n"); + } else { + put_amf_double(pb, flv->duration / (double)1000); + } + if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0) { + av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n"); + } else { + put_amf_double(pb, file_size); + } + } avio_seek(pb, file_size, SEEK_SET); return 0; }
when living stream cannot seekable, don't write duration and filesize in metadata, and donnot seek at the flv_write_trailer Signed-off-by: Steven Liu <lq@chinaffmpeg.org> --- libavformat/flvenc.c | 49 ++++++++++++++++++++++++++++--------------------- 1 files changed, 28 insertions(+), 21 deletions(-)