2

I am new to Xuggler. I want to write a program which reads a video file from ByteArrayInputStream. This is the code:

 public static String path="/home/gurinderbeer/Downloads/IMG_1579.MOV";

 public static void main(String[] args) throws IOException
 {
     // get size of file
    File f = new File(path);
    int size = (int) f.length();
    byte[] b = new byte[size];

    // read data from inputstream into byte array b
    InputStream fileInputStream = null;
    fileInputStream = new FileInputStream(path);
    fileInputStream.read(b);


    // convert byte array to ByteArrayinputStream
    InputStream byteStream = new ByteArrayInputStream(b);

    //create container from byteStream
    IContainer container =IContainer.make();
    int result = container.open(byteStream,null);

    System.out.println(container.getNumStreams());
    System.out.println(container.getDuration());

    byteStream.close();

}

First, get the file from input path. Get size of the file, and initialize the byte array.

Then get all data from file input fileinputstream, and copy that data to byte array. Next,it creates byteArrayInputStream from byte array.

Finally, this byteArrayInputStream is given as input to the IContainer.

This code works for the video files, if size of video file is less than 7 MB in notime( it takes less than 1 second to run). But if I use video file greater than 7 MB of size, the program continues to run and never ends. I didn't gave any error, but continues to execute. I tried to debug and found it continues to run at this line:

int result = container.open(byteStream,null)

I left the program running even for half an hour but it didn't gave any results, and still continue to execute..

Can anyone help regarding this.....

0 Answers0