How to compress an FLV movie in java?
How can we compress the flv movie? Is there any free library which i can use?
for compressing the video i can go 开发者_JAVA百科for reducing the resoultion as well, even framerate reducing is acceptable to me.You can use Xuggler to do exactly this, directly from Java. Here's 3 lines of Xuggler's MediaTool API code that will transcode a file:
// create a media reader
IMediaReader reader = ToolFactory.makeReader("videofile.flv");
// add a viewer to the reader, to see the decoded media
reader.addListener(ToolFactory.makeWriter("output.mov", reader));
// read and decode packets from the source file and
// and dispatch decoded audio and video to the writer
while (reader.readPacket() == null)
;
See the tutorials and user groups and other examples for how to tweak encoding parameters.
Take a look at ffmpeg a good place to start might be
http://sourceforge.net/projects/jffmpeg/
It's a Java wrapper for ffmpeg
FLV is simply a container format - the actual codecs used within an FLV vary. Additionally, the codecs themselves are patented, meaning there are legal barriers for using them.
According to Wikipedia, FLV files likely contain video compressed using Sorenson Spark or VP6. If you know which codec your movie uses, you might try finding a library that can work with it.
It's very likely, however, that there are already tools available for encoding or re-encoding FLV files which you might be able to use via JAVA or some other language.
精彩评论