当前位置: 首页 > news >正文

做网站用的大图在哪里查关键词排名

做网站用的大图,在哪里查关键词排名,未成年人做网站,seo 关键词优化注意#xff1a;这是我们的“ Xuggler开发教程 ”系列的一部分。 到目前为止#xff0c;在我们的Xuggler教程系列中#xff0c;我们已经对视频处理的Xuggler进行了介绍#xff0c;并讨论了转码和媒体修改 。 在本教程中#xff0c;我们将看到如何解码视频和捕获帧#xf… 注意这是我们的“ Xuggler开发教程 ”系列的一部分。 到目前为止在我们的Xuggler教程系列中我们已经对视频处理的Xuggler进行了介绍并讨论了转码和媒体修改 。 在本教程中我们将看到如何解码视频和捕获帧以及如何从头开始创建视频。 让我们开始解码视频流并以预定义的时间间隔捕获一些帧。 例如可以使用它来制作媒体文件的缩略图 。 为此我们将再次使用MediaTool API 这是用于解码编码和修改视频的高级API。 概念是打开媒体文件循环播放特定的视频流并以特定的间隔捕获相应的帧将其转换为图像然后将二进制内容转储到文件中。 这是所有这些代码的样子 package com.javacodegeeks.xuggler;import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException;import javax.imageio.ImageIO;import com.xuggle.mediatool.IMediaReader; import com.xuggle.mediatool.MediaListenerAdapter; import com.xuggle.mediatool.ToolFactory; import com.xuggle.mediatool.event.IVideoPictureEvent; import com.xuggle.xuggler.Global;public class VideoThumbnailsExample {public static final double SECONDS_BETWEEN_FRAMES 10;private static final String inputFilename c:/Java_is_Everywhere.mp4;private static final String outputFilePrefix c:/snapshots/mysnapshot;// The video stream index, used to ensure we display frames from one and// only one video stream from the media container.private static int mVideoStreamIndex -1;// Time of last frame writeprivate static long mLastPtsWrite Global.NO_PTS;public static final long MICRO_SECONDS_BETWEEN_FRAMES (long)(Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);public static void main(String[] args) {IMediaReader mediaReader ToolFactory.makeReader(inputFilename);// stipulate that we want BufferedImages created in BGR 24bit color spacemediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);mediaReader.addListener(new ImageSnapListener());// read out the contents of the media file and// dispatch events to the attached listenerwhile (mediaReader.readPacket() null) ;}private static class ImageSnapListener extends MediaListenerAdapter {public void onVideoPicture(IVideoPictureEvent event) {if (event.getStreamIndex() ! mVideoStreamIndex) {// if the selected video stream id is not yet set, go ahead an// select this lucky video streamif (mVideoStreamIndex -1)mVideoStreamIndex event.getStreamIndex();// no need to show frames from this video streamelsereturn;}// if uninitialized, back date mLastPtsWrite to get the very first frameif (mLastPtsWrite Global.NO_PTS)mLastPtsWrite event.getTimeStamp() - MICRO_SECONDS_BETWEEN_FRAMES;// if its time to write the next frameif (event.getTimeStamp() - mLastPtsWrite MICRO_SECONDS_BETWEEN_FRAMES) {String outputFilename dumpImageToFile(event.getImage());// indicate file writtendouble seconds ((double) event.getTimeStamp()) / Global.DEFAULT_PTS_PER_SECOND;System.out.printf(at elapsed time of %6.3f seconds wrote: %s\n,seconds, outputFilename);// update last write timemLastPtsWrite MICRO_SECONDS_BETWEEN_FRAMES;}}private String dumpImageToFile(BufferedImage image) {try {String outputFilename outputFilePrefix System.currentTimeMillis() .png;ImageIO.write(image, png, new File(outputFilename));return outputFilename;} catch (IOException e) {e.printStackTrace();return null;}}}} 这看起来似乎有些令人不知所措但确实非常简单。 让我为您提供一些详细信息。 我们首先从输入文件创建IMediaReader 。 媒体读取器用于读取和解码媒体。 由于我们希望将捕获的视频帧作为图像进行处理因此我们使用setBufferedImageTypeToGenerate方法来表示这一点。 阅读器打开一个媒体容器从中读取数据包解码数据然后将有关数据的信息分发到任何已注册的IMediaListener对象。 这是我们的自定义类ImageSnapListener起作用的地方。 我们的侦听器扩展了MediaListenerAdapter 它是实现IMediaListener接口的适配器提供空方法。 通知实现此接口的对象有关视频处理期间生成的事件的信息。 我们只关心处理视频事件因此我们仅实现IMediaListener.onVideoPicture方法。 在其中我们使用提供的IVideoPictureEvent对象查找正在处理的流仅视频。 由于我们希望在特定时间捕获帧因此我们不得不在时间戳上弄乱一点。 首先我们通过检查Global.NO_PTS常量的值来确保处理第一帧该值意味着没有为给定对象设置时间戳。 然后如果经过了最短的时间我们通过调用IVideoPictureEvent.getImage方法捕获帧该方法返回基础BufferedImage 。 请注意我们所说的是经过的视频时间而不是“实时”。 然后我们使用ImageIO.write实用程序方法将图像数据转储为PNG格式的文件。 最后我们更新最后的写入时间。 让我们运行此应用程序以查看结果。 作为输入文件我使用的是一个古老的Sun商业广告它宣称“ Java无处不在 ”。 我已经在本地下载了提供的MP4版本。 这是输出控制台的外观 在经过0.000秒时写道c/snapshots/mysnapshot1298228503292.png 在10.010秒的经过时间写道c/snapshots/mysnapshot1298228504014.png 在20.020秒的经过时间写道c/snapshots/mysnapshot1298228504463.png … 在经过时间130.063秒时写道c/snapshots/mysnapshot1298228509454.png 在经过时间140.007秒时写道c/snapshots/mysnapshot1298228509933.png 在经过150.017秒的时间时写道c/snapshots/mysnapshot1298228510379.png 总视频时间约为151秒因此我们捕获了16帧。 这是我的文件夹中捕获的图像的外观 好的就是用来制作视频缩略图的。 现在让我们看看如何从头开始创建视频。 作为输入我们将使用桌面上的顺序快照 。 这可以用于基本的屏幕记录应用程序。 为了创建视频与到目前为止所见的MediaTool API相比我们将不得不采取一些更底层的方法。 不过请不要担心它不会很复杂。 主要思想是我们创建一个媒体编写器向其中添加一些流信息对我们的媒体屏幕截图图像进行编码然后关闭该编写器。 让我们看看用于实现此目的的代码 package com.javacodegeeks.xuggler;import java.awt.AWTException; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.util.concurrent.TimeUnit;import com.xuggle.mediatool.IMediaWriter; import com.xuggle.mediatool.ToolFactory; import com.xuggle.xuggler.ICodec;public class ScreenRecordingExample {private static final double FRAME_RATE 50;private static final int SECONDS_TO_RUN_FOR 20;private static final String outputFilename c:/mydesktop.mp4;private static Dimension screenBounds;public static void main(String[] args) {// lets make a IMediaWriter to write the file.final IMediaWriter writer ToolFactory.makeWriter(outputFilename);screenBounds Toolkit.getDefaultToolkit().getScreenSize();// We tell it were going to add one video stream, with id 0,// at position 0, and that it will have a fixed frame rate of FRAME_RATE.writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_MPEG4, screenBounds.width/2, screenBounds.height/2);long startTime System.nanoTime();for (int index 0; index SECONDS_TO_RUN_FOR * FRAME_RATE; index) {// take the screen shotBufferedImage screen getDesktopScreenshot();// convert to the right image typeBufferedImage bgrScreen convertToType(screen, BufferedImage.TYPE_3BYTE_BGR);// encode the image to stream #0writer.encodeVideo(0, bgrScreen, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);// sleep for frame rate millisecondstry {Thread.sleep((long) (1000 / FRAME_RATE));} catch (InterruptedException e) {// ignore}}// tell the writer to close and write the trailer if neededwriter.close();}public static BufferedImage convertToType(BufferedImage sourceImage, int targetType) {BufferedImage image;// if the source image is already the target type, return the source imageif (sourceImage.getType() targetType) {image sourceImage;}// otherwise create a new image of the target type and draw the new imageelse {image new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), targetType);image.getGraphics().drawImage(sourceImage, 0, 0, null);}return image;}private static BufferedImage getDesktopScreenshot() {try {Robot robot new Robot();Rectangle captureSize new Rectangle(screenBounds);return robot.createScreenCapture(captureSize);} catch (AWTException e) {e.printStackTrace();return null;}}} 我们首先从给定的输出文件创建一个IMediaWriter 。 此类对媒体进行编码和解码同时处理音频和视频流。 Xuggler猜测文件扩展名在我们的情况下为MP4的输出格式并适当设置一些默认值。 然后我们使用addVideoStream方法添加新的视频流并提供其索引使用的编解码器类型 此处为MPEG-4 和视频尺寸。 在此示例中尺寸设置为等于屏幕尺寸的一半。 然后我们执行一个循环该循环的运行次数等于所需的帧速率乘以所需的运行时间。 在循环内部我们按照Java2D带有Java屏幕快照的文章中的描述生成屏幕快照。 我们将屏幕快照作为BufferedImage检索并将其转换为适当的类型 TYPE_3BYTE_BGR 如果尚不存在。 接下来我们使用IMediaWriter.encodeVideo方法将图像编码为视频流。 我们提供流索引图像经过的视频时间和时间单位。 然后根据所需的帧速率我们睡适当的时间。 循环结束后我们将关闭编写器并在必要时编写预告片具体取决于视频格式这由Xuggler自动完成。 如果我们执行该应用程序则会创建一个视频其中记录了您的桌面操作。 这是浏览JavaCodeGeeks网站时的静止图像 伙计们这是Xuggler的另一篇教程描述了如何从输入文件捕获视频帧以及如何使用桌面快照生成视频。 与往常一样您可以下载为本教程创建的Eclipse项目 。 请继续关注JavaCodeGeeks上的更多Xuggler教程 别忘了分享 相关文章 Xuggler视频处理简介 Xuggler教程转码和媒体修改 使用wowza和xuggler将RTMP转换为RTSP 翻译自: https://www.javacodegeeks.com/2011/02/xuggler-tutorial-frames-capture-video.html
http://www.pierceye.com/news/494302/

相关文章:

  • 购物网站模版广州外贸网络推广
  • 高碑店网站网站建设手机软件开发的模式
  • 公司网站开发国内外现状网络营销外包团队哪些好
  • 淘客网站怎么建立如何用api做网站
  • 合肥网站建设ahyedawordpress主题安全
  • 网站建设实训室介绍东莞seo广告宣传
  • 公职人员可以做公益网站吗aws网站建设
  • 什么叫高端网站定制广州建筑公司
  • 全新网站如何做百度竞价网站制作现状解决方案
  • 阿里云esc建设网站近三天时政热点
  • 怎样做公司网站介绍仿站网站源码下载
  • 电子商务网站规划与建设摘要软件app定制开发
  • 天水做网站的公司kj6699的seo综合查询
  • 找工程项目信息网站早那么做商城网站
  • 做网站优化销售管理系统排名
  • wordpress导入网站模板wordpress部分图片
  • 无锡做网站365caiyi秘密直播
  • 无锡企业网站制作报价公司做网站需要哪些手续
  • 最好的营销型网站保险购买平台有哪些
  • 网站建设实训的目的网站开发的框架协议
  • 本地郑州网站建设搭建一个网站
  • 如何做网站竞品分析哪个网站可以接任务做兼职
  • 佛山网站关键词网站建设需求分析文档
  • 网站收录地址旅游网站建设的相关报价
  • seo月薪seo优化方法网站快速排名推广渠道
  • 企业网站设计理念如何seo网站
  • 河南移动商城网站建设怎么创建平台卖自己的产品
  • 网上做网站钱被骗了报案有用吗文章自定义wordpress
  • 网站设置成灰色市场监督管理局是什么单位
  • 北京国贸网站建设wordpress需要付费才能看某些页面