Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java mp4parser to create a single .m4s fragment (without malformation) #447

Open
charneykaye opened this issue Oct 21, 2021 · 0 comments
Open

Comments

@charneykaye
Copy link

charneykaye commented Oct 21, 2021

Also posted to: https://stackoverflow.com/questions/69625970/java-mp4parser-to-create-a-single-m4s-fragment with a +100 reputation bounty for a solution!

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 an .m4s media fragment.

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

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

It's critical that we be able to designate this single .m4s fragment with a sequence number (index) that we will manually increment for each media segment.

The objective is to build an .m4s fragment comprising the box types SegmentTypeBox, SegmentIndexBox, and MovieFragmentBox. As For reference, I have used mp4parser to inspect an .m4s fragment that was generated via ffmpeg -f hls. This specification is available here as a .yaml file

My implementation creates an MP4 without error. But, when the unit test attempts to read the file that the ChunkMp4Builder just wrote to a temp folder:

java.lang.RuntimeException: A cast to int has gone wrong. Please contact the mp4parser discussion group (3724673092)
	at org.mp4parser.tools.CastUtils.l2i(CastUtils.java:30)
	at org.mp4parser.support.AbstractBox.parse(AbstractBox.java:97)
	at org.mp4parser.AbstractBoxParser.parseBox(AbstractBoxParser.java:116)
	at org.mp4parser.BasicContainer.initContainer(BasicContainer.java:107)
	at org.mp4parser.IsoFile.<init>(IsoFile.java:57)
	at org.mp4parser.IsoFile.<init>(IsoFile.java:52)
	at com.charneykaye.TestBase.getMp4Boxes(TestBase.java:116)
	at com.charneykaye.CustomFragmentMp4BuilderTest.run(CustomFragmentMp4BuilderTest.java:78)

The expected box types SegmentTypeBox, SegmentIndexBox, and MovieFragmentBox do appear in the output:

The expected box types SegmentTypeBox, SegmentIndexBox, and MovieFragmentBox do appear in the output

However, at the end of the file appears a box of an unknown type:

There seems to be a box of an unknown type, appearing at the end of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant