Class StandardMp4Writer

  • All Implemented Interfaces:
    Closeable, AutoCloseable, SampleSink

    public class StandardMp4Writer
    extends DefaultBoxes
    implements SampleSink
    Creates an MP4 file with ftyp, mdat+, moov order. A very special property of this variant is that it written sequentially. You can start transferring the data while the sink receives it. (in contrast to typical implementations which need random access to write length fields at the beginning of the file)
    • Method Detail

      • close

        public void close()
                   throws IOException
        Description copied from interface: SampleSink
        Free all resources blocked and interrupts the process of writing the output. An implementation should flush all samples that have not yet been written and write the file footer - if exists - before actually freeing the resources.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface SampleSink
        Throws:
        IOException - if closing fails
      • createMoov

        protected Box createMoov()
      • isChunkReady

        protected boolean isChunkReady​(StreamingTrack streamingTrack,
                                       StreamingSample next)
        Tests if the currently received samples for a given track are already a 'chunk' as we want to have it. The next sample will not be part of the chunk will be added to the fragment buffer later.
        Parameters:
        streamingTrack - track to test
        next - the lastest samples
        Returns:
        true if a chunk is to b e created.
      • writeChunkContainer

        protected void writeChunkContainer​(org.mp4parser.streaming.output.mp4.StandardMp4Writer.ChunkContainer chunkContainer)
                                    throws IOException
        Throws:
        IOException
      • acceptSample

        public void acceptSample​(StreamingSample streamingSample,
                                 StreamingTrack streamingTrack)
                          throws IOException
        Description copied from interface: SampleSink
        Adds a samples to the SampleSink. This might or might not cause writing the sample any output stream or channel. Once this method is called the StreamingTrack must be ready and accept calls to any method.
        Specified by:
        acceptSample in interface SampleSink
        Throws:
        IOException - if writing (or reading) fails.