Java 有没有办法通过Xuggler获得视频的分辨率?

Java 有没有办法通过Xuggler获得视频的分辨率?,java,video,resolution,xuggler,Java,Video,Resolution,Xuggler,我正在开发一个项目,它本质上是一个视频上传程序,我想知道是否有任何方法可以使用Java中的Xuggler库获得上传视频的分辨率。在类中有getHeight和getWidth方法 所以你应该使用这些方法,告诉你怎么做 我告诉你什么是重要的 // Create a Xuggler container object IContainer container = IContainer.make(); // Open up the container if (container.open("/path/

我正在开发一个项目,它本质上是一个视频上传程序,我想知道是否有任何方法可以使用Java中的Xuggler库获得上传视频的分辨率。

在类中有
getHeight
getWidth
方法

所以你应该使用这些方法,告诉你怎么做

我告诉你什么是重要的

// Create a Xuggler container object
IContainer container = IContainer.make();

// Open up the container
if (container.open("/path/to/video.avi", IContainer.Type.READ, null) < 0)
  throw new IllegalArgumentException("could not open file: " + filename);

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

// and iterate through the streams to find the first video stream
int videoStreamId = -1;
IStreamCoder videoCoder = null;
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: "
      +filename);

/*
 * 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: "
      + filename);

// here you have what you need
int height = videoCoder.getHeight();
int width = videoCoder.getWidth();
//创建一个Xuggler容器对象
IContainer容器=IContainer.make();
//打开容器
if(container.open(“/path/to/video.avi”,IContainer.Type.READ,null)<0)
抛出新的IllegalArgumentException(“无法打开文件:+filename”);
//查询要打开的调用找到了多少流
int numStreams=container.getNumStreams();
//并遍历这些流以找到第一个视频流
int videoStreamId=-1;
IStreamCoder videoCoder=null;
for(int i=0;i