We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Heavy videos adding creates heap space error


Hi Mudassir,

When we add multiple high quality videos to powerpoint, it generate OutOFMemoryexception.
We have videos of size as big as 2-3 GB and we plan to add them into the PPT files in the coming releases.But Aspose throws exception when videos greater than around 500 mb generates this error.Can you replicate this error on you end ?


Regards
Mohit Garg

Hi Mohit Grag,


I am assuming that you are using the same platform as you have shared in this thread link. I like to share that you that the OutofMemory Exception is thrown when your stack is overflown. I have never been able to verify such a big video files (2-3 GB) by embedding in presentations. Can you please try increasing the Java heap size to m 500 MB more than what you video file size is and share your findings with us. I will create a ticket for this for further investigation by our development team. Even, if it turns out to be a limitation in terms of maximum file size, Aspose.Slides also offers to add video as link rather than embedding in that.

Many Thanks,

Hi Mudassir,

I have tested the pptx with even smaller videos.I got the same heap error when I used a video of size only 100 MB.
FYI I am using Aspose 7.3.0 and My JVM heap setting is max 1024 MB
I would like to emphasize to please check on your side this heap issue.
Linked Videos are not part of requirement.So we have to live with embedded videos in power-point.

Regards
Mohit Garg

Hi Mohit Garg,


Can you please share the sample application along with sample video file with us. Please also share the environment details where by you are using Aspose.Slides. I will investigate the issue further on my end to help you out. You can share the video file in some ftp server or dropbox and kindly share the download link with us.

Many Thanks,

Hi Mudassir,

Thanks for your prompt replies always :slight_smile:

Application can’t be shared as it is confidential but you can easily replicate the issue at your end by the video link I am providing below.Its a 137 MB video and even with single slide PPT file, I get OutOfMemoryError.
Regarding platform details we are getting this error on every platform be it Mac or Windows(XP or 7). It seems to be a buffer related issue.

You can download the Video file from the link below :
http://switchcontrolindia.com/Sample.mp4


Hi Mohit,


I have observed the issue specified and it seems to be an issue with Aspose.Slides while embedding large video files. An issue with ID SLIDESJAVA-33948 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,


Hi Mudassir,

We are getting heap error even on linked videos(In case the video > 150 MB). Earlier we thought its just the embedded videos on which addVideo method throws OutOfMemoryError but with latest library 7.4.0 we are experiencing the same Error with linked videos.Are you reading the whole file in memory even for linked files ?
This is highly unexpected and disappointing.
Can we get this resolved as soon as possible ?

Hi Mohit,


I have worked over the scenario shared by you and tried linking the 700 MB avi movie using Aspose.Slides for Java 7.4.0 by using following sample code. I have not been able to observe any issue at all on my end. I have shared the generated presentation as well for your kind reference. I have used JDK 1.6_35 in Windows 7 x64 environment. Can you please try using following sample code on your end.

//Instantiate PrseetationEx class that represents the PPTX
PresentationEx pres = new PresentationEx();

//Get the first slide
SlideEx sld = pres.getSlides().get_Item(0);

//Add Video Frame
VideoFrameEx vf = sld.getShapes().addVideoFrame(50, 150, 300, 350, “D:\Movies\Dead Man Down.avi”);

//Set Play Mode and Volume of the Video
vf.setPlayMode(VideoPlayModePresetEx.Auto);
vf.setVolume(AudioVolumeModeEx.Loud);
////Creating a Buffered Image object to hold the image file
BufferedImage image=null;

//Loading image
try {
image = ImageIO.read(new File(“C:\Users\Public\Pictures\Sample Pictures\Desert.jpg”));
} catch (IOException e) {
}

//Adding image in collection
ImageEx imgx = pres.getImages().addImage(image);

//Set the fill type to Picture
vf.getFillFormat().setFillType(FillTypeEx.Picture);

//setting image to vide frame
vf.setImage(imgx);

//Write the PPTX file to disk
pres.write(“D:\Aspose Data\VideoFrame.pptx”);

Many Thanks,

Hi Mudassir,

I used this code for linked videos.

vf = sld.getShapes().addVideoFrame(50, 75, 350 * AR, 350, null);
videoStream = new FileInputStream(vidiLink.getAbsolutePath());
VideoEx vid = ppt.getVideos().addVideo(videoStream); // adding VideoEx from stream
// vf.setEmbeddedVideo(vid);

Please note that last line is commented.

It is working for linked videos as well(although crashing for big size videos)
As per your suggestion I tried setting the last parameter of addVideFrame and it works that way as well(without heap error for big videos).

vf = sld.getShapes().addVideoFrame(50, 75, 350 * AR, 350, vidiLink.getAbsolutePath());

Sort of same effect with two approaches.

Anyways Can you please tell by when you can resolve the heap error issue on Embedded videos ? We really need that feature.

Thanks and Regards
Mohit Garg


Hi Mohit Garg,


The correct way for setting the linked Ole frame is as explained in my last post. You need to use the following sample code for setting linked ole.

//Add Video Frame
VideoFrameEx vf = sld.getShapes().addVideoFrame(50, 150, 300, 350, “D:\Movies\Dead Man Down.avi”);

Also, in your sample code, if you comment the following line and that you have:

// vf.setEmbeddedVideo(vid);

You also don’t need to use the following line:

VideoEx vid = ppt.getVideos().addVideo(videoStream);

By using the above line, you are in fact embedding the video in Video collection. It is in fact first step of embedded videos that you first add video to presentation video collection and then set video frame to use the embedded video. So, please try using the sample code shared by me in my last post for linked videos and if there is any issue please feel free to share with us.

Secondly, the issue attached with this thread is still waiting in queue for investigation. Actually, as per Aspose policy, the first priority is given to paid Enterprise and Priority support issues. The issue belonging to mentioned support levels are resolved first. Then the issues belonging to normal support forum like Aspose.Slides are considered for investigation based on first come and first serve basis. Then issues are selected for investigation and resolution based on their complexity. I will be able to share the further feedback regarding your issue as soon as it will be shared by our development team and I will appreciate your patience for that or you may try opting our priority or enterprise support options for expedite investigations of the issue. Also, in Enterprise or Priority support issues the complex issues takes some time but definitely lesser than that of normal support issues.

Many Thanks,

Thanks for detailed explanation Mudassir about Aspose Policy and I understand your point.
For your information we have purchased Aspose " Developer OEM license" almost a month back if that can help.
We have already incorporated Aspose in our product but unable to release due to heap error in big size videos.




Thanks for detailed explanation Mudassir about Aspose Policy and I understand your point.
For your information we have purchased Aspose " Developer OEM license" almost a month back if that can help.
We have already incorporated Aspose in our product but unable to release due to heap error in big size videos.

P.S : Sorry for double post.

Hi Mohit Grag,


I can understand the inconvenience on your end. I have already raised the issue of embedding videos to maximum priority level that can be set to issues added in normal support forums and will share the feedback with you as soon as it will be resolved. I also like to suggest you to please visit this web link for our different support options.

Many Thanks,

Hi Mudassir,

We have same issue with latest release aspose.slides-7.5.

OutOfMemoryError.for files above 130 mb files.

Is there any chance to get its resolution without special support option ?

This bug blocked our power point feature in main application.

Hi Jatinder,

Thanks for inquiring Aspose.Slides.

I like to share that the concerned issue has been added in our issue tracking system with maximum priority level of High that can be assigned to normal support forum issues. However, there are already pending Enterprise and Priority support issues waiting for resolution in queue and as per policy the first preference is given to them. I can understand the inconvenience on your end but I can only request you to kindly wait till the issue is selected for investigation and resolution. I have also requested our development team to kindly schedule the issue for investigation and resolution if there is any empty slot available for scheduling it.

We are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESJAVA-33948) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(1)

Hi Mudassir,


Thanks for working on this issue.

I have tried this update and I can’t say the issue is fixed.
I am still getting the heap space error. The only difference is that the previous versions throws heap error with 135 mb or more of video size and current version throws heap error at 250 mb or more.

250 mb file size can not store more than 3 minutes of full hd videos. This is not an acceptable solution. The video files can be in GB’s

The best way to verify the fix is to create ppt with 1 or 2 gb of embeded video file.

Do you want any thing more from me ?

Hi Jatinder,

I am sorry for the inconvenience. Our development team has investigated
the issue on their end. Actually, the size of inserted video depends on
amount of memory (RAM), because we store the video in form of a byte
array (used copy operation).


Our
developer used test video file = 777mb. When amount of Heap = 3GB he
got an OutOfMemoryException bwhen Heap = 4GB I got the file.

For copying video we have used following code snippet:

FileInputStream fstream=new FileInputStream(“big.avi”);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[2048];

while ((nRead = fstream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
buffer.close();
fstream.close();

Our
development team was able to slightly reduce amount of required memory,
but size of inserted video is still depends on the size of Java heap
space. We recommend using the following code for adding large size video (This code is a little helping the Garbage Collector):

PresentationEx pres=new PresentationEx();
FileInputStream fstream=new FileInputStream(“big.avi”);

ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[2048];

while ((nRead = fstream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
byte[] vidByte = buffer.toByteArray();
buffer.close();
fstream.close();
VideoEx video=pres.getVideos().addVideo(vidByte);

SlideEx slide=pres.getSlides().get_Item(0);

VideoFrameEx vid=slide.getShapes().addVideoFrame(20f, 20f, 300f, 300f, null);

vid.setEmbeddedVideo(video);

pres.write(“presWithVideo.pptx”);

Please share, if I may help you further in this regard.

Hi Mudassir,


Even if we use the above code , I don’t think we can add video files larger than 4gb.
Powerpoint allows you to add videos of any size , I have tried adding video of size 30 gb with power point without any error.
I don’t know Aspose implementation for videos but ideally the whole file should not be loaded in memory. Copy file in chunks to the destination location.

byte[] vidByte = buffer.toByteArray(); for video files is not ideal way to do.


Hi Jatinder,

I have observed the feedback shared by you and like I have shared in my previous post here that size of inserted video is still depends on the size of Java heap
space and Ram size. When you are adding presentation programatically using Aspose.Slides, you are in fact adding a presentation in Document Object Model (DOM) of Aspose.Slides. The DOM is an extracted form of presentation that is loaded in memory. I agree that you may have successfully added a 30 GB presentation using PowerPoint. I have also share that feedback that when our development team tried adding a 777 MB file, they have to set the heap size of 4 GB for that. Likewise, for video file greater than 4 GB you may have some additional Ram and Heap size requirements.

Many Thanks,