args = Gst.init(name, args);
if (args.length < 1) {
System.err.println("Usage: " + name + " <filename>");
System.exit(1);
}
Element src = null;
if (true) try {
final FileInputStream srcFile = new FileInputStream(args[0]);
// src = new InputStreamSrc(new BufferedInputStream(srcFile), "input file");
src = new InputStreamSrc(srcFile, "input file");
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
/*else if (true) {
try {
final RandomAccessFile f = new RandomAccessFile(args[0], "r");
// src = new InputStreamSrc(new BufferedInputStream(srcFile), "input file");
src = new ReadableByteChannelSrc(f.getChannel(), "input_file");
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
} else if (true) {
src = ElementFactory.make("filesrc", "Input File");
src.set("location", args[0]);
}*/
DecodeBin2 decodeBin = (DecodeBin2) ElementFactory.make("decodebin2", "Decode Bin");
Pipeline pipe = new Pipeline("main pipeline");
pipe.addMany(src, decodeBin);
src.link(decodeBin);
/* create audio output */
final Bin audioBin = new Bin("Audio Bin");
Element conv = ElementFactory.make("audioconvert", "Audio Convert");
Element sink = ElementFactory.make("autoaudiosink", "sink");
audioBin.addMany(conv, sink);
Element.linkMany(conv, sink);
audioBin.addPad(new GhostPad("sink", conv.getStaticPad("sink")));
pipe.add(audioBin);