[FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: fix the duration of m4s segment is unusually smaller than expected.
Liu Steven
lq at chinaffmpeg.org
Tue Oct 9 11:31:12 EEST 2018
> 在 2018年10月9日,下午4:05,C.H.Liu <liuchh83 at gmail.com> 写道:
>
> My test clip is big_buck_bunny_1080p_h264.mov with CMD:
>
> ./ffmpeg -i ~/Downloads/conversion/big_buck_bunny_1080p_h264.mov -t 50 -flags +cgop -g 30 -preset superfast -f hls -hls_segment_type fmp4 -hls_playlist_type vod -hls_time 10 issue/pl.m3u8
>
> The original result is:
>
> #EXTM3U
> #EXT-X-VERSION:7
> #EXT-X-TARGETDURATION:10
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-PLAYLIST-TYPE:VOD
> #EXT-X-MAP:URI="init.mp4"
> #EXTINF:10.416667,
> pl0.m4s
> #EXTINF:1.250000,
> pl1.m4s
> #EXTINF:9.083333,
> pl2.m4s
> #EXTINF:9.791667,
> pl3.m4s
> #EXTINF:10.000000,
> pl4.m4s
> #EXTINF:9.458333,
> pl5.m4s
> #EXT-X-ENDLIST
>
>
>
> After apply the patch, the result become to:
>
> #EXTM3U
> #EXT-X-VERSION:7
> #EXT-X-TARGETDURATION:10
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-PLAYLIST-TYPE:VOD
> #EXT-X-MAP:URI="init.mp4"
> #EXTINF:10.416667,
> pl0.m4s
> #EXTINF:10.333333,
> pl1.m4s
> #EXTINF:9.791667,
> pl2.m4s
> #EXTINF:10.000000,
> pl3.m4s
> #EXTINF:9.458333,
> pl4.m4s
> #EXT-X-ENDLIST
>
>
>
> Seems that the vs→number in function hls_write_packet() was minus once more. Then “end_pts = hls->recording_time * vs→number;” was too small.
>
> After having enough buffer (av_compare_ts() around line 2189), we generate the init.mp4 firstly, then the first segment. It should be generate the second segment, when we DO have enough buffer for the second time, . However, the end_pts dons’t grow any, because the vs→number was subtracted 1.
Ok, you are right until now.
fmp4_init_mode maybe you can remove too.
>
>
> Liu Steven <lq at chinaffmpeg.org> 于2018年10月9日周二 下午3:28写道:
>
>
> > 在 2018年10月9日,下午3:17,Liu Steven <lq at chinaffmpeg.org> 写道:
> >
> >
> >
> >> 在 2018年10月9日,下午2:56,Charles Liu <liuchh83 at gmail.com> 写道:
> >>
> >> In fmp4 mode, the duration of the second m4s segment is unusually smaller than the expected segment time.
> >>
> >> Signed-off-by: Charles Liu <liuchh83 at gmail.com>
> >> ---
> >> libavformat/hlsenc.c | 4 ----
> >> 1 file changed, 4 deletions(-)
> >>
> >> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> >> index 28c2dd62fc..3ccd8756f6 100644
> >> --- a/libavformat/hlsenc.c
> >> +++ b/libavformat/hlsenc.c
> >> @@ -2233,10 +2233,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
> >> }
> >> }
> >>
> >> - if (vs->fmp4_init_mode) {
> >> - vs->number--;
> >> - }
> >
> > No, this is reserve, will be used by byterange mode
>
> Ah, sorry my mistake, it is because the when the init.mp4 is not in the sequence, so the start number should be 0.
> >> -
> >> if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> >> if (hls->flags & HLS_SINGLE_FILE) {
> >> ret = flush_dynbuf(vs, &range_length);
> >> --
> >> 2.19.1
> >>
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel at ffmpeg.org
> >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list