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


Java IMediaReader.readPacket方法代码示例

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


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

示例1: grab

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
/**
 * Grab a still image from the video and store it in
 * {@link StillVideo#getStill()}.
 */
public void grab() {
    IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);
    mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
    mediaReader.addListener(new ImageSnapListener());

    if (grabAt == -1) {
        // Get a screenshot half way through the video
        grabAt = (getVideoDuration() / 2);
    }

    try {
        while (mediaReader.readPacket() == null && !gotStill) ;
    } catch (Throwable t) {
        Logger.getLogger(StillVideo.class.getName()).log(Level.INFO, t.
                getMessage());
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:22,代码来源:StillVideo.java

示例2: testTranscoding

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
@Test
public void testTranscoding() {
    IMediaReader mediaReader = ToolFactory.makeReader(filename);
    IMediaWriter mediaWriter = ToolFactory.makeWriter(targetFilename,
            mediaReader);

    mediaReader.addListener(mediaWriter);

    // create a media viewer with stats enabled
    //        IMediaViewer mediaViewer = ToolFactory.makeViewer(true);
    //        
    //        mediaReader.addListener(mediaViewer);

    while (mediaReader.readPacket() == null)
        ;
}
 
开发者ID:destiny1020,项目名称:java-learning-notes-cn,代码行数:17,代码来源:XuggleTest.java

示例3: testModifyMedia

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
@Test
public void testModifyMedia() {
    IMediaReader mediaReader = ToolFactory.makeReader(targetFilename);

    // configure it to generate buffer images
    mediaReader
            .setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);

    IMediaWriter mediaWriter = ToolFactory.makeWriter(targetAvi,
            mediaReader);

    IMediaTool imageMediaTool = new StaticImageMediaTool(targetImage);
    IMediaTool audioVolumeMediaTool = new VolumeAdjustMediaTool(0.3);

    mediaReader.addListener(imageMediaTool);
    imageMediaTool.addListener(audioVolumeMediaTool);
    audioVolumeMediaTool.addListener(mediaWriter);

    while (mediaReader.readPacket() == null)
        ;
}
 
开发者ID:destiny1020,项目名称:java-learning-notes-cn,代码行数:22,代码来源:XuggleTest.java

示例4: testSplittingIntoTwo

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
@Test
public void testSplittingIntoTwo() {
    String source = "D:/worksap/HUE-kickoff/team-introduction/SRE.mp4";
    String target1 = "D:/worksap/HUE-kickoff/team-introduction/SRE-1.mp4";
    String target2 = "D:/worksap/HUE-kickoff/team-introduction/SRE-2.mp4";

    IMediaReader reader = ToolFactory.makeReader(source);
    CutChecker cutChecker = new CutChecker();
    reader.addListener(cutChecker);
    IMediaWriter writer = ToolFactory.makeWriter(target1, reader);
    cutChecker.addListener(writer);

    boolean updated = false;
    while (reader.readPacket() == null) {
        // 15 below is the point to split, in seconds
        if ((cutChecker.currentTimestamp >= 15 * 1000000) && (!updated)) {
            cutChecker.removeListener(writer);
            writer.close();
            writer = ToolFactory.makeWriter(target2, reader);
            cutChecker.addListener(writer);
            updated = true;
        }
    }
}
 
开发者ID:destiny1020,项目名称:java-learning-notes-cn,代码行数:25,代码来源:XuggleTest.java

示例5: testSplittingOnlyOne

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
@Test
public void testSplittingOnlyOne() {
    String source = "D:/worksap/HUE-kickoff/team-introduction/SRE.mp4";
    String target3 = "D:/worksap/HUE-kickoff/team-introduction/SRE-3.mp4";

    IMediaReader reader = ToolFactory.makeReader(source);
    CutChecker cutChecker = new CutChecker();
    reader.addListener(cutChecker);

    boolean updated = false;
    while (reader.readPacket() == null) {
        // 15 below is the point to split, in seconds
        if ((cutChecker.currentTimestamp >= 15 * 1000000) && (!updated)) {
            IMediaWriter writer = ToolFactory.makeWriter(target3, reader);
            cutChecker.addListener(writer);
            updated = true;
        }
    }
}
 
开发者ID:destiny1020,项目名称:java-learning-notes-cn,代码行数:20,代码来源:XuggleTest.java

示例6: main

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
/**
 * Takes a media container (file) as the first argument, opens it,
 * plays audio as quickly as it can, and opens up a Swing window and
 * displays video frames with <i>roughly</i> the right timing.
 *  
 * @param args Must contain one string which represents a filename
 */

public static void main(String[] args) {
    args = new String[] { "D:\\worksap\\HUE-kickoff\\team-introduction\\SRE.mp4" };
    if (args.length <= 0)
        throw new IllegalArgumentException(
                "must pass in a filename as the first argument");

    // create a new mr. decode an play audio and video
    IMediaReader reader = ToolFactory.makeReader(args[0]);
    reader.addListener(ToolFactory.makeViewer());
    while (reader.readPacket() == null)
        do {
        } while (false);

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

示例7: run

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
public void run() {
	if (videoFile == null)
		return;
	
	IMediaReader reader = ToolFactory.makeReader(videoFile.getAbsolutePath());
	reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
	reader.addListener(this);

	logger.trace("opening {}", videoFile.getAbsolutePath());

	while (reader.readPacket() == null)
		do {} while (false);
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:14,代码来源:MockCamera.java

示例8: processVideo

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
public void processVideo(IMediaListener listener) {
	IMediaReader reader = ToolFactory.makeReader(videoFile.getAbsolutePath());
	reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
	reader.addListener(listener);

	logger.trace("opening {}", videoFile.getAbsolutePath());

	while (reader.readPacket() == null)
		do {} while (false);
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:11,代码来源:MockCamera.java

示例9: encode

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
public void encode() {
    IMediaReader mediaReader = ToolFactory.makeReader(input);
    mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
    mediaReader.addListener(new Transcoder());

    writer = ToolFactory.makeWriter(output, mediaReader);
    mediaReader.addListener(writer);

    while (mediaReader.readPacket() == null) {
        // read through input and process using the MediaWriter listener
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:13,代码来源:TranscodeVideo.java

示例10: execute

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
@Override
public List<CVParticle> execute(CVParticle particle) throws Exception {
	List<CVParticle> result = new ArrayList<CVParticle>();
	if(!(particle instanceof VideoChunk)) return result;
	
	VideoChunk video = (VideoChunk) particle;
	frames = new ArrayList<>();
	seqNum = video.getSequenceNr();
	streamId = video.getStreamId();
	
	File tmpVideo = File.createTempFile("videochunk_", "."+video.getContainer());
	FileOutputStream fos = new FileOutputStream(tmpVideo);
	fos.write(video.getVideo());
	fos.flush();
	fos.close();
	IMediaReader reader = ToolFactory.makeReader(tmpVideo.getAbsolutePath());
	
	reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
	reader.addListener(this);
	while (reader.readPacket() == null);
	reader.close();
	if(!tmpVideo.delete()) tmpVideo.deleteOnExit();
	
	if(groupOfFrames){
		result.add(new GroupOfFrames(video.getStreamId(), video.getSequenceNr(), frames));
	}else{
		for(Frame frame : frames) result.add(frame);
	}
	return result;
}
 
开发者ID:sensorstorm,项目名称:StormCV,代码行数:31,代码来源:VideoToFramesOp.java

示例11: createThumbnailImage

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
/**
 * Attempts to create a new thumbnail image.
 * @param dim the dimension of the image
 * @param pathToVideo the path to the source video file
 * @return the thumbnail image, or null if failed
 */
public static synchronized BufferedImage createThumbnailImage(Dimension dim, String pathToVideo) {
	THUMBNAIL_TOOL.initialize(dim);
	String path = pathToVideo.startsWith("http:")? ResourceLoader.getURIPath(pathToVideo): pathToVideo; //$NON-NLS-1$
  IMediaReader mediaReader = ToolFactory.makeReader(path);
  mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
  mediaReader.addListener(THUMBNAIL_TOOL);
  while (!THUMBNAIL_TOOL.isFinished() && mediaReader.readPacket()==null); // reads video until a thumbnail is created
  mediaReader.close();
  return THUMBNAIL_TOOL.thumbnail;
}
 
开发者ID:OpenSourcePhysics,项目名称:video-engines,代码行数:17,代码来源:XuggleThumbnailTool.java

示例12: readXugglerFlac

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
private void readXugglerFlac(Binary binary, AudioFormat format, File file) {
	IMediaListener myListener = new MediaListenerAdapter() {
		public void onOpen(IMediaGenerator pipe) {
			log.info("opened: " + ((IMediaReader) pipe).getUrl());
		}

		@Override
		public void onAudioSamples(IAudioSamplesEvent event) {
			IAudioSamples samples = event.getAudioSamples();
			// log.info("onaudiosamples " + samples.getNumSamples() + " "+
			// " fs:" + getFS().length() + " " + samples);
			ShortBuffer sb = samples.getByteBuffer().asShortBuffer();

			for (int i = 0; i < sb.limit()
					&& getFS().length() < audioinfo.getSampleCount(); i++) {
				short num = sb.get(i);
				getFS().add(1.0f * num / Short.MAX_VALUE);
			}
			//
			super.onAudioSamples(event);
		}
	};

	IMediaReader r = ToolFactory.makeReader(file.getAbsolutePath());
	r.addListener(myListener);

	while (true) {
		IError p;
		p = r.readPacket();
		if (p != null) {
			break;
		}
	}
	//
	log.info("read flac done");
}
 
开发者ID:jeukku,项目名称:waazdoh.music.common,代码行数:37,代码来源:MWave.java

示例13: main

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
/**
 * Create and display a number of bouncing balls on the 
 */

public static void main(String[] args) {
    args = new String[] {
            "D:\\worksap\\HUE-kickoff\\team-introduction\\SRE.mp4",
            "D:\\worksap\\HUE-kickoff\\team-introduction\\SRE-modified.mp4" };

    if (args.length < 2) {
        System.out
                .println("Usage: ModifyAudioAndVideo <inputFileName> <outputFileName>");
        System.exit(-1);
    }

    File inputFile = new File(args[0]);
    if (!inputFile.exists()) {
        System.out.println("Input file does not exist: " + inputFile);
        System.exit(-1);
    }

    File outputFile = new File(args[1]);

    // create a media reader and configure it to generate BufferImages

    IMediaReader reader = ToolFactory.makeReader(inputFile.toString());
    reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);

    // create a writer and configure it's parameters from the reader

    IMediaWriter writer = ToolFactory.makeWriter(outputFile.toString(),
            reader);

    // create a tool which paints video time stamp into frame

    IMediaTool addTimeStamp = new TimeStampTool();

    // create a tool which reduces audio volume to 1/10th original

    IMediaTool reduceVolume = new VolumeAdjustTool(0.1);

    // create a tool chain:
    //   reader -> addTimeStamp -> reduceVolume -> writer

    reader.addListener(addTimeStamp);
    addTimeStamp.addListener(reduceVolume);
    reduceVolume.addListener(writer);

    // add a viewer to the writer, to see media modified media

    writer.addListener(ToolFactory.makeViewer());

    // read and decode packets from the source file and
    // then encode and write out data to the output file

    while (reader.readPacket() == null)
        do {
        } while (false);
}
 
开发者ID:destiny1020,项目名称:java-learning-notes-cn,代码行数:60,代码来源:ModifyVideoAndAudio.java

示例14: concatenate

import com.xuggle.mediatool.IMediaReader; //导入方法依赖的package包/类
/**
 * Concatenate two source files into one destination file.
 * 
 * @param sourceUrl1 the file which will appear first in the output
 * @param sourceUrl2 the file which will appear second in the output
 * @param destinationUrl the file which will be produced
 */

public static void concatenate(String sourceUrl1, String sourceUrl2,
        String destinationUrl) {
    out.printf("transcode %s + %s -> %s\n", sourceUrl1, sourceUrl2,
            destinationUrl);

    //////////////////////////////////////////////////////////////////////
    //                                                                  //
    // NOTE: be sure that the audio and video parameters match those of //
    // your input media                                                 //
    //                                                                  //
    //////////////////////////////////////////////////////////////////////

    // video parameters

    final int videoStreamIndex = 0;
    final int videoStreamId = 0;
    final int width = 1920;
    final int height = 1080;

    // audio parameters

    final int audioStreamIndex = 1;
    final int audioStreamId = 0;
    final int channelCount = 2;
    final int sampleRate = 48000; // Hz

    // create the first media reader

    IMediaReader reader1 = ToolFactory.makeReader(sourceUrl1);

    // create the second media reader

    IMediaReader reader2 = ToolFactory.makeReader(sourceUrl2);

    // create the media concatenator

    MediaConcatenator concatenator = new MediaConcatenator(
            audioStreamIndex, videoStreamIndex);

    // concatenator listens to both readers

    reader1.addListener(concatenator);
    reader2.addListener(concatenator);

    // create the media writer which listens to the concatenator

    IMediaWriter writer = ToolFactory.makeWriter(destinationUrl);
    concatenator.addListener(writer);

    // add the video stream

    writer.addVideoStream(videoStreamIndex, videoStreamId, width, height);

    // add the audio stream

    writer.addAudioStream(audioStreamIndex, audioStreamId, channelCount,
            sampleRate);

    // read packets from the first source file until done

    while (reader1.readPacket() == null)
        ;

    // read packets from the second source file until done

    while (reader2.readPacket() == null)
        ;

    // close the writer

    writer.close();
}
 
开发者ID:destiny1020,项目名称:java-learning-notes-cn,代码行数:81,代码来源:ConcatenateAudioAndVideo.java


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