javamp4mpeg-dashmp4parserfmp4

Java mp4parser fragment sequence discontinuity


This use case is a service that manually encodes a series of uncompressed .wav media segments into .m4s fragments for broadcast via MPEG-DASH, using ffmpeg to compress the .wav to .aac and sannies/mp4parser to assemble the aac audio into a .m4s media fragment.

I created this public GitHub project to reproduce the issue in its entirety.

For example, here's the custom ChunkFragmentM4sBuilder.java class.


This log is from ChunkFragmentM4sBuilderTest.java which results in the concatenated test output test-java-mp4parser.mp4 appears to be ok:

Concatenated init .mp4 and fragment .m4s are OK

However, when I play the shipped playlist and segments using VLC, I see these failures in the logs:

mp4: Fragment sequence discontinuity detected 163497124 != 0

This error happens when VLC plays the following DASH playlist:

And here is the latest implementation of my custom fragment builder class and additional notes:

Files.deleteIfExists(Path.of(m4sFilePath));
AACTrackImpl aacTrack=new AACTrackImpl(new FileDataSourceImpl(aacFilePath));
Movie movie=new Movie();
movie.addTrack(aacTrack);
Container mp4file=new ChunkFragmentM4sBuilder(seqNum).build(movie);
FileChannel fc=new FileOutputStream(m4sFilePath).getChannel();
mp4file.writeContainer(fc);
fc.close();

Solution

  • The VLC message is just an info entry and not an error. It's expected since the starting sequence number corresponds to the live-edge.

    You cannot playback that manifest once the live-edge went past the time of the last segment of those 3 provided. You would need to continue generating new segments corrresponding to the current time.

    You can test this easily by making the manifest static, adding a segment list and modifiying the start number.


    Your segments look self-initialized but are not declared as such which will lead to problems. It also wastes bandwidth as you already provide an initialization segment.

    As a reminder you should have: