If you want to do it with java, you can do it very easily using Xuggle.
They have a great website explaining how to do everything
the documentation is here:
http://build.xuggle.com/view/Stable/job/xuggler_jdk5_stable/javadoc/java/api/index.html
and an excellent tutorial telling you how to do what you want is here:
http: //blog.xuggle.com/2009/06/05/introduction-to-xuggler-mediatools/
They provide an easy way to do what you want in the first tutorial, which is simple trans-coding.
I've found that it works alright for encoding to flv. What it does behind the scenes is use ffmpeg, so anything that will trip up ffmpeg will also fail with xuggle.
The relevant sample java code is:
// 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)
;
Which I got from
http ://wiki.xuggle.com/MediaTool_Introduction
If you want some fully working clojure code... here it is :)
(import '(com.xuggle.mediatool ToolFactory))
(import '(com.xuggle.mediatool IMediaDebugListener IMediaDebugListener$Event))
(defn readerRecurse
"calls .readPacket until there's nothing left to do2"
[reader]
(if (not (nil? (.readPacket reader))) ; here .readPacket actually does the processing as a side-effect.
true ; it returns null when it has MORE ro process, and signals an error when done...
(recur reader)))
(defn convert
"takes video and converts it to a new type of video"
[videoInput videoOutput]
(let [reader (ToolFactory/makeReader videoInput)]
(doto reader
(.addListener (ToolFactory/makeWriter videoOutput reader))
(.addListener (ToolFactory/makeDebugListener (into-array [IMediaDebugListener$Event/META_DATA]))))
(readerRecurse reader)))
now all you have to do is something like:
(convert "/path/to/some_file.stupid_extention" "/path/to/awesome.flv")
and you're done!