Skip to content

Latest commit

 

History

History
72 lines (47 loc) · 2.84 KB

README-en.md

File metadata and controls

72 lines (47 loc) · 2.84 KB

中文

Jave, An Audio Transcoding Tool

This tool is mainly used to convert the AMR to MP3 format for playing in the audio tag of HTML5.

Linux, Windows and Mac is all supported.

Based on a well known project, named JAVE which relies on ffmpeg, this tool can be used to all ffmpeg supported format conversion. See JAVE official documentation for details.

USE EXAMPLE

Inclue Maven Depandency

 <dependency>
    <groupId>com.github.dadiyang</groupId>
    <artifactId>jave</artifactId>
    <version>1.0.6</version>
 </dependency>

Invoke AudioUtils.amrToMp3 Method

Just 3 lines, JAVE make it extraordinary easy.

public void amrToMp3()  {
    File source = new File("target/test-classes/material/testAudio.amr");
    File target = new File("testAudio.mp3");
    AudioUtils.amrToMp3(source, target);
}

HOW IT WORKS

  1. Determine the current running environment when initializing and copy the corresponding ffmpeg executable file in classpath:bin directory to a temporary directory
  2. Invoke Runtime.getRuntime().exec(cmd) to execute ffmpeg's transcode command according to the format and configuration.

PROBLEMS OF THE OLD JAVE PROJECT

Ffmpeg is dependent on runtime platform, and JAVE project encapsulation the ffmpeg, it make ffmpeg has cross-platform features by the above mechanism. However, the old JAVE project has the following problems:

  1. It's too old. The latest time they release it was 2009. The ffmpeg it involved was outdated and didn't work in many conditions.
  2. EncoderException: Stream mapping somethings occur.
  3. It didn't publish to Maven Central Repository. Besides, JAVE itself is not a maven project.
  4. Mac was not supported.

Therefore, I created this project to solve the above problems.

FEATURE OF THIS NEW JAVE

  1. This is a maven project and has published to Maven Central Repository.
  2. The ffmpeg was updated and verified. (The project provided an unit test to easily verified)
  3. Avoid the EncoderException: Stream mapping.
  4. Linux, Windows and Mac is all supported.

EXTENSION

Set System.setProperty("ffmpeg.home", "your ffmpeg executable file's path") to specify your own ffmpeg executable when the provided one doesn't match your runtime.

eg. System.setProperty("ffmpeg.home", "/usr/local/bin/")

REFERENCES

LICENSE

JAVE project is open source following GPL License, and this new JAVE project is modified and enhanced on the basis of JAVE, hence GPL License is adopted.