本文整理汇总了Java中com.xuggle.mediatool.ToolFactory.makeReader方法的典型用法代码示例。如果您正苦于以下问题:Java ToolFactory.makeReader方法的具体用法?Java ToolFactory.makeReader怎么用?Java ToolFactory.makeReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.xuggle.mediatool.ToolFactory
的用法示例。
在下文中一共展示了ToolFactory.makeReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: grab
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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());
}
}
示例2: testTranscoding
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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)
;
}
示例3: testModifyMedia
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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)
;
}
示例4: testSplittingIntoTwo
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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;
}
}
}
示例5: testSplittingOnlyOne
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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;
}
}
}
示例6: main
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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);
}
示例7: PlaybackContext
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的package包/类
public PlaybackContext(File videoFile, PlaybackListener listener) {
this.listener = listener;
mediaReader = ToolFactory.makeReader(videoFile.getPath());
mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
mediaReader.open();
duration = mediaReader.getContainer().getDuration() / 1000; // microseconds
// to
// milliseconds
mediaReader.addListener(this);
}
示例8: run
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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);
}
示例9: processVideo
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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);
}
示例10: setupReader
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的package包/类
private void setupReader(IContainer container) {
// Set up a new reader using the container that reads the images.
this.reader = ToolFactory.makeReader(container);
this.reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
this.reader.addListener(new FrameGetter());
// Find the video stream.
IStream s = null;
int i = 0;
while (i < container.getNumStreams()) {
s = container.getStream(i);
if (s != null && s.getStreamCoder().getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
// Save the stream index so that we only get frames from
// this stream in the FrameGetter
this.streamIndex = i;
break;
}
i++;
}
if (container.getDuration() == Global.NO_PTS)
this.totalFrames = -1;
else
this.totalFrames = (long) (s.getDuration() *
s.getTimeBase().getDouble() * s.getFrameRate().getDouble());
// If we found the video stream, set the FPS
if (s != null)
this.fps = s.getFrameRate().getDouble();
// If we found a video stream, setup the MBFImage buffer.
if (s != null) {
final int w = s.getStreamCoder().getWidth();
final int h = s.getStreamCoder().getHeight();
this.width = w;
this.height = h;
}
}
示例11: encode
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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
}
}
示例12: execute
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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;
}
示例13: ConvertAudio
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的package包/类
public ConvertAudio(InputStream input) {
//this.outputFile = outputFile;
IContainer container = IContainer.make();
if (container.open(XugglerIO.map(input),IContainer.Type.READ, null) < 0)
throw new IllegalArgumentException("Could not Stream the Content " );
reader = ToolFactory.makeReader(container);
reader.addListener(this);
}
示例14: RTMPDump
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的package包/类
public RTMPDump(String server, int port, String app, String streamName, String targetM3u8) throws IOException {
this.url = makeRTMPUrl(server, port, app, streamName);
reader = ToolFactory.makeReader(url);
if (logger.isInfoEnabled()) {
reader.addListener(ToolFactory.makeDebugListener());
}
lock = new Semaphore(0);
m3u8Container = new M3U8Container(streamName, targetM3u8);
m3u8Container.setup();
}
示例15: createThumbnailImage
import com.xuggle.mediatool.ToolFactory; //导入方法依赖的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;
}