com.googlecode.mp4parser.util.Matrix Java Examples

The following examples show how to use com.googlecode.mp4parser.util.Matrix. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Mp4Movie.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #2
Source File: Mp4Movie.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #3
Source File: Mp4Movie.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #4
Source File: MediaHelper.java    From AndroidVideoSamples with Apache License 2.0 5 votes vote down vote up
private static Matrix GetMatrixFromRotation( int rotation ) {
   switch ( rotation ) {
   case 90:
      return Matrix.ROTATE_90;
   case 180:
      return Matrix.ROTATE_180;
   case 270:
      return Matrix.ROTATE_270;
   default:
   case 0:
      return Matrix.ROTATE_0;
   }
}
 
Example #5
Source File: Mp4Movie.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #6
Source File: Mp4Movie.java    From SiliCompressor with Apache License 2.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #7
Source File: Mp4Movie.java    From talk-android with MIT License 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #8
Source File: Mp4Movie.java    From VideoCompressor with Apache License 2.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #9
Source File: Mp4Movie.java    From react-native-video-helper with MIT License 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #10
Source File: Mp4Movie.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #11
Source File: Mp4Movie.java    From VideoCompressor with Apache License 2.0 5 votes vote down vote up
public void setRotation(int angle) {
    if (angle == 0) {
        matrix = Matrix.ROTATE_0;
    } else if (angle == 90) {
        matrix = Matrix.ROTATE_90;
    } else if (angle == 180) {
        matrix = Matrix.ROTATE_180;
    } else if (angle == 270) {
        matrix = Matrix.ROTATE_270;
    }
}
 
Example #12
Source File: ProcessVideoUtils.java    From patrol-android with GNU General Public License v3.0 4 votes vote down vote up
public static void startTrim(File src, File dst, double startTime, double endTime) throws IOException {
    FileDataSourceImpl file = new FileDataSourceImpl(src);
    Movie movie = MovieCreator.build(file);
    List<Track> tracks = movie.getTracks();
    movie.setTracks(new LinkedList<Track>());

    Log.d(TAG, "startTrim: " + startTime + " " + endTime);
    for (Track track : tracks) {
        long currentSample = 0;
        double currentTime = 0;
        long startSample = -1;
        long endSample = -1;
        for (int i = 0; i < track.getSampleDurations().length; i++) {
            if (currentTime <= startTime) {

                // current sample is still before the new starttime
                startSample = currentSample;
            }
            if (currentTime <= endTime) {
                // current sample is after the new start time and still before the new endtime
                endSample = currentSample;
            } else {
                // current sample is after the end of the cropped video
                break;
            }
            currentTime += (double) track.getSampleDurations()[i] / (double) track.getTrackMetaData().getTimescale();
            currentSample++;
        }
        movie.addTrack(new CroppedTrack(track, startSample, endSample));
    }
    Container out = new DefaultMp4Builder().build(movie);
    MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
    mvhd.setMatrix(Matrix.ROTATE_180);
    if (!dst.exists()) {
        dst.createNewFile();
    }
    FileOutputStream fos = new FileOutputStream(dst);
    WritableByteChannel fc = fos.getChannel();
    try {
        out.writeContainer(fc);
    }catch (Exception e){
        e.printStackTrace();
    } finally {
        fc.close();
        fos.close();
        file.close();
    }
}
 
Example #13
Source File: MP4Builder.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}
 
Example #14
Source File: Mp4Movie.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #15
Source File: Mp4Movie.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #16
Source File: MP4Builder.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}
 
Example #17
Source File: MP4Builder.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}
 
Example #18
Source File: Mp4Movie.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #19
Source File: Mp4Movie.java    From VideoCompressor with Apache License 2.0 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #20
Source File: MP4Builder.java    From deltachat-android with GNU General Public License v3.0 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}
 
Example #21
Source File: Mp4Movie.java    From deltachat-android with GNU General Public License v3.0 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #22
Source File: ProcessVideoUtils.java    From patrol-android with GNU General Public License v3.0 4 votes vote down vote up
public static boolean concatTwoVideos(File src1, File src2, File dst) {
    try {
        FileDataSourceImpl file1 = new FileDataSourceImpl(src1);
        FileDataSourceImpl file2 = new FileDataSourceImpl(src2);
        Movie result = new Movie();
        Movie movie1 = MovieCreator.build(file1);
        Movie movie2 = MovieCreator.build(file2);

        Movie[] inMovies = new Movie[]{
                movie1, movie2
        };

        List<Track> videoTracks = new LinkedList<Track>();
        List<Track> audioTracks = new LinkedList<Track>();

        for (Movie m : inMovies) {
            for (Track t : m.getTracks()) {
                if (t.getHandler().equals("soun")) {
                    audioTracks.add(t);
                }
                if (t.getHandler().equals("vide")) {
                    videoTracks.add(t);
                }
            }
        }

        if (audioTracks.size() > 0) {

            result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));

        }
        if (videoTracks.size() > 0) {

            result.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));

        }

        Container out = new DefaultMp4Builder().build(result);
        MovieHeaderBox mvhd = Path.getPath(out, "moov/mvhd");
        mvhd.setMatrix(Matrix.ROTATE_180);
        if (!dst.exists()) {
            dst.createNewFile();
        }
        FileOutputStream fos = new FileOutputStream(dst);
        WritableByteChannel fc = fos.getChannel();
        try {
            out.writeContainer(fc);
        } finally {
            fc.close();
            fos.close();
            file1.close();
            file2.close();
        }
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
 
Example #23
Source File: Mp4Movie.java    From react-native-video-helper with MIT License 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #24
Source File: MP4Builder.java    From SiliCompressor with Apache License 2.0 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}
 
Example #25
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}
 
Example #26
Source File: Mp4Movie.java    From SiliCompressor with Apache License 2.0 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #27
Source File: MP4Builder.java    From talk-android with MIT License 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}
 
Example #28
Source File: Mp4Movie.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #29
Source File: Mp4Movie.java    From talk-android with MIT License 4 votes vote down vote up
public Matrix getMatrix() {
    return matrix;
}
 
Example #30
Source File: MP4Builder.java    From VideoCompressor with Apache License 2.0 4 votes vote down vote up
protected TrackBox createTrackBox(Track track, Mp4Movie movie) {
    TrackBox trackBox = new TrackBox();
    TrackHeaderBox tkhd = new TrackHeaderBox();

    tkhd.setEnabled(true);
    tkhd.setInMovie(true);
    tkhd.setInPreview(true);
    if (track.isAudio()) {
        tkhd.setMatrix(Matrix.ROTATE_0);
    } else {
        tkhd.setMatrix(movie.getMatrix());
    }
    tkhd.setAlternateGroup(0);
    tkhd.setCreationTime(track.getCreationTime());
    tkhd.setDuration(track.getDuration() * getTimescale(movie) / track.getTimeScale());
    tkhd.setHeight(track.getHeight());
    tkhd.setWidth(track.getWidth());
    tkhd.setLayer(0);
    tkhd.setModificationTime(new Date());
    tkhd.setTrackId(track.getTrackId() + 1);
    tkhd.setVolume(track.getVolume());

    trackBox.addBox(tkhd);

    MediaBox mdia = new MediaBox();
    trackBox.addBox(mdia);
    MediaHeaderBox mdhd = new MediaHeaderBox();
    mdhd.setCreationTime(track.getCreationTime());
    mdhd.setDuration(track.getDuration());
    mdhd.setTimescale(track.getTimeScale());
    mdhd.setLanguage("eng");
    mdia.addBox(mdhd);
    HandlerBox hdlr = new HandlerBox();
    hdlr.setName(track.isAudio() ? "SoundHandle" : "VideoHandle");
    hdlr.setHandlerType(track.getHandler());

    mdia.addBox(hdlr);

    MediaInformationBox minf = new MediaInformationBox();
    minf.addBox(track.getMediaHeaderBox());

    DataInformationBox dinf = new DataInformationBox();
    DataReferenceBox dref = new DataReferenceBox();
    dinf.addBox(dref);
    DataEntryUrlBox url = new DataEntryUrlBox();
    url.setFlags(1);
    dref.addBox(url);
    minf.addBox(dinf);

    Box stbl = createStbl(track);
    minf.addBox(stbl);
    mdia.addBox(minf);

    return trackBox;
}