Opened 15 months ago

Last modified 15 months ago

#8847 new defect

Negative segment durations in m3u8 file with small hls_time

Reported by: vschweitzer Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

When using the HLS muxer, some segment durations
in the output m3u8 file are negative when specifying
a very short hls_time (<0.12s for this example).

How to reproduce:

Using the attached h264 file:

./ffmpeg -report -i test.264 -pix_fmt yuv420p -vcodec libx264 -b:v 10000k -hls_segment_type fmp4 -hls_time 0.1 -hls_flags split_by_time+second_level_segment_index -strftime 1 -hls_segment_filename stream-%%18d.m4s -hls_playlist_type event index.m3u8

The uncut command line output can be found in the
attached log file. A sample of the output m3u8 file
looks like this:

[...]
#EXTINF:0.200000,
stream-000000000000000107.m4s
#EXTINF:0.160000,
stream-000000000000000108.m4s
#EXTINF:-0.080000,
stream-000000000000000109.m4s
#EXTINF:0.200000,
stream-000000000000000110.m4s
#EXTINF:0.160000,
stream-000000000000000111.m4s
#EXTINF:-0.040000,
stream-000000000000000112.m4s
[...] 

Although the varying file lengths are somewhat expected,
the negative durations seem invalid.

Additional info:

When disabling B-Frames using "-bf 0", no negative durations occur.

./ffmpeg -report -i test.264 -pix_fmt yuv420p -vcodec libx264 -b:v 10000k -hls_segment_type fmp4 -hls_time 0.1 -hls_flags split_by_time+second_level_segment_index -strftime 1 -hls_segment_filename stream-%%18d.m4s -hls_playlist_type event -bf 0 index.m3u8 

Explicitly setting a framerate for the output changes
the lengths of segments, but does not get rid of negative
segments.

This issue was tested on Ubuntu 18.04 and Windows 10,
using git HEAD and the latest zeranoe build (20200812-bb59bdb)
respectively.

Attachments (4)

test.264 (594.9 KB ) - added by vschweitzer 15 months ago.
Input video file. This is the "foreman" video sequence.
command_line_output.log (124.8 KB ) - added by vschweitzer 15 months ago.
The full, uncut command line output, generated using -report.
command_line_output_no_b_frames.log (124.3 KB ) - added by vschweitzer 15 months ago.
The full, uncut command line output with B-frames disabled. Generated using -report.
0001-avformat-hlsenc-check-the-segment-duration-valid.patch (1.4 KB ) - added by Steven Liu 15 months ago.

Download all attachments as: .zip

Change History (5)

by vschweitzer, 15 months ago

Attachment: test.264 added

Input video file. This is the "foreman" video sequence.

by vschweitzer, 15 months ago

Attachment: command_line_output.log added

The full, uncut command line output, generated using -report.

by vschweitzer, 15 months ago

The full, uncut command line output with B-frames disabled. Generated using -report.

comment:1 by Steven Liu, 15 months ago

try this patch please.
i will send it to maillist on monday if no problem.

Note: See TracTickets for help on using tickets.