public List<SampleEntry> getSampleEntries() { return origTrack.getSampleEntries(); }
public List<SampleEntry> getSampleEntries() { return origTrack.getSampleEntries(); }
public List<SampleEntry> getSampleEntries() { return source.getSampleEntries(); }
public List<SampleEntry> getSampleEntries() { return parent.getSampleEntries(); }
public List<SampleEntry> getSampleEntries() { return source.getSampleEntries(); }
public List<SampleEntry> getSampleEntries() { return source.getSampleEntries(); }
public List<SampleEntry> getSampleEntries() { return source.getSampleEntries(); }
public SilenceTrackImpl(Track ofType, long ms) { source = ofType; name = "" + ms + "ms silence"; assert ofType.getSampleEntries().size() == 1: ""; if ("mp4a".equals(ofType.getSampleEntries().get(0).getType())) { int numFrames = l2i(getTrackMetaData().getTimescale() * ms / 1000 / 1024); decodingTimes = new long[numFrames]; Arrays.fill(decodingTimes, getTrackMetaData().getTimescale() * ms / numFrames / 1000); while (numFrames-- > 0) { samples.add(new SampleImpl((ByteBuffer) ByteBuffer.wrap(new byte[]{ 0x21, 0x10, 0x04, 0x60, (byte) 0x8c, 0x1c, }).rewind(), ofType.getSampleEntries().get(0))); } } else { throw new RuntimeException("Tracks of type " + ofType.getClass().getSimpleName() + " are not supported"); } }
static String getFormat(Track track) { String type = null; for (SampleEntry sampleEntry : track.getSampleEntries()) { OriginalFormatBox frma; frma = Path.getPath((Container) sampleEntry, "sinf/frma"); String _type; if (frma != null) { _type = frma.getDataFormat(); } else { _type = sampleEntry.getType(); } if (type == null) { type = _type; } else { if (!type.equals(_type)) { throw new RuntimeException("The SyncSampleIntersectionFindler only works when all SampleEntries are of the same type. " + type + " vs. " + _type); } } } return type; }
protected void createStsd(Track track, SampleTableBox stbl) { SampleDescriptionBox stsd = new SampleDescriptionBox(); stsd.setBoxes(track.getSampleEntries()); stbl.addBox(stsd); }
protected void createStsd(Track track, SampleTableBox stbl) { SampleDescriptionBox stsd = new SampleDescriptionBox(); stsd.setBoxes(track.getSampleEntries()); stbl.addBox(stsd); }
public AppendTrack(Track... tracks) throws IOException { super(appendTracknames(tracks)); this.tracks = tracks; for (Track track : tracks) { sampleEntries.addAll(track.getSampleEntries()); } for (Track track : tracks) { //System.err.println("Track " + track + " is about to be appended"); lists.addAll(track.getSamples()); } int numSamples = 0; for (Track track : tracks) { numSamples += track.getSampleDurations().length; } decodingTimes = new long[numSamples]; int index = 0; // should use system arraycopy but this works too (yes it's slow ...) for (Track track : tracks) { long[] durs = track.getSampleDurations(); System.arraycopy(durs, 0, decodingTimes, index, durs.length); index += durs.length; } }
public static void main(String[] args) throws IOException { String f = Avc1ToAvc3Example.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/1365070268951.mp4"; Movie m = MovieCreator.build(new FileInputStream(f).getChannel(), new FileRandomAccessSourceImpl(new RandomAccessFile(f, "r")), "inmem"); Movie m2 = new Movie(); for (Track track : m.getTracks()) { if (track.getSampleEntries().get(0).getType().equals("avc1")) { m2.addTrack(new Avc1ToAvc3TrackImpl(track)); } else { m2.addTrack(track); } } new FragmentedMp4Builder().build(m2).writeContainer(new FileOutputStream("output.mp4").getChannel()); IsoFile i = new IsoFile("output.mp4"); for (Box box : i.getBoxes()) { System.err.println(box + "@-nooffsets"); } } }
String type = t.getSampleEntries().get(0).getType(); System.out.println("Track of type " + type ); if (t.getSampleEntries().get(0) instanceof VisualSampleEntry) { HashMap<Integer, Integer> previous = (HashMap<Integer, Integer>) common.clone(); common.clear();
public Avc1ToAvc3TrackImpl(Track parent) throws IOException { super(parent); for (SampleEntry sampleEntry : parent.getSampleEntries()) { if (sampleEntry.getType().equals("avc1")) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { // This creates a copy cause I can't change the original instance sampleEntry.getBox(Channels.newChannel(baos)); VisualSampleEntry avc3SampleEntry = (VisualSampleEntry) new IsoFile(new ByteBufferByteChannel(ByteBuffer.wrap(baos.toByteArray()))).getBoxes().get(0); avc3SampleEntry.setType("avc3"); avc1toavc3.put(sampleEntry, avc3SampleEntry); } catch (IOException e) { throw new RuntimeException("Dumping sample entry to memory failed"); } } else { avc1toavc3.put(sampleEntry, sampleEntry); } } samples = new ReplaceSyncSamplesList(parent.getSamples()); }
protected void createStsc(Track track, Map<Track, int[]> chunks, SampleTableBox stbl) { int[] tracksChunkSizes = chunks.get(track); SampleToChunkBox stsc = new SampleToChunkBox(); stsc.setEntries(new LinkedList<SampleToChunkBox.Entry>()); long lastChunkSize = Integer.MIN_VALUE; // to be sure the first chunks hasn't got the same size long lastSampleDescriptionIndex = Integer.MIN_VALUE; List<Sample> samples = track.getSamples(); int currentSampleIndex = 0; List<SampleEntry> sampleEntries = track.getSampleEntries(); for (int i = 0; i < tracksChunkSizes.length; i++) { Sample sample = samples.get(currentSampleIndex); int currentSampleDescriptionIndex = sampleEntries.indexOf(sample.getSampleEntry()) + 1; // one base if (lastChunkSize != tracksChunkSizes[i] || lastSampleDescriptionIndex != currentSampleDescriptionIndex) { stsc.getEntries().add(new SampleToChunkBox.Entry(i + 1, tracksChunkSizes[i], currentSampleDescriptionIndex)); lastChunkSize = tracksChunkSizes[i]; lastSampleDescriptionIndex = currentSampleDescriptionIndex; } currentSampleIndex += tracksChunkSizes[i]; } stbl.addBox(stsc); }
for (SampleEntry sampleEntry : source.getSampleEntries()) {
protected void createTfhd(long startSample, long endSample, Track track, int sequenceNumber, TrackFragmentBox parent) { TrackFragmentHeaderBox tfhd = new TrackFragmentHeaderBox(); SampleFlags sf = new SampleFlags(); tfhd.setDefaultSampleFlags(sf); tfhd.setBaseDataOffset(-1); tfhd.setSampleDescriptionIndex(track.getSampleEntries().indexOf(track.getSamples().get(l2i(startSample)).getSampleEntry()) + 1); tfhd.setTrackId(track.getTrackMetaData().getTrackId()); tfhd.setDefaultBaseIsMoof(true); parent.addBox(tfhd); }
if (getFormat(track).equals(getFormat(testTrack))) { AudioSampleEntry ase = null; for (SampleEntry sampleEntry : testTrack.getSampleEntries()) { if (ase == null) { ase = (AudioSampleEntry) sampleEntry; for (SampleEntry sampleEntry : track.getSampleEntries()) { if (ase == null) { ase = (AudioSampleEntry) sampleEntry;
protected void createStsd(Track track, SampleTableBox stbl) { SampleDescriptionBox stsd = new SampleDescriptionBox(); stsd.setBoxes(track.getSampleEntries()); stbl.addBox(stsd); }