Package org.mp4parser.muxer.builder
Class FragmentedMp4Builder
- java.lang.Object
-
- org.mp4parser.muxer.builder.FragmentedMp4Builder
-
- All Implemented Interfaces:
Mp4Builder
public class FragmentedMp4Builder extends Object implements Mp4Builder
Creates a fragmented MP4 file.
-
-
Field Summary
Fields Modifier and Type Field Description protected Fragmenterfragmenter
-
Constructor Summary
Constructors Constructor Description FragmentedMp4Builder()
-
Method Summary
Modifier and Type Method Description Containerbuild(Movie movie)Builds the actual IsoFile from the Movie.protected DataInformationBoxcreateDinf(Movie movie, Track track)protected ParsableBoxcreateEdts(Track track, Movie movie)protected intcreateFragment(List<Box> moofsMdats, Track track, long startSample, long endSample, int sequence)ParsableBoxcreateFtyp(Movie movie)protected BoxcreateMdat(long startSample, long endSample, Track track, int i)protected ParsableBoxcreateMdhd(Movie movie, Track track)protected ParsableBoxcreateMdia(Track track, Movie movie)protected ParsableBoxcreateMdiaHdlr(Track track, Movie movie)protected voidcreateMfhd(long startSample, long endSample, Track track, int sequenceNumber, MovieFragmentBox parent)protected ParsableBoxcreateMfra(Movie movie, Container isoFile)Creates a 'mfra' - movie fragment random access box for the given movie in the given isofile.protected ParsableBoxcreateMinf(Track track, Movie movie)protected ParsableBoxcreateMoof(long startSample, long endSample, Track track, int sequenceNumber)Creates a 'moof' box for a given sequence of samples.protected List<Box>createMoofMdat(Movie movie)protected ParsableBoxcreateMoov(Movie movie)Creates a fully populated 'moov' box with all child boxes.protected ParsableBoxcreateMvex(Movie movie)Creates a 'mvex' - movie extends box and populates it with 'trex' boxes by callingcreateTrex(Movie, Track)for each track to generate themprotected ParsableBoxcreateMvhd(Movie movie)Creates a single 'mvhd' movie header box for a given movie.protected voidcreateSaio(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent, MovieFragmentBox moof)protected voidcreateSaiz(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent)protected voidcreateSenc(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent)protected ParsableBoxcreateStbl(Movie movie, Track track)protected voidcreateStsd(Track track, SampleTableBox stbl)protected voidcreateTfdt(long startSample, Track track, TrackFragmentBox parent)protected voidcreateTfhd(long startSample, long endSample, Track track, int sequenceNumber, TrackFragmentBox parent)protected BoxcreateTfra(Track track, Container isoFile)Creates a 'tfra' - track fragment random access box for the given track with the isoFile.protected ParsableBoxcreateTkhd(Movie movie, Track track)protected voidcreateTraf(long startSample, long endSample, Track track, int sequenceNumber, MovieFragmentBox parent)protected ParsableBoxcreateTrak(Track track, Movie movie)protected ParsableBoxcreateTrex(Movie movie, Track track)protected voidcreateTrun(long startSample, long endSample, Track track, int sequenceNumber, TrackFragmentBox parent)Creates one or more track run boxes for a given sequence.DategetDate()FragmentergetFragmenter()protected List<Sample>getSamples(long startSample, long endSample, Track track)Gets all samples starting withstartSample(one based -> one is the first) and ending withendSample(exclusive).protected long[]getSampleSizes(long startSample, long endSample, Track track, int sequenceNumber)Gets the sizes of a sequence of samples.voidsetFragmenter(Fragmenter fragmenter)
-
-
-
Field Detail
-
fragmenter
protected Fragmenter fragmenter
-
-
Method Detail
-
getDate
public Date getDate()
-
createFtyp
public ParsableBox createFtyp(Movie movie)
-
createFragment
protected int createFragment(List<Box> moofsMdats, Track track, long startSample, long endSample, int sequence)
-
build
public Container build(Movie movie)
Builds the actual IsoFile from the Movie.- Specified by:
buildin interfaceMp4Builder- Parameters:
movie- data source- Returns:
- the freshly built IsoFile
-
createTfhd
protected void createTfhd(long startSample, long endSample, Track track, int sequenceNumber, TrackFragmentBox parent)
-
createMfhd
protected void createMfhd(long startSample, long endSample, Track track, int sequenceNumber, MovieFragmentBox parent)
-
createTraf
protected void createTraf(long startSample, long endSample, Track track, int sequenceNumber, MovieFragmentBox parent)
-
createSenc
protected void createSenc(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent)
-
createSaio
protected void createSaio(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent, MovieFragmentBox moof)
-
createSaiz
protected void createSaiz(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent)
-
getSamples
protected List<Sample> getSamples(long startSample, long endSample, Track track)
Gets all samples starting withstartSample(one based -> one is the first) and ending withendSample(exclusive).- Parameters:
startSample- low endpoint (inclusive) of the sample sequenceendSample- high endpoint (exclusive) of the sample sequencetrack- source of the samples- Returns:
- a
List<Sample>of raw samples
-
getSampleSizes
protected long[] getSampleSizes(long startSample, long endSample, Track track, int sequenceNumber)Gets the sizes of a sequence of samples.- Parameters:
startSample- low endpoint (inclusive) of the sample sequenceendSample- high endpoint (exclusive) of the sample sequencetrack- source of the samplessequenceNumber- the fragment index of the requested list of samples- Returns:
- the sample sizes in the given interval
-
createTfdt
protected void createTfdt(long startSample, Track track, TrackFragmentBox parent)
-
createTrun
protected void createTrun(long startSample, long endSample, Track track, int sequenceNumber, TrackFragmentBox parent)Creates one or more track run boxes for a given sequence.- Parameters:
startSample- low endpoint (inclusive) of the sample sequenceendSample- high endpoint (exclusive) of the sample sequencetrack- source of the samplessequenceNumber- the fragment index of the requested list of samplesparent- the created box must be added to this box
-
createMoof
protected ParsableBox createMoof(long startSample, long endSample, Track track, int sequenceNumber)
Creates a 'moof' box for a given sequence of samples.- Parameters:
startSample- low endpoint (inclusive) of the sample sequenceendSample- high endpoint (exclusive) of the sample sequencetrack- source of the samplessequenceNumber- the fragment index of the requested list of samples- Returns:
- the list of TrackRun boxes.
-
createMvhd
protected ParsableBox createMvhd(Movie movie)
Creates a single 'mvhd' movie header box for a given movie.- Parameters:
movie- the concerned movie- Returns:
- an 'mvhd' box
-
createMoov
protected ParsableBox createMoov(Movie movie)
Creates a fully populated 'moov' box with all child boxes. Child boxes are:- Parameters:
movie- the concerned movie- Returns:
- fully populated 'moov'
-
createTfra
protected Box createTfra(Track track, Container isoFile)
Creates a 'tfra' - track fragment random access box for the given track with the isoFile. The tfra contains a map of random access points with time as key and offset within the isofile as value.- Parameters:
track- the concerned trackisoFile- the track is contained in- Returns:
- a track fragment random access box.
-
createMfra
protected ParsableBox createMfra(Movie movie, Container isoFile)
Creates a 'mfra' - movie fragment random access box for the given movie in the given isofile. UsescreateTfra(Track, Container)to generate the child boxes.- Parameters:
movie- concerned movieisoFile- concerned isofile- Returns:
- a complete 'mfra' box
-
createTrex
protected ParsableBox createTrex(Movie movie, Track track)
-
createMvex
protected ParsableBox createMvex(Movie movie)
Creates a 'mvex' - movie extends box and populates it with 'trex' boxes by callingcreateTrex(Movie, Track)for each track to generate them- Parameters:
movie- the source movie- Returns:
- a complete 'mvex'
-
createTkhd
protected ParsableBox createTkhd(Movie movie, Track track)
-
createMdhd
protected ParsableBox createMdhd(Movie movie, Track track)
-
createStbl
protected ParsableBox createStbl(Movie movie, Track track)
-
createStsd
protected void createStsd(Track track, SampleTableBox stbl)
-
createMinf
protected ParsableBox createMinf(Track track, Movie movie)
-
createMdiaHdlr
protected ParsableBox createMdiaHdlr(Track track, Movie movie)
-
createMdia
protected ParsableBox createMdia(Track track, Movie movie)
-
createTrak
protected ParsableBox createTrak(Track track, Movie movie)
-
createEdts
protected ParsableBox createEdts(Track track, Movie movie)
-
createDinf
protected DataInformationBox createDinf(Movie movie, Track track)
-
getFragmenter
public Fragmenter getFragmenter()
-
setFragmenter
public void setFragmenter(Fragmenter fragmenter)
-
-