本文整理汇总了Java中com.xuggle.xuggler.IContainerFormat类的典型用法代码示例。如果您正苦于以下问题:Java IContainerFormat类的具体用法?Java IContainerFormat怎么用?Java IContainerFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IContainerFormat类属于com.xuggle.xuggler包,在下文中一共展示了IContainerFormat类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canRead
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
public synchronized static boolean canRead(String mimeType) {
if(TYPES == null) {
TYPES = new HashSet<>();
if(USE_JCODEC) {
TYPES.add(MIME.MT_MOV);
TYPES.add(MIME.MT_MP4);
TYPES.add(MIME.MT_GIF);
} else {
String[][] types = MIME.getMimeTypes();
for(IContainerFormat fmt : IContainerFormat.getInstalledInputFormats()) {
for(String type : TextUtilities.split(fmt.getInputFormatShortName(), ','))
TYPES.add(type(type, types));
}
TYPES.add(MIME.MT_MOV);
TYPES.add(MIME.MT_GIF);
}
}
return TYPES.contains(mimeType);
}
示例2: setContainerFormat
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
/**
* Not working yet.
*
* @param b
* @param off
* @param len
* @throws IOException
*/
@Override
public void setContainerFormat(byte[] b, long off, long len)
throws IOException {
ByteArrayInputStream bis = new ByteArrayInputStream(b);
ObjectInputStream ois = null;
ois = new ObjectInputStream(bis);
try {
containerFormat = (IContainerFormat) ois.readObject();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: getSupportedCodecs
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
/**
* Given the short name of a container, prints out information about
* it, including which codecs Xuggler can write (mux) into that container.
*
* @param name the short name of the format (e.g. "flv")
*/
public static void getSupportedCodecs(String name) {
IContainerFormat format = IContainerFormat.make();
format.setOutputFormat(name, null, null);
List<ID> codecs = format.getOutputCodecsSupported();
if (codecs.isEmpty())
System.out.println("no supported codecs for "+name); //$NON-NLS-1$
else {
System.out.println(name+" ("+format+") supports following codecs:"); //$NON-NLS-1$ //$NON-NLS-2$
for(ID id : codecs) {
if (id != null) {
ICodec codec = ICodec.findEncodingCodec(id);
if (codec != null) {
System.out.println(codec);
}
}
}
}
}
示例4: setup
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
public void setup(final SegmentFacade facade, ISimpleMediaFile outputStreamInfo) {
log.debug("setup {}", outputUrl);
this.outputStreamInfo = outputStreamInfo;
this.facade = facade;
// output to a custom handler
outputStreamInfo.setURL(outputUrl);
// setup our mpeg-ts io handler
MpegTsIoHandler outputHandler = new MpegTsIoHandler(outputUrl, facade);
MpegTsHandlerFactory.getFactory().registerStream(outputHandler, outputStreamInfo);
// create a container
container = IContainer.make();
log.trace("Container buffer length: {}", container.getInputBufferLength());
// create format
containerFormat = IContainerFormat.make();
containerFormat.setOutputFormat("mpegts", outputUrl, null);
}
示例5: setEncodingParameters
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
/**
* A quick hack. Encoding paramaters are hard-coded here.
*
* @throws IOException
*/
@Override
public void setEncodingParameters() throws IOException {
containerFormat = IContainerFormat.make();
containerFormat.setOutputFormat("avi", null, null);
// ObjectOutputStream oos = new ObjectOutputStream();
// oos.writeObject(containerFormat);
streamCoders = new IStreamCoder[] { IStreamCoder
.make(IStreamCoder.Direction.ENCODING) };
ICodec codec = ICodec.guessEncodingCodec(containerFormat, null, null,
null, ICodec.Type.CODEC_TYPE_VIDEO);
streamCoders[0].setNumPicturesInGroupOfPictures(1);
streamCoders[0].setCodec(codec);
streamCoders[0].setBitRate(25000);
streamCoders[0].setBitRateTolerance(9000);
streamCoders[0].setPixelType(IPixelFormat.Type.YUV420P);
streamCoders[0].setWidth(352);
streamCoders[0].setHeight(288);
streamCoders[0].setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
streamCoders[0].setGlobalQuality(0);
IRational frameRate = IRational.make(25, 1);
streamCoders[0].setFrameRate(frameRate);
streamCoders[0].setTimeBase(IRational.make(frameRate.getDenominator(),
frameRate.getNumerator()));
}
示例6: getSupportedContainerFormats
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
@Override
public List<MediaContainerFormat> getSupportedContainerFormats() {
List<MediaContainerFormat> out = new ArrayList<MediaContainerFormat>();
Collection<IContainerFormat> formats = IContainerFormat.getInstalledInputFormats();
for (IContainerFormat format : formats) {
out.add(new MediaContainerFormat(format.getInputFormatShortName(), format.getInputFormatLongName()));
}
return out;
}
示例7: saveScratch
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
/**
* Saves the video to the current scratchFile.
*
* @throws IOException
*/
@Override
protected void saveScratch() throws IOException {
FileFilter fileFilter = videoType.getDefaultFileFilter();
if (!hasContent || !(fileFilter instanceof VideoFileFilter))
return;
// set container format
IContainerFormat format = IContainerFormat.make();
VideoFileFilter xuggleFilter = (VideoFileFilter)fileFilter;
format.setOutputFormat(xuggleFilter.getContainerType(), null, null);
// set the pixel type--may depend on selected fileFilter?
IPixelFormat.Type pixelType = IPixelFormat.Type.YUV420P;
// open the output stream, write the images, close the stream
openStream(format, pixelType);
// open temp images and encode
long timeStamp = 0;
int n=0;
synchronized (tempFiles) {
for (File imageFile: tempFiles) {
if (!imageFile.exists())
throw new IOException("temp image file not found"); //$NON-NLS-1$
BufferedImage image = ResourceLoader.getBufferedImage(imageFile.getAbsolutePath(), BufferedImage.TYPE_3BYTE_BGR);
if (image==null || image.getType()!=BufferedImage.TYPE_3BYTE_BGR) {
throw new IOException("unable to load temp image file"); //$NON-NLS-1$
}
encodeImage(image, pixelType, timeStamp);
n++;
timeStamp = Math.round(n*frameDuration*1000); // frameDuration in ms, timestamp in microsec
}
}
closeStream();
deleteTempFiles();
hasContent = false;
canRecord = false;
}
示例8: getContainerFormat
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
public IContainerFormat getContainerFormat() {
// TODO Auto-generated method stub
return containerFormat;
}
示例9: openStream
import com.xuggle.xuggler.IContainerFormat; //导入依赖的package包/类
/**
* Opens/initializes the output stream using a specified Xuggle format.
*
* @param format the format
* @param pixelType the pixel type
* @throws IOException
*/
private boolean openStream(IContainerFormat format, IPixelFormat.Type pixelType)
throws IOException {
outContainer = IContainer.make();
if (outContainer.open(scratchFile.getAbsolutePath(), IContainer.Type.WRITE, format)<0) {
OSPLog.finer("Xuggle could not open output file"); //$NON-NLS-1$
return false;
}
String typicalName = "typical."+videoType.getDefaultExtension(); //$NON-NLS-1$
ICodec codec = ICodec.guessEncodingCodec(format, null, typicalName, null, ICodec.Type.CODEC_TYPE_VIDEO);
outStream = outContainer.addNewStream(0);
outStreamCoder = outStream.getStreamCoder();
outStreamCoder.setNumPicturesInGroupOfPictures(10);
outStreamCoder.setCodec(codec);
outStreamCoder.setBitRate(250000);
// outStreamCoder.setBitRateTolerance(9000);
outStreamCoder.setPixelType(pixelType);
if(dim==null && frameImage!=null) {
dim = new Dimension(frameImage.getWidth(null), frameImage.getHeight(null));
}
if(dim!=null) {
outStreamCoder.setHeight(dim.height);
outStreamCoder.setWidth(dim.width);
}
// outStreamCoder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
// outStreamCoder.setGlobalQuality(0);
IRational frameRate = IRational.make(1000/frameDuration);
boolean hasTimeBaseLimit = typicalName.endsWith(".avi") || typicalName.endsWith(".mpg"); //$NON-NLS-1$ //$NON-NLS-2$
if (hasTimeBaseLimit && frameRate.getDenominator()>65535) { // maximum timebase = 2^16 - 1
double fps = 1000/frameDuration;
int denom = 63000; // 7 x 9000
int numer = Math.round(Math.round(fps*denom));
frameRate = IRational.make(numer, denom);
}
outStreamCoder.setFrameRate(frameRate);
// set time base to inverse of frame rate
outStreamCoder.setTimeBase(IRational.make(frameRate.getDenominator(),
frameRate.getNumerator()));
// // some codecs require experimental mode to be set? (and all accept it??)
// if (outStreamCoder.setStandardsCompliance(IStreamCoder.CodecStandardsCompliance.COMPLIANCE_EXPERIMENTAL) < 0) {
// OSPLog.finer("Xuggle could not set compliance mode to experimental"); //$NON-NLS-1$
// return false;
// }
if (outStreamCoder.open()<0) {
OSPLog.finer("Xuggle could not open stream encoder"); //$NON-NLS-1$
return false;
}
if (outContainer.writeHeader()<0) {
OSPLog.finer("Xuggle could not write file header"); //$NON-NLS-1$
return false;
}
return true;
}