• Post Reply Bookmark Topic Watch Topic
  • New Topic

java wrapper for ffmpeg (video conversions)  RSS feed

 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java system that needs to execute ffmpeg to convert video files from one format to another. Looks like I need to interface with JNA. Years ago some people wrote wrappers for interfacing with ffmpeg but those all look un-maintained.

Are there any suggestions on what is the best way to interface with ffmpeg to convert files from one format to another?
Any good JNA wrappers for ffmpeg?
Any really horror stories and lessons learned, so that I can avoid them???
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds complicated so moving to Java in General.
 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not moving to java persey. thier purchased java product is either not performing to expectations, out of date, unreliable, licensing is ending.

The powers that be have decided on using a known failry reputable free executable (ffmpeg) for transforming videos, veruses a paid for product that keeps having bugs.

So they are technically moving away from java in this case
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
peter cooke wrote: I have a java system that needs to execute ffmpeg to convert video files from one format to another. Looks like I need to interface with JNA. Years ago some people wrote wrappers for interfacing with ffmpeg but those all look un-maintained.

Are there any suggestions on what is the best way to interface with ffmpeg to convert files from one format to another?
Any good JNA wrappers for ffmpeg?
Any really horror stories and lessons learned, so that I can avoid them???


I have used Xuggler framework in a java web portal, mainly for conversions from common formats to FLV. It's good - I had no major complaints. Documentation however is not comprehensive - you sometimes have to trawl their forums to find out how to do something.
Technically, it's a java adaptor around ffmpeg functionality, that interfaces with ffmpeg libraries using Swig generated wrappers.

Not sure what functions you're looking for, but here are some gotchas I encountered with it (note: this is 1 year old information; things may have improved/changed now):

- It did not support all codecs that the underlying ffmpeg supported. ffmpeg standalone would convert some formats without issues, while xuggler threw unsupported format errors.

- Xuggler imposed some additional constraints of its own on formats. I have not done any comprehensive study on what additional constraints it imposed, but one I encountered is that it required audio streams to have only one of 3 sampling rates - 11050, 22050 or 44100 Hz - when converting to FLV. This was a hindrance when converting the typically 48kHz WMV audio streams to FLV. I had to first resample audio (xuggler itself can do this; no external additional library required) at one of these 3 rates, and then convert to FLV.

- Xuggler had problems with Microsoft WMV format latest versions, mainly because WMV is a closed format and needs to be reverse engineered by xuggler team. In my case, files created using Windows Vista/7 Moviemaker had issues converting to FLV.

- Xuggler didn't seem to understand data streams - like subtitle text streams in WMV files. I discarded data streams while converting.

- If using in a shared environment like Tomcat, put the xuggler jars in the shared jar path common to all hosted web apps. This is because xuggler's design is such that its native library can be safely loaded by only one classloader.

I would advise that you create a xuggler prototype, gather a collection of media files of different encoding and formats that reflect your application's usage in production, try converting them using the prototype, and study problems. The minor details and gotchas are not really documented anywhere, and I suspect they change with each release.
 
peter cooke
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the info. discovered researching xuggler, is not allowed to use the AAC codec.
and I the main feature for the release is AAC.

so I am forced into using runtime.exec(...)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!