当前位置: 首页>>代码示例>>Java>>正文


Java IStreamCoder.getCodecType方法代码示例

本文整理汇总了Java中com.xuggle.xuggler.IStreamCoder.getCodecType方法的典型用法代码示例。如果您正苦于以下问题:Java IStreamCoder.getCodecType方法的具体用法?Java IStreamCoder.getCodecType怎么用?Java IStreamCoder.getCodecType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.xuggle.xuggler.IStreamCoder的用法示例。


在下文中一共展示了IStreamCoder.getCodecType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMeanGOPLength

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
public static int getMeanGOPLength(IContainer container) throws CannotProceedException, IOException {
 int numStreams = container.getNumStreams();
 
 if( numStreams <= 0 )
     throw new IOException( "No streams found in container." );
 
 List<IIndexEntry> index_list = null;
 
 for( int j = 0; j < container.getNumStreams(); j++ ) {
     IStream stream = container.getStream(j);
     IStreamCoder coder = stream.getStreamCoder();
     if( coder.getCodecType() != ICodec.Type.CODEC_TYPE_VIDEO)
         continue;
     index_list = stream.getIndexEntries();
 }
 
 if( index_list == null || index_list.size() == 0)
     throw new CannotProceedException( "No index entries found!" );
 
 int k = 0;
 for( int i = 0; i < index_list.size(); i++ )
    if ( index_list.get(i).isKeyFrame() ) k++; 
 
    return index_list.size() / k;
}
 
开发者ID:openpreserve,项目名称:video-batch,代码行数:26,代码来源:XugglerAnalyzer.java

示例2: setResampler

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
private void setResampler(IStreamCoder videoCoder) {
    if (videoCoder.getCodecType() != ICodec.Type.CODEC_TYPE_VIDEO)
        return;

    resampler = null;
    if (videoCoder.getPixelType() != IPixelFormat.Type.BGR24) {
        // if this stream is not in BGR24, we're going to need to
        // convert it. The VideoResampler does that for us.
        resampler = IVideoResampler.make(videoCoder.getWidth(),
                videoCoder.getHeight(), IPixelFormat.Type.BGR24,
                videoCoder.getWidth(), videoCoder.getHeight(),
                videoCoder.getPixelType());
        if (resampler == null)
            throw new RuntimeException("could not create color space "
                    + "resampler for: " + videoCoder);
    }
}
 
开发者ID:openpreserve,项目名称:video-batch,代码行数:18,代码来源:XugglerInputStream.java

示例3: getAvgGOPLength

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
public long getAvgGOPLength(){
 
 List<IIndexEntry> index_list = null;

    IStream videostream = null;
 
 for( int j = 0; j < container.getNumStreams(); j++ ) {
     IStream stream = container.getStream(j);
     IStreamCoder coder = stream.getStreamCoder();
     if( coder.getCodecType() != ICodec.Type.CODEC_TYPE_VIDEO)
         continue;
     index_list = stream.getIndexEntries();
        videostream = stream;
 }
 
    // TODO: generalize MediaFramework interface to deal with audio too (where not videostream is contained)
 if( index_list == null || index_list.isEmpty() )
        return videostream.getNumFrames();
 
 int k = 0;
 for( int i = 0; i < index_list.size(); i++ )
    if ( index_list.get(i).isKeyFrame() ) k++; 
 
    return index_list.size() / k;
}
 
开发者ID:openpreserve,项目名称:video-batch,代码行数:26,代码来源:XugglerMediaFramework.java

示例4: onAddStream

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
@Override
 public void onAddStream(IAddStreamEvent event) {
	 int streamIndex = event.getStreamIndex();
	 IStreamCoder streamCoder = event.getSource().getContainer()
	 		.getStream(streamIndex).getStreamCoder();
	 if (streamCoder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
	 	//writer.addAudioStream(streamIndex, streamIndex, 1, 16000);
    		writer.addAudioStream(1, 0,ICodec.ID.CODEC_ID_PCM_S16LE, 1, 16000); 
	 }
	 super.onAddStream(event);
}
 
开发者ID:sumansaurabh,项目名称:AudioTranscoder,代码行数:12,代码来源:ConvertAudio.java

示例5: getMeanVideoFrameSize

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
/**
 * Calculates average frame size in bytes of the video stream of the given container.
 * @param container
 * @return
 * @throws IOException
 * @throws CannotProceedException
 */
public static int getMeanVideoFrameSize( IContainer container ) throws IOException, CannotProceedException {
    
 int numStreams = container.getNumStreams();
 
 if( numStreams <= 0 )
     throw new IOException( "No streams found in container." );
 
 List<IIndexEntry> index_list = null;
 
 for( int j = 0; j < container.getNumStreams(); j++ ) {
     IStream stream = container.getStream(j);
     IStreamCoder coder = stream.getStreamCoder();
     if( coder.getCodecType() != ICodec.Type.CODEC_TYPE_VIDEO)
         continue;
     index_list = stream.getIndexEntries();
 }
 
 if( index_list == null || index_list.size() == 0)
     throw new CannotProceedException( "No index entries found!" );
 
 BigInteger avg_size = new BigInteger("0");
 
 for( int i = 0; i < index_list.size(); i++ )
     avg_size = avg_size.add( new BigInteger( index_list.get(i).getSize() + "") );
 
 avg_size = avg_size.divide( new BigInteger( index_list.size() + "" ));
		
    return avg_size.intValue();
}
 
开发者ID:openpreserve,项目名称:video-batch,代码行数:37,代码来源:XugglerAnalyzer.java

示例6: printStreamInfo

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
private void printStreamInfo(IStream stream) {
    IStreamCoder coder = stream.getStreamCoder();
    IContainer container = stream.getContainer();
    String info = "";

    info += (String.format("type: %s; ", coder.getCodecType()));
    info += (String.format("codec: %s; ", coder.getCodecID()));
    info += String.format(
            "duration: %s; ",
            stream.getDuration() == Global.NO_PTS ? "unknown" : ""
                    + stream.getDuration());
    info += String.format("start time: %s; ",
            container.getStartTime() == Global.NO_PTS ? "unknown" : ""
                    + stream.getStartTime());
    info += String
            .format("language: %s; ",
                    stream.getLanguage() == null ? "unknown" : stream
                            .getLanguage());
    info += String.format("timebase: %d/%d; ", stream.getTimeBase()
            .getNumerator(), stream.getTimeBase().getDenominator());
    info += String.format("coder tb: %d/%d; ", coder.getTimeBase()
            .getNumerator(), coder.getTimeBase().getDenominator());

    if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
        info += String.format("sample rate: %d; ", coder.getSampleRate());
        info += String.format("channels: %d; ", coder.getChannels());
        info += String.format("format: %s", coder.getSampleFormat());
    } else if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
        info += String.format("width: %d; ", coder.getWidth());
        info += String.format("height: %d; ", coder.getHeight());
        info += String.format("format: %s; ", coder.getPixelType());
        info += String.format("frame-rate: %5.2f; ", coder.getFrameRate()
                .getDouble());
    }
    LOG.debug(info);
}
 
开发者ID:openpreserve,项目名称:video-batch,代码行数:37,代码来源:XugglerInputStream.java

示例7: open

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void open(URLVideoSource src) throws IOException {
	try {
		if("file".equals(src.getURL().getProtocol())) {
			File f = new File(src.getURL().toURI());
			if (container.open(f.getAbsolutePath(), IContainer.Type.READ, null) < 0)
				throw new IOException("could not open " + f.getAbsolutePath());
		} else {
			String urlStr = TextUtilities.toString(src.getURL());
			if (container.open(urlStr, IContainer.Type.READ, null) < 0)
				throw new IOException("could not open " + urlStr);
		}
	} catch(URISyntaxException e) {
		throw new IOException(e);
	}
	// query how many streams the call to open found
	int numStreams = container.getNumStreams();
	// and iterate through the streams to find the first audio stream
	int videoStreamId = -1;
	int audioStreamId = -1;
	for(int i = 0; i < numStreams; i++) {
		// Find the stream object
		IStream stream = container.getStream(i);
		// Get the pre-configured decoder that can decode this stream;
		IStreamCoder coder = stream.getStreamCoder();

		if (videoStreamId == -1 && coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
			videoStreamId = i;
			videoStream   = stream;
			videoCoder    = coder;
		}
		else if (audioStreamId == -1 && coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
			audioStreamId = i;
			audioStream   = stream;
			audioCoder    = coder;
			audioFormat   = new AudioFormat(
					audioCoder.getSampleRate(),
					(int)IAudioSamples.findSampleBitDepth(audioCoder.getSampleFormat()),
					audioCoder.getChannels(),
					true, /* xuggler defaults to signed 16 bit samples */
					false);
		}
	}
	if (videoStreamId == -1 && audioStreamId == -1)
		throw new IOException("could not find audio or video stream in container in " + src);

	/*
	 * Check if we have a video stream in this file.  If so let's open up our decoder so it can
	 * do work.
	 */
	if (videoCoder != null) {
		if(videoCoder.open() < 0)
			throw new IOException("could not open audio decoder for container " + src);

		if (videoCoder.getPixelType() != IPixelFormat.Type.RGB24) {
			resampler = IVideoResampler.make(
					videoCoder.getWidth(), videoCoder.getHeight(), 
					IPixelFormat.Type.RGB24,
					videoCoder.getWidth(), videoCoder.getHeight(), 
					videoCoder.getPixelType());
			if (resampler == null)
				throw new IOException("could not create color space resampler for " + src);
		}
	}

	if (audioCoder != null) {
		if (audioCoder.open() < 0)
			throw new IOException("could not open audio decoder for container: " + src);
	}
	decoderThread = new Thread(this, src.getURL().toString());
	decoderThread.setPriority(Thread.MIN_PRIORITY);
	decoderThread.setDaemon(true);
	doDecode.set(true);
	decoderThread.start();
}
 
开发者ID:arisona,项目名称:ether,代码行数:76,代码来源:XuggleAccess.java

示例8: load

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
@Override
public XugglerAudioMedia load(String basePath, String filePath) throws MediaException {
	// create the video container object
	IContainer container = IContainer.make();

	// open the container format
	if (container.open(filePath, IContainer.Type.READ, null) < 0) {
		LOGGER.error("Could not open container: [" + filePath + "].");
		throw new UnsupportedMediaException(filePath);
	}
	// convert to seconds
	long length = container.getDuration() / 1000 / 1000;
	String format = container.getContainerFormat().getInputFormatLongName() + " [";
	LOGGER.debug("Audio file opened. Container format: " + container.getContainerFormat().getInputFormatLongName());

	// query how many streams the call to open found
	int numStreams = container.getNumStreams();
	LOGGER.debug("Stream count: " + numStreams);

	// loop over the streams to find the first audio stream
	IStreamCoder audioCoder = null;
	for (int i = 0; i < numStreams; i++) {
		IStream stream = container.getStream(i);
		// get the coder for the stream
		IStreamCoder coder = stream.getStreamCoder();
		// check for an audio stream
		if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
			audioCoder = coder;
		}
	}
	
	// make sure we have a video stream
	if (audioCoder == null) {
		LOGGER.error("No audio coder found in container: [" + filePath + "].");
		throw new UnsupportedMediaException(filePath);
	}
	
	// check audio
	if (audioCoder != null) {
		format += " " + audioCoder.getCodec().getLongName();
	}
	format += "]";
	
	AudioMediaFile file = new AudioMediaFile(
			basePath,
			filePath,
			format,
			length);
	
	// create the media object
	XugglerAudioMedia media = new XugglerAudioMedia(file);
	
	// clean up
	if (container != null) {
		container.close();
	}
	
	// return the media
	return media;
}
 
开发者ID:wnbittle,项目名称:praisenter,代码行数:61,代码来源:XugglerAudioMediaLoader.java

示例9: testBasicInfo

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
@Test
public void testBasicInfo() {
    // first we create a Xuggler container object
    IContainer container = IContainer.make();

    // we attempt to open up the container
    int result = container.open(filename, IContainer.Type.READ, null);

    // check if the operation was successful
    if (result < 0)
        throw new RuntimeException("Failed to open media file");

    // query how many streams the call to open found
    int numStreams = container.getNumStreams();

    // query for the total duration
    long duration = container.getDuration();

    // query for the file size
    long fileSize = container.getFileSize();

    // query for the bit rate
    long bitRate = container.getBitRate();

    System.out.println("Number of streams: " + numStreams);
    System.out.println("Duration (ms): " + duration);
    System.out.println("File Size (bytes): " + fileSize);
    System.out.println("Bit Rate: " + bitRate);

    // iterate through the streams to print their meta data
    for (int i = 0; i < numStreams; i++) {

        // find the stream object
        IStream stream = container.getStream(i);

        // get the pre-configured decoder that can decode this stream;
        IStreamCoder coder = stream.getStreamCoder();

        System.out.println("*** Start of Stream Info ***");

        System.out.printf("stream %d: ", i);
        System.out.printf("type: %s; ", coder.getCodecType());
        System.out.printf("codec: %s; ", coder.getCodecID());
        System.out.printf("duration: %s; ", stream.getDuration());
        System.out.printf("start time: %s; ", container.getStartTime());
        System.out.printf("timebase: %d/%d; ", stream.getTimeBase()
                .getNumerator(), stream.getTimeBase().getDenominator());
        System.out.printf("coder tb: %d/%d; ", coder.getTimeBase()
                .getNumerator(), coder.getTimeBase().getDenominator());
        System.out.println();

        if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
            System.out.printf("sample rate: %d; ", coder.getSampleRate());
            System.out.printf("channels: %d; ", coder.getChannels());
            System.out.printf("format: %s", coder.getSampleFormat());
        } else if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
            System.out.printf("width: %d; ", coder.getWidth());
            System.out.printf("height: %d; ", coder.getHeight());
            System.out.printf("format: %s; ", coder.getPixelType());
            System.out.printf("frame-rate: %5.2f; ", coder.getFrameRate()
                    .getDouble());
        }

        System.out.println();
        System.out.println("*** End of Stream Info ***");

    }

}
 
开发者ID:destiny1020,项目名称:java-learning-notes-cn,代码行数:70,代码来源:XuggleTest.java

示例10: play

import com.xuggle.xuggler.IStreamCoder; //导入方法依赖的package包/类
/**
 * Plays the video stream, or resumes it if it was paused
 */
public void play() {
	
	if(container == null) {
		// Create a Xuggler container object
		container = IContainer.make();
	}
	
	if(!container.isOpened()) {
		// Open up the container
		if (container.open(inputStream, null) < 0) {
			throw new RuntimeException("Could not open video file: " + videoPath);
		}

		// Query how many streams the call to open found
		int numStreams = container.getNumStreams();

		// Iterate through the streams to find the first video stream
		for (int i = 0; i < numStreams; i++) {
			// Find the stream object
			IStream stream = container.getStream(i);
			
			// Get the pre-configured decoder that can decode this stream;
			IStreamCoder coder = stream.getStreamCoder();
			
			if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
				videoStreamId = i;
				videoCoder = coder;
				break;
			}
		}
		
		if (videoStreamId == -1) {
			throw new RuntimeException("Could not find video stream in container: " + videoPath);
		}
		
		/* Now we have found the video stream in this file. Let's open up our
		 * decoder so it can do work
		 */
		if (videoCoder.open() < 0) {
			throw new RuntimeException("Could not open video decoder for container: " + videoPath);
		}
		
		if (videoCoder.getPixelType() != IPixelFormat.Type.BGR24) {
			// If this stream is not in BGR24, we're going to need to convert it
			resampler = IVideoResampler.make(
				videoCoder.getWidth(),
				videoCoder.getHeight(),
				IPixelFormat.Type.BGR24,
				videoCoder.getWidth(),
				videoCoder.getHeight(),
				videoCoder.getPixelType()
			);
			
			if (resampler == null) {
				throw new RuntimeException("Could not create color space resampler");
			}
		}
		
		/* Query the first timestamp in the stream
		 * Timestamps are in microseconds - convert to milli
		 */
		firstTimestampMilliseconds = container.getStartTime() / 1000;
	}
	
	playState = PlayState.PLAYING;
}
 
开发者ID:aaronsnoswell,项目名称:LibGDXVideoSample,代码行数:70,代码来源:VideoTextureProvider.java


注:本文中的com.xuggle.xuggler.IStreamCoder.getCodecType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。