Opened 6 years ago

Closed 5 years ago

#7166 closed defect (fixed)

HLS format with fmp4 creates empty init.mp4 file when there is a single m4s output segment

Reported by: Jordan Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: hls
Cc: james@moxion.io Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
When using the hls format and fmp4 segment type, ffmpeg creates broken output segments if the input file has a short duration.

Specifically whenever there is a single m4s output segment. This seems to happen anytime the input file duration is less than hls_time, or if the input file only has a single keyframe.

With the repro command below, four files are produced.

  1. init.mp4
  2. segment0.m4s
  3. segment.m3u8 (contents appear correct)
  4. ffmpeg log (from -report flag)

The init.mp4 file is empty with 0 bytes. I inspected the segment0.m4s with mp4dump, and it contains the data that should be in init.mp4, (styp, ftyp & moov).

I expected init.mp4 to contain the styp, ftyp and moov atoms, and segment0.m4s should contain a moof and mdat.

How to reproduce:

% ffmpeg -i h264_5s.mp4 -f hls -hls_segment_type fmp4 -hls_time 10 -report segment.m3u8
ffmpeg version

Reproduced with latest build from today (2018-04-26), and 4.0 release.

I'll upload the report log and sample mp4

Attachments (3)

h264_5s.mp4 (1.0 MB ) - added by Jordan 6 years ago.
short video to reproduce bug (about 5 seconds, h264)
ffmpeg-20180426-143435.log (48.9 KB ) - added by Jordan 6 years ago.
ffmpeg report log
mp4dump-segment0.txt (4.4 KB ) - added by Jordan 6 years ago.
mp4dump of segment0.m4s. seems to match expected contents of init.mp4

Download all attachments as: .zip

Change History (7)

by Jordan, 6 years ago

Attachment: h264_5s.mp4 added

short video to reproduce bug (about 5 seconds, h264)

by Jordan, 6 years ago

Attachment: ffmpeg-20180426-143435.log added

ffmpeg report log

by Jordan, 6 years ago

Attachment: mp4dump-segment0.txt added

mp4dump of segment0.m4s. seems to match expected contents of init.mp4

comment:1 by Carl Eugen Hoyos, 6 years ago

Keywords: hls added

This is not reproducible with testsrc2=d=2 as input?

comment:2 by Jordan, 6 years ago

cehoyos, I am able to reproduce with testsrc2. Thanks for your suggestion, I wasn't aware of that feature.

So, here's a cmd to repro the bug with testsrc2 (2 second video)

ffmpeg -f lavfi -i testsrc2=d=2 -f hls -hls_segment_type fmp4 -hls_time 10 -report segment.m3u8

Sanity check, output works fine with a 20 second test

ffmpeg -f lavfi -i testsrc2=d=20 -f hls -hls_segment_type fmp4 -hls_time 10 -report segment.m3u8

comment:3 by James Maguire, 6 years ago

Cc: james@moxion.io added

Possibly related commit id: 8318f60845bbbc4d33a39eee45e4daff0e5dacfb
Which was a fix for ticket #6888

comment:4 by Carl Eugen Hoyos, 5 years ago

Component: undeterminedavformat
Reproduced by developer: set
Resolution: fixed
Status: newclosed
Version: unspecifiedgit-master
Note: See TracTickets for help on using tickets.