How to compute output video length?

37 views
Skip to first unread message

Fabian

unread,
Jul 12, 2012, 2:10:03 PM7/12/12
to xuggle...@googlegroups.com
Hey guys,

I'm using an IMediaWriter to encode a sequence of images to a video. It's working perfectly fine, but I'm wondering if there's any possibility of computing the output video length with given frameTimeStep. In fact:

IMediaWriter encoder;
int frameTimeStep = 25;
int currFrameTime = 0;
encoder = ToolFactory.makeWriter(destinationFile);
encoder.addVideoStream(0, 0, width, height);
 
for (image img : sequenceOfImages) {
currFrameTime += frameTimeStep
encoder.encodeVideo(0, img, currFrameTime, TimeUnit.MILLISECONDS);
}
 
encoder.close();
(That's not exactly how the implementation actually is, but I think you'll get the point.)

I'd like to know, given the frameTimeStep, how long is the output video going to be? Obviously the length is independent from the numbers of images which are encoded, but the greater frameTimeStep the longer the video.

Thanks and best wishes,
furby

Furby

unread,
Jul 12, 2012, 2:19:12 PM7/12/12
to xuggle...@googlegroups.com
Oops my fault. The video length is actually changing with the numbers of encoded images.

So how can I compute the length of the output video given the total number of encoded pictures nad the frameTimeStep?

Best wishes,
furby
 

Furby

unread,
Jul 12, 2012, 2:24:55 PM7/12/12
to xuggle...@googlegroups.com
Ok now I've figured it out. Sorry for these posts, but maybe it is useful for somebody.

Output video length in seconds = (totalnumberOfPictures * frameTimeStep) / 1000

Division by 1000 because of the chosen TimeUnit.

Best wishes,
furby
Reply all
Reply to author
Forward
0 new messages