Comments (2)
The print structure thingy might or might not work correctly. The trak box
should be on the same level as mvhd. Please check the isoviewer project to
check your mp4s!
Am 03.02.2015 04:45 schrieb "MattStillerman" [email protected]:
The class PrintStructure in package com.google.code.mp4parser.example
seems to have a bug.The program is supposed to print an indented list of the boxes in the
stream. For each box that is a container, it is supposed to parse the
contents, and print an indented list of boxes inside. You would expect that
the size of a container would correspond to the sum of the sizes of its
"top level" constituents, plus 8 bytes. Here is the beginning of the output
from the program, exhibiting the error:ftyp@0 size: 24
mdat@24 size: 6930099
moov@6930123 size: 3765
mvhd@13860262 size: 108
udta@13860370 size: 38
©xyz@20790625 size: 30
trak@20790655 size: 2164
tkhd@27720948 size: 92
mdia@27721040 size: 2064
mdhd@34651433 size: 32This output seems to indicate that the udta box of size 38 contains a ©xyz
box of size 30 and a trak box of size 2164 -- which is impossible.The error is that the print method, when applied to the contents of a box,
starts with a FileChannel that is positioned at the beginning of the box
data, and it runs to the end of the channel. It should stop when it
reaches the end of the box!—
Reply to this email directly or view it on GitHub
#47.
from mp4parser.
Thanks very much! I'll try out the isoviewer.
Here is a fixed version of the class, followed by its output. The trak box is now at the same level as mvhd.
Matt
package com.google.code.mp4parser.example;
import com.coremedia.iso.IsoTypeReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import com.googlecode.mp4parser.DataSource;
import java.nio.channels.FileChannel;
import java.util.Arrays;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* User: sannies
* Date: 8/5/11
* Time: 2:03 PM
* To change this template use File | Settings | File Templates.
*/
public class PrintStructureFixed {
public static void main(String[] args) throws IOException {
System.out.println("PWD: " + System.getProperty("user.dir"));
System.out.println("Input: " + args[0]);
FileInputStream fis = new FileInputStream(new File(args[0]));
System.out.println("input size: " + fis.getChannel().size());
PrintStructureFixed ps = new PrintStructureFixed();
ps.print(fis.getChannel(), 0, 0, 0);
}
/** Parses the FileChannel, in the range [start, end) and prints the elements found
*
* Elements are printed, indented by "level" number of spaces. If an element is
* a container, then its contents will be, recursively, printed, with a greater
* indentation.
*
* @param fc
* @param level
* @param start
* @param end
* @throws IOException
*/
private void print(FileChannel fc, int level, long start, long end) throws IOException {
fc.position(start);
if(end <= 0) {
end = start + fc.size();
System.out.println("Setting END to " + end);
}
while (end - fc.position() > 8) {
long begin = fc.position();
ByteBuffer bb = ByteBuffer.allocate(8);
fc.read(bb);
bb.rewind();
long size = IsoTypeReader.readUInt32(bb);
String type = IsoTypeReader.read4cc(bb);
long fin = begin + size;
// indent by the required number of spaces
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println(type + "@" + (begin) + " size: " + size);
if (containers.contains(type)) {
print(fc, level + 1, begin + 8, fin);
if(fc.position() != fin) {
System.out.println("End of container contents at " + fc.position());
System.out.println(" FIN = " + fin);
}
}
fc.position(fin);
}
}
List<String> containers = Arrays.asList(
"moov",
"trak",
"mdia",
"minf",
"udta",
"stbl"
);
}
Input: mp4parser-master/examples/src/main/resources/1365070453555.mp4
input size: 6933888
Setting END to 6933888
ftyp@0 size: 24
mdat@24 size: 6930099
moov@6930123 size: 3765
mvhd@6930131 size: 108
udta@6930239 size: 38
©xyz@6930247 size: 30
trak@6930277 size: 2164
tkhd@6930285 size: 92
mdia@6930377 size: 2064
mdhd@6930385 size: 32
hdlr@6930417 size: 44
minf@6930461 size: 1980
vmhd@6930469 size: 20
dinf@6930489 size: 36
stbl@6930525 size: 1916
stsd@6930533 size: 152
stts@6930685 size: 1064
stss@6931749 size: 36
stsz@6931785 size: 568
stsc@6932353 size: 52
stco@6932405 size: 36
trak@6932441 size: 1447
tkhd@6932449 size: 92
mdia@6932541 size: 1347
mdhd@6932549 size: 32
hdlr@6932581 size: 44
minf@6932625 size: 1263
smhd@6932633 size: 16
dinf@6932649 size: 36
stbl@6932685 size: 1203
stsd@6932693 size: 91
stts@6932784 size: 96
stsz@6932880 size: 920
stsc@6933800 size: 52
stco@6933852 size: 36
from mp4parser.
Related Issues (20)
- On the fly HOT 1
- Class Not Found Exception : org,mp4parser.boxes.iso.14496.part12.FileTypeBox.
- Java mp4parser to create a single .m4s fragment (without malformation)
- Write MP4 file from RTSP stream
- MovieCreator.build(file) NullPointerException
- mux bytebuffer audio and video
- VP9 support for mp4parser
- Will your library support OpenHarmony platform by JavaScript language ? HOT 1
- Cant Trim Videos
- How to release resources HOT 1
- java.lang.OutOfMemoryError: Direct buffer memory
- NullPointerException when trying on Android corrupt video file
- Latest Git Tag not pushed
- Can this be used to add timed metadata?
- Can you provide a guide on how to install?
- Why are so many tags updated on Apr 26, 2022?
- Android SDK mp4parser issue while implementation to other project because of dependency
- convert video in 3 seconds segments
- Adding HEIF Support
- Buffer size should be checked when parsing font name field of QuicktimeText block
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mp4parser.