xuggle concurrent transcoding

523 views Asked by At

I'm xuggle primer and I'd like to transcode video to various formats/qualities. As a newbie I'd like to use the Xuggle MediaTool. As I need to do it efficiently, I want to process each target format in a separate thread. What's the correct concurrency pattern for this case?

Let's say I have file.avi and I'd like to transcode it to .flv and .mov. I'm curious if xuggle starts threads for each Writer in a following case:

IMediaReader reader = ToolFactory.makeReader("file.avi");
reader.addListener(ToolFactory.makeWriter("file.flv", reader));
reader.addListener(ToolFactory.makeWriter("file.mov", reader));
while (reader.readPacket() == null){}

Or maybe I should start conversion for each format in a separate thread?

(code from: MediaTool Introduction)

1

There are 1 answers

1
Art Clarke On BEST ANSWER

Xuggle does not start any threads(1) and it's up to you to manage threads. In addition, Xuggle objects are not thread safe -- you must control access yourself.

However before you add multiple threads, it may be worth measuring performance out of the box. Multiple threads on a multi-core machine will definitely speed up encoding, but you may not need that benefit.

Art

(1) Not entirely true but in your case Xuggle does not start any threads. Xuggle will (as of version 4.0) at most start one other thread that it uses for memory cleanup.