本文整理匯總了Java中org.mp4parser.Container.writeContainer方法的典型用法代碼示例。如果您正苦於以下問題:Java Container.writeContainer方法的具體用法?Java Container.writeContainer怎麽用?Java Container.writeContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mp4parser.Container
的用法示例。
在下文中一共展示了Container.writeContainer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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.");
}
示例2: 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()));
}
示例3: 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]");
}
示例4: 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();
}
示例5: 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());
}
示例6: 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();
}
示例7: 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();
}
}
示例8: main
import org.mp4parser.Container; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
Movie m = MovieCreator.build("c:\\content\\ffmpeg.mp4");
DefaultMp4Builder defaultMp4Builder = new DefaultMp4Builder();
Container c = defaultMp4Builder.build(m);
FileOutputStream fos = new FileOutputStream("C:\\content\\out.mp4");
WritableByteChannel wbc = Channels.newChannel(fos);
c.writeContainer(wbc);
}
示例9: main
import org.mp4parser.Container; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
Track track = new H265TrackImpl(new FileDataSourceImpl("c:\\content\\test-UHD-HEVC_01_FMV_Med_track1.hvc"));
Movie movie = new Movie();
movie.addTrack(track);
DefaultMp4Builder mp4Builder = new DefaultMp4Builder();
Container c = mp4Builder.build(movie);
c.writeContainer(new FileOutputStream("output.mp4").getChannel());
}
示例10: main
import org.mp4parser.Container; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl("C:\\dev\\mp4parser\\streaming\\src\\test\\resources\\org\\mp4parser\\streaming\\input\\h264\\tos.h264"));
Movie m = new Movie();
m.addTrack(h264Track);
DefaultMp4Builder builder = new DefaultMp4Builder();
Container c = builder.build(m);
c.writeContainer(new FileOutputStream("output-old.mp4").getChannel());
}
示例11: main
import org.mp4parser.Container; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, XPathExpressionException, SAXException, ParserConfigurationException, URISyntaxException {
Movie v = new Movie(); // = MovieCreator.build("C:\\dev\\DRMTODAY-872\\31245689abb7c52a3d0721447bddd6cd_Tears_Of_Steel_600000.mp4");
Track audio = new H264TrackImpl(new FileDataSourceImpl("C:\\Users\\sannies\\Downloads\\test.h264"));
v.addTrack(audio);
Mp4Builder defaultMp4Builder = new DefaultMp4Builder();
Container c = defaultMp4Builder.build(v);
c.writeContainer(new FileOutputStream("output.mp4").getChannel());
}
示例12: main
import org.mp4parser.Container; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
String videoFile = MuxVideoWithAmf0.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/example-sans-amf0.mp4";
Movie video = MovieCreator.build(videoFile);
Properties props = new Properties();
props.load(MuxVideoWithAmf0.class.getResourceAsStream("/amf0track.properties"));
HashMap<Long, byte[]> samples = new HashMap<Long, byte[]>();
for (String key : props.stringPropertyNames()) {
samples.put(Long.parseLong(key), Base64.decodeBase64(props.getProperty(key)));
}
Track amf0Track = new Amf0Track(samples);
amf0Track.getTrackMetaData();
video.addTrack(amf0Track);
FragmentedMp4Builder fragmentedMp4Builder = new FragmentedMp4Builder();
fragmentedMp4Builder.setFragmenter(new DefaultFragmenterImpl(2));
Container out = fragmentedMp4Builder.build(video);
FileOutputStream fos = new FileOutputStream(new File(String.format("output.mp4")));
FileChannel fc = fos.getChannel();
out.writeContainer(fc);
fos.close();
}
示例13: 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 AppendTrack(new ClippedTrack(audio, 0, 10), new ClippedTrack(audio, 100, audio.getSamples().size())));
Container out = new DefaultMp4Builder().build(nuMovie);
FileOutputStream fos = new FileOutputStream(new File("output.mp4"));
out.writeContainer(fos.getChannel());
fos.close();
}
示例14: main
import org.mp4parser.Container; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
Movie mWithVideo = MovieCreator.build("C:\\dev\\mp4parser\\examples\\src\\main\\resources\\davidappend\\v1.mp4");
Movie mWOutVideo = new Movie();
for (Track track : mWithVideo.getTracks()) {
if (track.getHandler().equals("soun")) {
mWOutVideo.addTrack(track);
}
}
DefaultMp4Builder b = new DefaultMp4Builder();
Container c = b.build(mWOutVideo);
c.writeContainer(new FileOutputStream("output.mp4").getChannel());
}
示例15: main
import org.mp4parser.Container; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
List<Movie> movies = new LinkedList<Movie>();
movies.add(MovieCreator.build(DavidAppend.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/davidappend/v1.mp4"));
movies.add(MovieCreator.build(DavidAppend.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/davidappend/v2.mp4"));
movies.add(MovieCreator.build(DavidAppend.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/davidappend/v2.mp4"));
List<Track> videoTracks = new LinkedList<Track>();
List<Track> audioTracks = new LinkedList<Track>();
for (Movie m : movies) {
for (Track track : m.getTracks()) {
if (track.getHandler().equals("vide")) {
videoTracks.add(track);
}
if (track.getHandler().equals("soun")) {
audioTracks.add(track);
}
}
}
Movie concatMovie = new Movie();
concatMovie.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));
concatMovie.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
Container out2 = new DefaultMp4Builder().build(concatMovie);
FileChannel fc = new RandomAccessFile(String.format("output.mp4"), "rw").getChannel();
fc.position(0);
out2.writeContainer(fc);
fc.close();
}