Search in sources :

Example 1 with TrackAtom

use of cbit.vcell.export.gloworm.atoms.TrackAtom in project vcell by virtualcell.

the class MediaMethods method writeMovie.

/**
 * This method was created in VisualAge.
 * @param out OutputStream
 */
public static final void writeMovie(File file, MediaMovie movie, boolean isDataFile) throws DataFormatException, IOException {
    // create and write out data atom
    MediaChunk[] chunksToBeWritten = movie.getSelfreferencedChunks();
    MediaData mdat = new MediaData(chunksToBeWritten);
    mdat.writeData(file, isDataFile);
    // create and write out movie atom
    TrackAtom[] traks = new TrackAtom[movie.getTracks().length];
    for (int i = 0; i < movie.getTracks().length; i++) traks[i] = MediaMethods.makeTrackAtom(movie, i);
    MovieHeader mvhd = new MovieHeader(movie.getTimeScale(), movie.getDuration(), movie.getNumberOfTracks());
    UserData userData = new UserData(movie.getUserDataEntries());
    MovieAtom moov = new MovieAtom(mvhd, traks, userData);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    DataOutputStream dout = new DataOutputStream(bout);
    moov.writeData(dout);
    bout.close();
    // byte[] moovBytes = bout.toByteArray();
    RandomAccessFile fw = new RandomAccessFile(file, "rw");
    fw.seek(file.length());
    fw.write(bout.toByteArray());
    fw.close();
}
Also used : MediaData(cbit.vcell.export.gloworm.atoms.MediaData) MovieAtom(cbit.vcell.export.gloworm.atoms.MovieAtom) RandomAccessFile(java.io.RandomAccessFile) TrackAtom(cbit.vcell.export.gloworm.atoms.TrackAtom) UserData(cbit.vcell.export.gloworm.atoms.UserData) DataOutputStream(java.io.DataOutputStream) MovieHeader(cbit.vcell.export.gloworm.atoms.MovieHeader) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with TrackAtom

use of cbit.vcell.export.gloworm.atoms.TrackAtom in project vcell by virtualcell.

the class MediaMethods method makeTrackAtom.

/**
 * This method was created in VisualAge.
 * @return TrackAtom
 * @param movie Movie
 * @param track Track
 */
private static final TrackAtom makeTrackAtom(MediaMovie movie, int trackIndex) throws DataFormatException {
    if ((0 <= trackIndex) && (trackIndex < movie.getTracks().length)) {
        MediaTrack track = movie.getTracks()[trackIndex];
        MediaInformation minf = MediaMethods.makeMediaInformation(track);
        int componentSubtype = 0;
        if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_VIDEO))
            componentSubtype = AtomConstants.COMPONENT_SUBTYPE_VIDEO;
        if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_OBJECT))
            componentSubtype = AtomConstants.COMPONENT_SUBTYPE_OBJECT;
        if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_QTVR))
            componentSubtype = AtomConstants.COMPONENT_SUBTYPE_QTVR;
        HandlerReference mhlr = new HandlerReference("mhlr", componentSubtype);
        MediaHeader mdhd = new MediaHeader(movie.getTimeScale(), track.getDuration());
        MediaAtom mdia = new MediaAtom(mdhd, mhlr, minf);
        TrackHeader tkhd = new TrackHeader(trackIndex + 1, track.getDuration(), track.getWidth(), track.getHeight());
        Edit[] edits;
        if (track.getEdits() == null)
            edits = new Edit[] { new Edit(track.getDuration()) };
        else
            edits = track.getEdits();
        EditList elst = new EditList(edits);
        EditAtom edts = new EditAtom(elst);
        TrackAtom trak = null;
        if (movie instanceof VRMediaMovie) {
            TrackReference trakRef = ((VRMediaMovie) movie).getTrackReference(trackIndex);
            trak = new TrackAtom(tkhd, null, null, edts, trakRef, null, null, mdia, null);
        } else {
            trak = new TrackAtom(tkhd, edts, mdia);
        }
        return trak;
    } else
        throw new DataFormatException("Track index out of bounds !");
}
Also used : MediaHeader(cbit.vcell.export.gloworm.atoms.MediaHeader) BaseMediaHeader(cbit.vcell.export.gloworm.atoms.BaseMediaHeader) MediaInformation(cbit.vcell.export.gloworm.atoms.MediaInformation) BaseMediaInformation(cbit.vcell.export.gloworm.atoms.BaseMediaInformation) VideoMediaInformation(cbit.vcell.export.gloworm.atoms.VideoMediaInformation) MediaAtom(cbit.vcell.export.gloworm.atoms.MediaAtom) TrackHeader(cbit.vcell.export.gloworm.atoms.TrackHeader) HandlerReference(cbit.vcell.export.gloworm.atoms.HandlerReference) DataFormatException(java.util.zip.DataFormatException) EditAtom(cbit.vcell.export.gloworm.atoms.EditAtom) TrackAtom(cbit.vcell.export.gloworm.atoms.TrackAtom) EditList(cbit.vcell.export.gloworm.atoms.EditList) TrackReference(cbit.vcell.export.gloworm.atoms.TrackReference)

Example 3 with TrackAtom

use of cbit.vcell.export.gloworm.atoms.TrackAtom in project vcell by virtualcell.

the class MediaMethods method writeMovie.

/**
 * This method was created in VisualAge.
 * @param out OutputStream
 */
public static final void writeMovie(DataOutputStream dataOutputStream, MediaMovie movie) throws DataFormatException {
    // create and write out data atom
    MediaChunk[] chunksToBeWritten = movie.getSelfreferencedChunks();
    MediaData mdat = new MediaData(chunksToBeWritten);
    mdat.writeData(dataOutputStream);
    // create and write out movie atom
    TrackAtom[] traks = new TrackAtom[movie.getTracks().length];
    for (int i = 0; i < movie.getTracks().length; i++) traks[i] = MediaMethods.makeTrackAtom(movie, i);
    MovieHeader mvhd = new MovieHeader(movie.getTimeScale(), movie.getDuration(), movie.getNumberOfTracks());
    UserData userData = new UserData(movie.getUserDataEntries());
    MovieAtom moov = new MovieAtom(mvhd, traks, userData);
    moov.writeData(dataOutputStream);
}
Also used : MediaData(cbit.vcell.export.gloworm.atoms.MediaData) MovieAtom(cbit.vcell.export.gloworm.atoms.MovieAtom) TrackAtom(cbit.vcell.export.gloworm.atoms.TrackAtom) UserData(cbit.vcell.export.gloworm.atoms.UserData) MovieHeader(cbit.vcell.export.gloworm.atoms.MovieHeader)

Aggregations

TrackAtom (cbit.vcell.export.gloworm.atoms.TrackAtom)3 MediaData (cbit.vcell.export.gloworm.atoms.MediaData)2 MovieAtom (cbit.vcell.export.gloworm.atoms.MovieAtom)2 MovieHeader (cbit.vcell.export.gloworm.atoms.MovieHeader)2 UserData (cbit.vcell.export.gloworm.atoms.UserData)2 BaseMediaHeader (cbit.vcell.export.gloworm.atoms.BaseMediaHeader)1 BaseMediaInformation (cbit.vcell.export.gloworm.atoms.BaseMediaInformation)1 EditAtom (cbit.vcell.export.gloworm.atoms.EditAtom)1 EditList (cbit.vcell.export.gloworm.atoms.EditList)1 HandlerReference (cbit.vcell.export.gloworm.atoms.HandlerReference)1 MediaAtom (cbit.vcell.export.gloworm.atoms.MediaAtom)1 MediaHeader (cbit.vcell.export.gloworm.atoms.MediaHeader)1 MediaInformation (cbit.vcell.export.gloworm.atoms.MediaInformation)1 TrackHeader (cbit.vcell.export.gloworm.atoms.TrackHeader)1 TrackReference (cbit.vcell.export.gloworm.atoms.TrackReference)1 VideoMediaInformation (cbit.vcell.export.gloworm.atoms.VideoMediaInformation)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 DataFormatException (java.util.zip.DataFormatException)1