com.coremedia.iso.boxes.HandlerBox Java Examples
The following examples show how to use
com.coremedia.iso.boxes.HandlerBox.
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: MP4Builder.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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 #2
Source File: MP4Builder.java From VideoCompressor with Apache License 2.0 | 4 votes |
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 #3
Source File: MP4Builder.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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 #4
Source File: MP4Builder.java From react-native-video-helper with MIT License | 4 votes |
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 #5
Source File: MP4Builder.java From VideoCompressor with Apache License 2.0 | 4 votes |
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 #6
Source File: MP4Builder.java From talk-android with MIT License | 4 votes |
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 #7
Source File: MP4Builder.java From SiliCompressor with Apache License 2.0 | 4 votes |
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 #8
Source File: MP4Builder.java From deltachat-android with GNU General Public License v3.0 | 4 votes |
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 #9
Source File: MediaHelper.java From AndroidVideoSamples with Apache License 2.0 | 4 votes |
public static Uri RotateVideo( Uri uri, int rotation ) { Uri rotatedVideoUri = null; try { IsoFile file = new IsoFile( uri.toString() ); List<Box> boxes = file.getMovieBox().getBoxes(); for ( Box box : boxes ) { if ( box instanceof TrackBox ) { TrackBox trackBox = (TrackBox) box; HandlerBox handlerBox = trackBox.getMediaBox().getHandlerBox(); if ( handlerBox.getHandlerType().toLowerCase( Locale.US ).equals( "vide" ) ) { TrackHeaderBox trackHeaderBox = trackBox.getTrackHeaderBox(); trackHeaderBox.setMatrix( GetMatrixFromRotation( rotation ) ); } } } String pathWithoutExtension = uri.toString().replace( ".mp4", "" ); String rotatedFileName = String.format( Locale.US, "%s_rotated_to_%d.mp4", pathWithoutExtension, rotation ); FileOutputStream videoFileOutputStream = new FileOutputStream( rotatedFileName ); file.getBox( videoFileOutputStream.getChannel() ); file.close(); videoFileOutputStream.close(); rotatedVideoUri = Uri.parse( rotatedFileName ); } catch ( IOException e ) { e.printStackTrace(); return null; } return rotatedVideoUri; }
Example #10
Source File: MP4Builder.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
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 #11
Source File: MP4Builder.java From Telegram with GNU General Public License v2.0 | 4 votes |
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; }