Java Code Examples for org.mp4parser.IsoFile#getBox()

The following examples show how to use org.mp4parser.IsoFile#getBox() . 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: MetaBoxTest.java    From mp4parser with Apache License 2.0 5 votes vote down vote up
@Test
public void testRooundTrip() throws IOException {
    File f = File.createTempFile("MetaBoxTest", "");
    f.deleteOnExit();
    FileOutputStream fos = new FileOutputStream(f);
    fos.write(metaBox);
    fos.close();
    IsoFile isoFile = new IsoFile(new FileInputStream(f).getChannel());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    isoFile.getBox(Channels.newChannel(baos));
    Assert.assertArrayEquals(metaBox, baos.toByteArray());
}
 
Example 2
Source File: WeirdISMVTest.java    From mp4parser with Apache License 2.0 5 votes vote down vote up
@Test
public void checkMikesStream() throws IOException {
    String hex = "000002346d6f6f760000006c6d76686400000000ceec8b72ceec8b7200989680000000000001000001000000000000000000000000010000000000000000000000000000000100000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002000001987472616b0000005c746b686400000007ceec8b72ceec8b72000000010000000000000000000000000000000000000000010000000001000000000000000000000000000000010000000000000000000000000000400000000000000000000000000001346d646961000000206d64686400000000ceec8b72ceec8b720098968000000000000000000000003468646c720000000000000000736f756e000000000000000000000000536f756e64204d656469612048616e646c657200000000d86d696e6600000010736d686400000000000000000000002464696e660000001c6472656600000000000000010000000c75726c20000000010000009c7374626c00000050737473640000000000000001000000406f776d61000000000000000100000000000000000002000000000000bb8000006101020080bb0000c31e0000f00310000a00008800001f00000000000000001073747473000000000000000000000010737473630000000000000000000000147374737a000000000000000000000000000000107374636f0000000000000000000000286d7665780000002074726578000000000000000100000001000000000000000000000000";
    byte[] data = Hex.decodeHex(hex);
    IsoFile isoFile = new IsoFile(new ByteBufferByteChannel(data));
    AudioSampleEntry owma = Path.getPath(isoFile, "moov[0]/trak[0]/mdia[0]/minf[0]/stbl[0]/stsd[0]/owma");
    System.err.println(owma);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    isoFile.getBox(Channels.newChannel(baos));
    Assert.assertArrayEquals(data, baos.toByteArray());
    // List<Box> b = ((Container)isoFile.getMovieBox().getBoxes().get(1)).getBoxes().get(1).getBoxes().get(2).getBoxes().get(2).getBoxes().get(0).getBoxes();

}
 
Example 3
Source File: RoundTripTest.java    From mp4parser with Apache License 2.0 3 votes vote down vote up
public void testRoundTrip_1(String originalFile) throws Exception {

        long start1 = System.currentTimeMillis();
        long start2 = System.currentTimeMillis();

        IsoFile isoFile = new IsoFile(new FileInputStream(originalFile).getChannel());

        long start3 = System.currentTimeMillis();


        long start4 = System.currentTimeMillis();
        Walk.through(isoFile);
        long start5 = System.currentTimeMillis();


        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        isoFile.getBox(Channels.newChannel(baos));


        long start6 = System.currentTimeMillis();

     /*   System.err.println("Preparing tmp copy took: " + (start2 - start1) + "ms");
        System.err.println("Parsing took           : " + (start3 - start2) + "ms");
        System.err.println("Writing took           : " + (start6 - start3) + "ms");
        System.err.println("Walking took           : " + (start5 - start4) + "ms");*/


        IsoFile copyViaIsoFileReparsed = new IsoFile(new ByteBufferByteChannel(baos.toByteArray()));
        BoxComparator.check(isoFile, copyViaIsoFileReparsed, "moov[0]/mvhd[0]", "moov[0]/trak[0]/tkhd[0]", "moov[0]/trak[0]/mdia[0]/mdhd[0]");
        isoFile.close();
        copyViaIsoFileReparsed.close();
        // as windows cannot delete file when something is memory mapped and the garbage collector
        // doesn't necessarily free the Buffers quickly enough we cannot delete the file here (we could but only for linux)


    }