The aim of this project is to provide an easy to use interface to FFmpeg. This project is not command line based like many others do. In addition JavaAV is easily maintainable. First, the native FFmpeg library is accessed through JNI. There is no other extra layer of native code like in Xuggler. Second, all the JNI classes are automatically generated with JavaCPP. Even the compilation into native code is controlled by JavaCPP. This way there is less effort to react to new FFmpeg updates. To improve JavaAV or fix bugs you do not need to touch the native code.
Below some code snippets are shown to demonstrate the API usage. For more complete code see the examples section.
Enumerate installed codecs (each string contains name, type and description):
String[] codecs = Codec.getInstalledCodecs();
Create and use a real-time video encoder:
Options options = new Options();
options.put("tune", "zerolatency");
options.put("preset", "ultrafast");
Encoder encoder = new Encoder(CodecID.H264);
encoder.setPixelFormat(PixelFormat.YUV420P);
encoder.setImageWidth(1280);
encoder.setImageHeight(720);
encoder.setGOPSize(25);
encoder.setBitrate(2000000);
encoder.setFramerate(25);
encoder.open(options);
BufferedImage image = ...;
VideoFrame frame = VideoFrame.create(image);
MediaPacket packet = encoder.encodeVideo(frame);
... send packet over a network, write it to a file or whatever
encoder.close();
Below is the list of some basic examples. All examples can be found in the projects src/examples folder.
For those who use Maven may include this project as dependency:
<dependency>
<groupId>com.github.hoary</groupId>
<artifactId>JavaAV</artifactId>
<version>0.5</version>
</dependency>
You can also download JavaAV manually. In doing so, JavaAV and the necessary dependencies must be added to the classpath.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。