本文整理匯總了Java中org.mp4parser.Container類的典型用法代碼示例。如果您正苦於以下問題:Java Container類的具體用法?Java Container怎麽用?Java Container使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Container類屬於org.mp4parser包,在下文中一共展示了Container類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFormat
import org.mp4parser.Container; //導入依賴的package包/類
public static String getFormat(Track track) {
List<SampleEntry> ses = track.getSampleEntries();
String format = null;
for (SampleEntry se : ses) {
OriginalFormatBox frma = Path.getPath((Container) se, "sinf/frma");
if (frma != null) {
if (format == null || format.equals(frma.getDataFormat())) {
format = frma.getDataFormat();
} else {
throw new RuntimeException("cant determine format of track");
}
} else {
if (format == null || format.equals(se.getType())) {
format = se.getType();
} else {
throw new RuntimeException("cant determine format of track");
}
}
}
return format;
}
示例2: writeMp4
import org.mp4parser.Container; //導入依賴的package包/類
private void writeMp4(List<Track> tracks) throws IOException {
Movie m = new Movie();
m.setTracks(tracks);
Mp4Builder mp4Builder = getFileBuilder(m);
Container isoFile = mp4Builder.build(m);
System.out.print("Writing t ");
WritableByteChannel wbc = new FileOutputStream(outputFile).getChannel();
try {
isoFile.writeContainer(wbc);
} finally {
wbc.close();
}
System.out.println("Done.");
}
示例3: check
import org.mp4parser.Container; //導入依賴的package包/類
public static void check(Container root1, Box b1, Container root2, Box b2, String... ignores) throws IOException {
//System.err.println(b1.getType() + " - " + b2.getType());
Assert.assertEquals(b1.getType(), b2.getType());
if (!isIgnore(root1, b1, ignores)) {
// System.err.println(b1.getType());
Assert.assertEquals("Type differs. \ntypetrace ref : " + b1 + "\ntypetrace new : " + b2,
b1.getType(), b2.getType());
if (b1 instanceof Container ^ !(b2 instanceof Container)) {
if (b1 instanceof Container) {
check(root1, (Container) b1, root2, (Container) b2, ignores);
} else {
checkBox(root1, b1, root2, b2, ignores);
}
} else {
Assert.fail("Either both boxes are container boxes or none");
}
}
}
示例4: find
import org.mp4parser.Container; //導入依賴的package包/類
public static long find(Container container, ParsableBox target, long offset) {
long nuOffset = offset;
for (Box lightBox : container.getBoxes()) {
if (lightBox == target) {
return nuOffset;
}
if (lightBox instanceof Container) {
long r = find((Container) lightBox, target, 0);
if (r > 0) {
return r + nuOffset;
} else {
nuOffset += lightBox.getSize();
}
} else {
nuOffset += lightBox.getSize();
}
}
return -1;
}
示例5: FragmentedMp4SampleList
import org.mp4parser.Container; //導入依賴的package包/類
public FragmentedMp4SampleList(long track, Container isofile, RandomAccessSource randomAccess) {
this.isofile = isofile;
this.randomAccess = randomAccess;
List<TrackBox> tbs = Path.getPaths(isofile, "moov[0]/trak");
for (TrackBox tb : tbs) {
if (tb.getTrackHeaderBox().getTrackId() == track) {
trackBox = tb;
}
}
if (trackBox == null) {
throw new RuntimeException("This MP4 does not contain track " + track);
}
List<TrackExtendsBox> trexs = Path.getPaths(isofile, "moov[0]/mvex[0]/trex");
for (TrackExtendsBox box : trexs) {
if (box.getTrackId() == trackBox.getTrackHeaderBox().getTrackId()) {
trex = box;
}
}
sampleEntries = new ArrayList<>(trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes(SampleEntry.class));
if (sampleEntries.size() != trackBox.getSampleTableBox().getSampleDescriptionBox().getBoxes().size())
throw new AssertionError("stsd contains not only sample entries. Something's wrong here! Bailing out");
sampleCache = (SoftReference<Sample>[]) Array.newInstance(SoftReference.class, size());
initAllFragments();
}
示例6: getFormat
import org.mp4parser.Container; //導入依賴的package包/類
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;
}
示例7: testSimpleMuxing
import org.mp4parser.Container; //導入依賴的package包/類
@Test
public void testSimpleMuxing() throws Exception {
Movie m = new Movie();
Movie v = MovieCreator.build(FragmentedMp4BuilderTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/BBB_qpfile_10sec/BBB_fixedres_B_180x320_80.mp4");
Movie a = MovieCreator.build(FragmentedMp4BuilderTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/BBB_qpfile_10sec/output_audio-2ch-20s.mp4");
m.addTrack(v.getTracks().get(0));
m.addTrack(a.getTracks().get(0));
FragmentedMp4Builder fragmentedMp4Builder = new FragmentedMp4Builder();
fragmentedMp4Builder.setFragmenter(new DefaultFragmenterImpl(5));
Container c = fragmentedMp4Builder.build(m);
c.writeContainer(Channels.newChannel(new ByteArrayOutputStream()));
}
示例8: freeze
import org.mp4parser.Container; //導入依賴的package包/類
@Test
public void freeze() throws IOException {
DataSource fc = new FileDataSourceImpl(getClass().getProtectionDomain().getCodeSource().getLocation().getFile() + "/org/mp4parser/muxer/tracks/h264-sample.h264");
H264TrackImpl.BUFFER = 65535; // make sure we are not just in one buffer
Track t = new H264TrackImpl(fc);
Movie m = new Movie();
m.addTrack(t);
DefaultMp4Builder mp4Builder = new DefaultMp4Builder();
Container c = mp4Builder.build(m);
// c.writeContainer(new FileOutputStream("C:\\dev\\mp4parser\\muxer\\src\\test\\resources\\org\\mp4parser\\muxer\\tracks\\h264-sample.mp4").getChannel());
IsoFile isoFileReference = new IsoFile(getClass().getProtectionDomain().getCodeSource().getLocation().getFile() + "org/mp4parser/muxer/tracks/h264-sample.mp4");
BoxComparator.check(c, isoFileReference, "moov[0]/mvhd[0]", "moov[0]/trak[0]/tkhd[0]", "moov[0]/trak[0]/mdia[0]/mdhd[0]", "moov[0]/trak[0]/mdia[0]/minf[0]/stbl[0]/stco[0]");
}
示例9: checkOutputIsStable
import org.mp4parser.Container; //導入依賴的package包/類
@Test
public void checkOutputIsStable() throws Exception {
Movie m = new Movie();
DTSTrackImpl dts = new DTSTrackImpl(new FileDataSourceImpl(DTSTrackImplTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/org/mp4parser/muxer/tracks/dts-sample.dtshd"));
m.addTrack(dts);
Fragmenter fif = new StaticFragmentIntersectionFinderImpl(Collections.singletonMap((Track) dts, new long[]{1}));
DefaultMp4Builder mp4Builder = new DefaultMp4Builder();
mp4Builder.setFragmenter(fif);
Container c = mp4Builder.build(m);
// c.writeContainer(new FileOutputStream("C:\\dev\\mp4parser\\isoparser\\src\\test\\resources\\com\\googlecode\\mp4parser\\authoring\\tracks\\dts-sample.mp4").getChannel());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
c.writeContainer(Channels.newChannel(baos));
IsoFile ref = new IsoFile(
new FileInputStream(DTSTrackImplTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/org/mp4parser/muxer/tracks/dts-sample.mp4").getChannel());
BoxComparator.check(ref, c, "moov[0]/mvhd[0]", "moov[0]/trak[0]/tkhd[0]", "moov[0]/trak[0]/mdia[0]/mdhd[0]");
}
示例10: main
import org.mp4parser.Container; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
String audioEnglish = RemoveSomeSamplesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-english-audio.mp4";
Movie originalMovie = MovieCreator.build(audioEnglish);
Track audio = originalMovie.getTracks().get(0);
Movie nuMovie = new Movie();
nuMovie.addTrack(new ReplaceSampleTrack(
new ReplaceSampleTrack(
new ReplaceSampleTrack(
audio,
25, ByteBuffer.allocate(5)),
27, ByteBuffer.allocate(5)),
29, ByteBuffer.allocate(5)));
Container out = new DefaultMp4Builder().build(nuMovie);
FileOutputStream fos = new FileOutputStream(new File("output.mp4"));
FileChannel fc = fos.getChannel();
out.writeContainer(fc);
fos.close();
}
示例11: dumpBoxes
import org.mp4parser.Container; //導入依賴的package包/類
private static void dumpBoxes(Container container, int indent) {
String meInd = getIndentation(indent);
String subInd = getIndentation(indent + 2);
System.out.println(meInd + container.getClass().getName());
for (Box box : container.getBoxes()) {
if (box instanceof Container) {
dumpBoxes((Container) box, indent + 2);
} else {
try {
if (box instanceof UnknownBox) {
System.out.println(subInd + box.getClass().getName() + "[" + box.getSize() + "/" + box.getType() + "]:" + box.toString());
} else if (box instanceof Utf8AppleDataBox) {
System.out.println(subInd + box.getClass().getName() + ": " + box.getType() + ": " + box.toString() + ": " + ((Utf8AppleDataBox) box).getValue());
} else {
System.out.println(subInd + box.getClass().getName() + ": " + box.getType() + "[" + box.getSize() + "]: " + box.toString());
}
} catch (Exception e) {
System.err.println("Error parsing " + box.getClass().getSimpleName() + " box: " + e);
e.printStackTrace(System.err);
}
}
}
}
示例12: main
import org.mp4parser.Container; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
String basePath = GetDuration.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/dash/";
Movie m = new Movie();
IsoFile baseIsoFile = new IsoFile(basePath + "redbull_100kbit_dash.mp4");
List<IsoFile> fragments = new LinkedList<IsoFile>();
for (int i = 1; i < 9; i++) {
fragments.add(new IsoFile(basePath + "redbull_10sec" + i + ".m4s"));
}
m.addTrack(new Mp4TrackImpl(1, new IsoFile("redbull_100kbit_dash.mp4"), new FileRandomAccessSourceImpl(new RandomAccessFile("redbull_100kbit_dash.mp4", "r")), "test"));
DefaultMp4Builder builder = new DefaultMp4Builder();
Container stdMp4 = builder.build(m);
FileOutputStream fos = new FileOutputStream("out.mp4");
stdMp4.writeContainer(fos.getChannel());
fos.close();
}
示例13: main
import org.mp4parser.Container; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
Movie movieIn = MovieCreator.build(GetDuration.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/1365070268951.mp4");
Movie movieOut = new Movie();
for (Track track : movieIn.getTracks()) {
if ("vide".equals(track.getHandler())) {
movieOut.addTrack(new WrappingTrack(track) {
@Override
public long[] getSampleDurations() {
long[] l = super.getSampleDurations();
l[0] *= 10;
l[l.length-1] *= 10;
return l;
}
});
} else {
movieOut.addTrack(track);
}
}
DefaultMp4Builder defaultMp4Builder = new DefaultMp4Builder();
Container mOut = defaultMp4Builder.build(movieOut);
mOut.writeContainer(new FileOutputStream("default.mp4").getChannel());
}
示例14: main
import org.mp4parser.Container; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
DataSource video_file = new FileDataSourceImpl("c:/dev/mp4parser2/source_video.h264");
DataSource audio_file = new FileDataSourceImpl("c:/dev/mp4parser2/source_audio.aac");
int duration = 30472;
H264TrackImpl h264Track = new H264TrackImpl(video_file, "eng", 15000, 1001); //supplied duration for the attached file was
AACTrackImpl aacTrack = new AACTrackImpl(audio_file);
Movie movie = new Movie();
movie.addTrack(h264Track);
//movie.addTrack(aacTrack);
Container out = new DefaultMp4Builder().build(movie);
FileOutputStream fos = new FileOutputStream(new File("c:/dev/mp4parser2/checkme.mp4"));
out.writeContainer(fos.getChannel());
fos.close();
}
示例15: main
import org.mp4parser.Container; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("C:\\dev\\mp4parser\\isoparser\\src\\test\\resources\\count.h264"));
//AACTrackImpl aacTrack = new AACTrackImpl(new FileInputStream("/home/sannies2/Downloads/lv.aac").getChannel());
Movie m = new Movie();
m.addTrack(h264Track);
//m.addTrack(aacTrack);
{
Container out = new DefaultMp4Builder().build(m);
FileOutputStream fos = new FileOutputStream(new File("h264_output.mp4"));
FileChannel fc = fos.getChannel();
out.writeContainer(fc);
fos.close();
}
}